Summary: Talk page for AutoTOC.
Maintainer: Petko
Users: +8 (View / Edit)

This space is for User-contributed commentary and notes. Please include your name and a date along with your comment.

The AutoTOC recipe on this page has enabled the "numbered headers" mode.

Conflict with NumberHeaders

Hi. Thank you, this recipe is very useful. I have just a problem: I tried to install numtoc_max (then I try the less interesting numtoc) but nothing works. Is there any way to solve the problem and have automatic numbers in the text and in TOC? For example (usual headers (! -> !!!!!!):
1 Header

1.1 Subheader
->1.1.1 Subsubheader
->-> Subsubheader

2 Another Header

2.1 Subheader
2.2 Subheader

I hope there is a solution, otherwise may I suggest this as a new feature for the next upgrade? Thank You. (P.S. Don't consider the -> in the example, it is just to show the different indentation). --Frank? January 11, 2013, at 08:50 AM

Reply 1

Currently AutoTOC doesn't do numbered headers itself, if the headers in the page are not numbered. But I'll see if it is possible to implement it in the future. --Petko January 11, 2013, at 11:50 AM

Just for information : css can work with counter (cf. dev opera). gb January 12, 2013, at 02:52 PM

Reply 2

Last night I have prototyped the automatic numbering so I'll add it and document it in less than 48 hours. Both the headings and the table of contents can be automatically numbered. --Petko January 12, 2013, at 03:25 PM


Version 20130114 can automatically number the headings in the page. This feature should be considered experimental. The other recipe NumberedHeaders does not need to be installed for this to work. --Petko January 14, 2013, at 07:39 AM

Hi Petko, I just tried ... fantastic, it works perfectly. I have no words, thank you very much... not to mention that you did it in record time. --Frank? January 16, 2013, at 04:37 PM

Disable by default?

Hi, thanks for the lovely plugins. I was wondering if there is a way to disable the creation of TOCs by default so that they only appear on pages which have the (:toc:) directive? For now I've simply set $AutoTocNbHeadings = 100;, but that seems hackish. Thanks again. --AdamShand

I have released a new version today which will disable all toc processing and will not load the script if $AutoTocNbHeadings is -1 and there is no (:toc:) directive. But in that case, should the recipe be called AutoTOC? :-) Petko September 12, 2012, at 02:12 AM

Conflict with WikiWords

Hello. This recipe is working great in automatic mode, but when I try to force its include in this wiki page some weird interference happens. It might be related with WikiWords? Thanks for your help --simkin November 10, 2011, at 02:06 AM

Thanks for the report, the new version hopefully fixes it. --Petko November 10, 2011, at 03:38 AM

Yes, It works fine now. Thanks a lot for the fast support --simkin November 10, 2011, at 04:49 AM

International and special characters

I'm testing this smart recipe and I would love if it were possible to produce a nicer anchor's name. In the current version, accentued letters, and signs, are unfriendly encoded (si.C3.A8cle for siècle) : is there some way to do as if accentued letters are unaccentuented, and all signs are - or spaces (_), before generating the anchor's name ? gb December 21, 2011, at 06:29 PM

You can test the latest version 20111222 with the $AutoTocIdEncoding mode "fold" or one of the others. Alternatively, you could force individual anchor names by setting an id of the heading like !! Français %block id=Francais% (see an example on AutoTOC#Voila_en_francais). --Petko December 22, 2011, at 10:41 AM

Great work Petko and nice result, thank you. Just for information : in fold mode, I wanted ~ and – and ’ to be transformed in _ rather than deleted ; thus I altered js file, line 56 to
hash = hash.replace(/(~|’|–|\s+)/g, '_').replace(/[^\w\s]+/g, '');

The version 20120416 allows the defining of custom replacements for the fold mode, without modifying the script, see $AutoTocCustomFold. --Petko April 16, 2012, at 01:37 PM

Scrolling issue in Firefox but not IE

I tried using the AutoTOC anchor to jump from another page directly to the section, but found it just went to the page, and did not scroll the desired section to the top of the screen.

I also tried it as the target for a redirect, with the same result - went to the page, but not to the section.

I have now found that this works as expected in IE, and the links go to the section anchors.

It fails in Firefox, and only goes to the page, regardless of any AutoTOC anchor after the #.

I've tried this in Fx safe mode, just in case any add-ons were interfering, but no change.

Des January 30, 2012, at 06:10 AM

The latest version from 2 days ago should have fixed that problem. If I go to AutoTOC#Installation, it scrolls down to the section. A browser cache refresh may be needed if your browser has cached the old version of autotoc.js. Also note that the anchor names are case sensitive, #Notes is not the same as #notes. --Petko January 30, 2012, at 10:12 AM

Thanks for the note - it looks as if it was indeed just the cache as you suggested, because the jump worked as soon as I fired things up this evening, without me having to force a flush. (Always copy and paste links - I have been down the typo/case dead-end too many times.)

Just mentioning in passing since I saw it (ie NOT seeking a fix), while trying things to see if I was doing something wrong, I noticed the these anchors don't work if used with PmWiki's (:include :) markup.

Thanks for AutoTOC - it's a superb replacement for all the others that tried to do a TOC.

Des January 30, 2012, at 04:39 PM

The AutoTOC and its anchors are generated by your browser, not by the PmWiki markup engine. If you include a page, its headings should appear in the TOC and should have the anchors generated. The other way around is not supported: if you want to include a section of a wiki page, you have to add the [[#section]] anchors in the source. --Petko January 30, 2012, at 05:05 PM

Talk page for the AutoTOC recipe (users).