2009-08-13
pomax
Pages with multiple sections with the same name will lead to these sections all having the same anchor link; on a page with the following structure, for instance, things will go wrong:
introductory page on grammar
verbs
basics
some examples
nouns
basics
some examples
This will be translated into a document with (for illustration purposes simplified) anchors:
#intro
#verbs
#basics
#examples
#nouns
#basics
#examples
This means that linking to sections on other pages will, for the 'basics' and 'examples' sections nested under nouns, point to wrong locations.
A solution would be to track section headers as they run through the renderer, and performing an 'already seen?' check, appending a tracking number to the anchor text if a section has been seen already, a la:
anchor = sectiontitle;
if(sectiontitlefound && isset(seentitles[sectiontitle])) {
anchor = sectiontitle . "_" . ++sectiontitles[sectiontitle]; }
else { sectiontitles[sectiontitle]=1; }
This would be able to cope with pages that have two or more (rather than just two) sections with the same name.
Particularly for pages that concern comparasons, or property listings, this will be a frequent occurence.
It's not a very severe issue, but it should be relatively easy to fix.