Description

If a section header has extra spaces, either trailing or leading, then the hashing algorithm for the #head-xxx anchor computes one hash for the Table of Contents (TOC), and one hash for the section itself. Thus, clicking on the TOC entry will not jump to that section.

Example

MoinMoinBugs/TableOfContentsBreakOnExtraSpaces/Test has a page with a lot of vertical space, so you can click and see the page jump (or not jump). Or, you can look at the html source for this page.

Header with leading space

Header with trailing space

Details

This Wiki.

Discussion

A work-around is for the page author to remove those spaces, but he or she would have to know about the bug.

The problem is not related to headings generation, both = head = and =     head    = are formated identically. See "parser.wiki: ignore white space around heading text" in http://nirs.dyndns.org/tests?test .

The problem is in the way the TOC macro creates the links, which is different from those created by the parser/formater, see "parser.wiki: TOC links to headings with white space" in http://nirs.dyndns.org/tests?test

======================================================================
FAIL: parser.wiki: TOC links to headings with white space
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Volumes/Home/nir/Projects/moin/tests/MoinMoin/_tests/test_parser_wiki.py", line 101, in testHeadingWithWhiteSpace
    'Expected "%(expected)s" but got "%(result)s"' % locals())
  File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/unittest.py", line 292, in failUnlessEqual
    raise self.failureException, \
AssertionError: Expected "<ol>
<li>
<a href="#head-8809edb77f319ec2f52fca2114de27d637fa4642">heading</a></li>
</ol>

 <h2 id="head-8809edb77f319ec2f52fca2114de27d637fa4642">heading</h2>Text " but got "<ol>
<li>
<a href="#head-df10d250709b57a192d521cb3f8cbf327d2c0f39">  heading  </a></li>
</ol>

 <h2 id="head-8809edb77f319ec2f52fca2114de27d637fa4642">heading</h2>Text "

Plan


CategoryMoinMoinBugFixed

MoinMoin: MoinMoinBugs/TableOfContentsBreakOnExtraSpaces (last edited 2007-10-29 19:19:17 by localhost)