After I add [toc] to the page, it does not gets validated from validator.w3.org as it has some html coding errors.

<div class="toc" id="toc">
<div class="toc-title">Contents</div>
<div class="toc-list">
<ul>
</li>
<li class="toc-level-1"><a href="#Test1">Test1</a></li>
<li class="toc-level-1"><a href="#Test2">Test2</a></li>
<li class="toc-level-1"><a href="#Test3">Test3</a></li>
</ul>
</div>
</div>

</li> <-- this is an unnecessary code which is being added to the html code

Comments

AlexisWilke’s picture

In my test, it looks like correct HTML...

<script type="text/javascript">toc_collapse=0;</script><div class="toc" id="toc">
<div class="toc-title">Summary<span class="toc-toggle-message">&nbsp;</span></div>
<div class="toc-list">
<ul>
        <li class="toc-level-1"><a href="#Isn-t_that_Simple_Enough">Isn't that Simple Enough?</a></li>
        <li class="toc-level-1"><a href="#So_Readon">So Read on!!!</a></li>
        <li class="toc-level-1"><a href="#How_about_the_count">How about the count?</a></li>
        <li class="toc-level-1"><a href="#What_about_the_anchors">What about the anchors?</a></li>
</ul>
</div>
</div>

First you'd need to check with a tool like wget to report exactly what your website spits out because in a browser it is most often tweaked by the browser. Otherwise, it looks like somehow one of your anchors did not make it right to the table of contents...

Thank you.
Alexis Wilke

himagarwal’s picture

I checked it with Internet Explorer and Google Chrome using http://validator.w3.org and both shows the same problem.

I'm using following settings when the error appears
Minimum heading level: H3
Maximum heading level: H3

But error disappears when I set it as follows:
Minimum heading level: H2
Maximum heading level: H3

But, I only want H3 to show up in table of contents.

Also, I checked the source code of my page and each and every H3 were outputting fine. All H3 anchors were able to make it to the table of contents.

So, I think there is some problem with setting both minimum and maximum heading level is H3.

AlexisWilke’s picture

Ah! Okay! I think you hit a problem that was mentioned before. If you have any H2 tags, then I think that it will add another <ul> tag without any <li>, or at least not the proper way...

Is your page public? Could you give us a URL?

Thank you.
Alexis

himagarwal’s picture

I have sent you the link through your contact page. Please check your email.

AlexisWilke’s picture

Version: 6.x-3.7 » 7.x-1.x-dev
Assigned: Unassigned » AlexisWilke

Okay, I found the problem. I was using $index as a flag to know whether the entry was the very first one or not. If not, then I added a </li>. This is fixed in the development version for now.

D6 commit: http://drupal.org/node/1507372

I'm moving that to version 7.x now because it is likely that the problem still exists in that version.

Thank you for your persistence.
Alexis

slv_’s picture

Assigned: AlexisWilke » slv_

I Will have a look into this for for 7.x.

slv_’s picture

Status: Active » Closed (fixed)

This is now committed to 7.x. Thanks Alexis and himagarwal

rvbcocardes’s picture

Concerning the w3c validator, I obtain another error :
Validation Output: Error

Line 119, Column 16: end tag for element "p" which is not open

</div><br /></p><div class='toc-back-to-top'><a href='#toc'></a></div><h3 id="I…

The Validator found an end tag for the above element, but that element is not currently open. This is often caused by a leftover end tag from an element that was removed during editing, or by an implicitly closed element (if you have an error related to an element being used where it is not allowed, this is almost certainly the case). In the latter case this error will disappear as soon as you fix the original problem.

Checked my source code : the closing </p> is inserted by the module in the last line of the module insertion in my page...

Thank you for your comments and/or help,
Cheers,
RVB