[Moin-user] How to hide Includes in [[TableOfContents]]

Gisbert Amm gia at webde.de
Mon Oct 17 06:52:30 EDT 2005

Nir Soffer wrote:
 > On 17 Oct, 2005, at 10:55, Gisbert Amm wrote:
 >> One of our Wiki pages has some Includes like the following
 >> [[Include(ArchitekturZirkel/PersistenzKapselung, , 3, from="^## next
 >> milestone", to="^## next milestone end")]]
 >> and a table of contents like this:
 >> [[TableOfContents(")]]
 >> Unfortunaltely the includes are shown in the toc at the same level as
 >> the heading preceeding them; Moin uses the respective pagename as toc
 >> entry - e.g. "ArchitekturZirkel/PersistenzKapselung".
 > Its not clear what is the problem. Please show the created output and
 > the expected output. Then check Include macro documentation, probably in
 > Include.py.

Found it out: The problem lies the line # 100 of TableOfContents.py
A short snippet might show what I mean:

                 # this is an [[Include()]] line.
                 # now parse the included page and do the work on it.

                 ## get heading and level from Include() line.
                 tmp = self.arg_re.match(match.group(1))
                 if tmp and tmp.group("name"):
                     inc_pagename = tmp.group("name")
                     # no pagename?  ignore it
                 if tmp.group("heading"):
                     if tmp.group("htext"):
                         heading = tmp.group("htext")
                         #heading = inc_pagename

You see the line I commented out after the last else.

This else means: In the included page there is no heading found. 
Therefore the pagename of the included page is set as heading. You don't 
want this when you only include a small part of that page within the 
*main text* of your including page.

You can also see my quick fix for the problem: Simply ignore the include 
and continue.

However, this might not be the desired behaviour in other cases  when 
one wants the included page to show up in the toc.

OTOH, then one can simply provide a heading within the included page to 
get it into the toc of the including page. IMHO it feels much more 
natural and logical this way.

A better fix might be to look if there is "from" and "to" in the include 
definition and continue in this case and set heading = inc_pagename only 
if there is no "from" and "to".

Gisbert Amm

More information about the Moin-user mailing list