#format wiki #language en #pragma section-numbers off #acl IanRiley:read,write,delete,revert,admin All:read #pragma supplementation-page on <> <> = 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. <> - inserts a Table of Contents for pagename to depth of maxdepth <> or <> - inserts a Table of Contents for the current page <> <> <> }}} <> <> <> 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 `<>`, and the heading links point to the headings on this page. == Download & Release Notes == || Download || Release Version || Moin Version || Release Notes || || [[attachment:GetTOC-1.0.py]] || 1.0 || 1.9.2 || || == Copyright == . @copyright: 2014 Ian Riley == License == GNU GPL, see COPYING for details. == Known issues and limitations == * None known ----- Hits:: <>