changeset 4673:307c423cf0d1

macro.TableOfContents: bug fix for MoinMoinBugs/TableOfContentsIgnoresSectionNumbersPragma
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Tue, 31 Mar 2009 16:26:36 +0200
parents 357ad7160d15
children 0946442e94ab
files MoinMoin/macro/TableOfContents.py
diffstat 1 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/macro/TableOfContents.py	Tue Mar 31 00:31:16 2009 +0200
+++ b/MoinMoin/macro/TableOfContents.py	Tue Mar 31 16:26:36 2009 +0200
@@ -137,6 +137,11 @@
 
  maxdepth:: maximum depth the table of contents is generated for (defaults to unlimited)
     """
+    try:
+        mindepth = int(macro.request.getPragma('section-numbers', 1))
+    except (ValueError, TypeError):
+        mindepth = 1
+
     if maxdepth is None:
         maxdepth = 99
 
@@ -176,7 +181,7 @@
         if txt is None:
             incl_id = id
             continue
-        if lvl > maxdepth or id is None:
+        if lvl < mindepth or lvl > maxdepth or id is None:
             continue
         if lvl < lastlvl:
             lastlvl = lvl
@@ -188,7 +193,7 @@
         if txt is None:
             incl_id = id
             continue
-        if lvl > maxdepth or id is None:
+        if lvl < mindepth or lvl > maxdepth or id is None:
             continue
 
         # will be reset by pop_unique_ids below