[Pmwiki-users] Automatic page table of contents with [[toc]]

John Rankin john.rankin
Mon Dec 1 12:34:22 CST 2003

Have a look at


It uses the [[toc]] variant.



This uses the [[toc*]] variant.

There is a page on PmWiki that prompted some of the ideas I 
implemented. See


In the mean time, I am struggling with how automatic indexing should
work. I have some very crude code that builds a 2 level table of
contents automatically, but it raises more questions than it answers.

1. Should the author have to use markup such as # to tag every entry
or should the system automatically pick up all headings in a page?

2. If automatic, should the system automatically generate anchors
for every heading or only on pages carrying a [[contents]] directive?

3. If automatic, should the author be able to designate the desired
depth, or should it be limited to (say) 2 levels, or should it go
to however many heading levels the page happens to use?

4. Is there a way to call the existing PmWiki nested lists code,
rather than have to figure it out? For example, is it possible to
process a [[contents]] directive first, convert it to 
# [[#toc1 text]]
## [[toc#2 text]]

and so on, plus convert all start of line ! to !#. Then the regular
PmWiki parser can take care of it for us. Although it may be a small
challenge to work out how many #'s to generate.

5. Does it need to support lists generated from [[#manualanchors]],
# automatically numbered anchors, *and* no anchor tagging and let
the system work it out?

I don't have good answers for any of these questions, which is why
so far I have stuck to a more manual approach. But I can see the
attraction of how MoinMoin and Wikipedia do it.

John Rankin

On Tuesday, 2 December 2003 6:35 AM, Christian Ridderstr?m <chr at home.se> wrote:

Do you have a page demonstrating the different tocs somewhere?
(It's easier for me to look at an example, and see how it should 
work before I try it on my site).

And maybe we should use a wiki page discussing the usage/syntax? 
(I don't mean anything more than simply pasting what's in these 
e-mails :-)

Anyway, I'll start to look at the attachments you sent in the other mail.


Dr. Christian Ridderstr?m, +46-8-768 39 44       http://www.md.kth.se/~chr

Pmwiki-users mailing list
Pmwiki-users at pmichaud.com

More information about the pmwiki-users mailing list