section-numbers pragma has no effect on TableOfContents macro
In version 1.5.5a of MoinMoin, setting the section-number pragma (#pragma section-numbers 2, see HelpOnProcessingInstructions) causes the TableOfContents Macro to ignore any headings whose number is below the level set in the pragma. This behaviour has regressed: it is no longer present in MoinMoin 1.8.1 nor in 1.8.2.
Please change TableOfContents to honour the section numbers pragma again.
1. Steps to reproduce
This wiki page reproduces the errant behavour.
2. Example
In MoinMoin 1.5.5a, the table of contents for this page would look like the following:
This is the desired behaviour!
Contents 1. Steps to reproduce 2. Example 3. Component selection 4. Details 5. Workaround
In version 1.8.1, it looks like
Contents 1. section-numbers pragma has no effect on TableOfContents macro 1. Steps to reproduce 2. Example 3. Component selection 4. Details 5. Workaround 2. Discussion 3. Plan
3. Component selection
This behaviour appears to have been introduced when MoinMoin/macro/TableOfContents.py was changed a as part of changeset 2562. A quick look in the code shows that TableOfContents.py now completely ignores the pragma. This means that #pragma section-numbers off will not work correctly either.
4. Details
This Wiki.
5. Workaround
None known.
Discussion
please help testing if that is what you expect
1 diff -r 83451b52e947 MoinMoin/macro/TableOfContents.py
2 --- a/MoinMoin/macro/TableOfContents.py Sat Mar 28 13:13:23 2009 +0100
3 +++ b/MoinMoin/macro/TableOfContents.py Mon Mar 30 22:47:29 2009 +0200
4 @@ -137,6 +137,11 @@
5
6 maxdepth:: maximum depth the table of contents is generated for (defaults to unlimited)
7 """
8 + try:
9 + mindepth = int(macro.request.getPragma('section-numbers', 1))
10 + except (ValueError, TypeError):
11 + mindepth = 1
12 +
13 if maxdepth is None:
14 maxdepth = 99
15
16 @@ -176,7 +181,7 @@
17 if txt is None:
18 incl_id = id
19 continue
20 - if lvl > maxdepth or id is None:
21 + if lvl < mindepth or lvl > maxdepth or id is None:
22 continue
23 if lvl < lastlvl:
24 lastlvl = lvl
25 @@ -188,7 +193,7 @@
26 if txt is None:
27 incl_id = id
28 continue
29 - if lvl > maxdepth or id is None:
30 + if lvl < mindepth or lvl > maxdepth or id is None:
31 continue
32
33 # will be reset by pop_unique_ids below
Works for me (see for example http://wooledge.org:8000/BashPitfalls).
Plan
- Priority:
- Assigned to:
Status: fixed by 4310:307c423cf0d1