--- ./moin-1.5.7/MoinMoin/Page.py-orig	2006-11-04 00:14:37.000000000 +1300
+++ Page.py	2007-05-02 12:02:24.000000000 +1200
@@ -1249,6 +1249,16 @@
         elif not request.user.may.read(self.page_name):
             request.write("<strong>%s</strong><br>" % _("You are not allowed to view this page."))
         else:
+            # if the config file has the "auto_toc" setting, insert a table
+            # of contents if the page has any headings
+            want_toc = False
+            try:
+                want_toc = self.cfg.auto_toc
+            except:
+                pass
+            if want_toc and pi_format == 'wiki' and not send_missing_page and (body.find("\n= ") >= 0 or body.find("\n== ") >= 0):
+                body = "[[TableOfContents(3)]]\n" + body
+
             # parse the text and send the page content
             self.send_page_content(request, Parser, body,
                                    format_args=pi_formatargs,
