Wiki Life: How To Fix a Wiki Article TOC


Hi ! Today I will show you how to fix a Wiki Article TOC.

The "TOC" feature

The “TOC” feature was introduced 2 years ago (see Wiki Life: How easy is it to add a table of contents?) and is probably one of the most used feature on the TechNet Wiki, as it is easy to use:

Use [toc] in the content of an article to automatically generate a Table of Contents!

And that's it. It's that simple, really. You just type "[toc]" anywhere in your article (in the Design tab; you don't have to be in the HTML tab). Then it takes all your headers and creates a TOC.

The TechNet Wiki article Wiki: How to Automatically Add a Table of Contents (TOC) to Your TechNet Wiki Article shows you how to automatically add a table of contents to your Wiki article by using the "[TOC]" tag.

Why should I fix my TOC?

The “TOC” feature is a great way to access content easily, but you should know that it does not always work, as explained here: Table of Contents (TOC) feature does not always work.

Things which make the TOC malfunctioning are the following:

  • Zeros in Heading Named Anchor Tag,
  • Foreign Characters in Heading Named Anchor Tag,
  • Duplicate Heading Named Anchor Tags.

How to fix a TOC

Firstly, you should have a look at these 2 Wiki articles, which will show you how to fix the TOC, and how to write an article in a foreign language:

In French we use a lot  of accentuated characters, like “Références” for “References”, or “L’article à lire” for “The article to be read”, so as I had many times the TOC malfunctioning I searched for an easier solution than switching to the HTML view to find the problems. Then I found in the TechNet Gallery a contribution named Parse TechNet Wiki Article HTML for Problems, uploaded by Richard Mueller; its description is the following:

VBScript program to parse a TechNet Wiki article HTML for problems, many of which affect the Table of Contents feature.

How to use it?

The tool is easy to use:

In preparation to run the script, open the TechNet Wiki article and click on the "Edit" tab. In the Wiki editor select "HTML" near the bottom (the default selection is "Design"). Copy the entire HTML of the article into a text file and save it. Then run this script and either specify the file with the HTML of the article as a parameter or let the script prompt you for the file.

To show you how to use Richard’s program, I created a sample Wiki article, containing some of the cases described previously in this article: a “0” or an accentuated character in the name, or leading digits which generates duplicate anchor tag names.

 

Once the tool launched it detect the “0” character in the first TOC entry:

 

The duplicate names:

And  the presence of " foreign characters" like “’”, or “à”, as in my example:

 

Then you have just to go to the HTML and fix the tag names ! Thanks Richard for this tool and ... For having updated it so quickly!

(By the way, the tool also detects RGB color values, which have to be replaced with standard color names.)

 

Benoît, the French Wiki Ninja

Comments (22)

  1. I had problems fixing TOC some days back (Naomi helped in fixing)……..Thanks Ben for sharing this !!!

  2. Excellent Benoît. Thanks for sharing.

  3. This is an awesome compilation of these resources and tells the big picture of TOCs! Thanks, Benoit!

  4. @All : Thanks for your comment !

    @Mahesh : I remember, and that's precisely why I wrote this blog post ! 🙂

  5. Merci pour ce tres bon article! 🙂

  6. I have used the script Benoit features above for a year now. It has helped me fix many TOC problems in the Wiki. I modified the script to handle some Portuguese characters, but Benoit found that some French characters also fool the TOC feature. The TOC ignores any headings with the foreign characters. Rather than tracking down every problem character, I revised the script to flag any extended ASCII characters. So far that works great.

  7. @Matthew, Bruno : 🙂

    @Richard : I can confirm that after your (quick !) update, all "french" characters I tested (é, è, à , ù) are now detected by your tool.

Skip to main content