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