Contents
GetTOC
Background and rationale
The MoinMoin macro TableOfContents creates a contents list for the current page, but not for another page, which of course is totally sensible. However, the collect.py parser combines pages into a single page and being able to included a contents list for each of these in a cover page would be useful. So this GetTOC macro was written as a helper macro for that parser. However, it might have some, albeit limited, applicaiton in other contexts.
Description
GetTOC gets a Table of Contents for the current or another page by calling the MoinMoin macro TableOfContents. It then converts the table heading, "Contents", to a hyperlink to a page anchor with a suffix of '.top', before inserting it in the current page. For this anchor link to be useful, the anchor needs to be inserted on the current page using the Anchor macro. This is done automatically by the collect.py parser. If done directly for pages with name containing non-alphanumeric characters, the name needs to be converted to text in the same way this is done by MoinMoin.wikiutil.wikiutil.anchor_name_from_text.
Usage
<< GetTOC(pagename, maxdepth)>>
Both arguments, "pagename" and "maxdepth", are optional. <<GetTOC(pagename, maxdepth)>> - inserts a Table of Contents for pagename to depth of maxdepth <<GetTOC>> or <<HttpLink()>> - inserts a Table of Contents for the current page <<GetTOC(, maxdepth) - inserts a Table of Contents for the current page to depth of maxdepth
Examples
<<GetTOC(MoinMoin Matters, 1)>> <<GetTOC>> <<GetTOC(, 2)>>
The links in the first example above have no targets on this page. See collect.py for details of how it can be used.
The target for Contents link in the other two examples has been inserted at the top of this page using <<Anchor(GetTOC.py.top)>>, and the heading links point to the headings on this page.
Download & Release Notes
Download |
Release Version |
Moin Version |
Release Notes |
1.0 |
1.9.2 |
|
Copyright
@copyright: 2014 Ian Riley <ian@riley.asia>
License
GNU GPL, see COPYING for details.
Known issues and limitations
- None known
- Hits
554