Page MenuHomePhabricator

Dummy anchor with id="top" at the top of the page breaks links to section named "top"
Open, Needs TriagePublic

Description

See for example this page and click on the "top" section in the TOC.

Event Timeline

Change 481313 had a related patch set uploaded (by AuroraAri; owner: AuroraAri):
[mediawiki/core@master] Allow TOC to "duplicate" existing anchors in MediaWiki

https://gerrit.wikimedia.org/r/481313

AuroraAri added a subscriber: AuroraAri.

I've submitted a patch which adds a new $reservedAnchors array in the parser. If you attempt to create a section heading with a headline that is in that array, it will treat it as though it's already in the TOC. Because MediaWiki already has the functionality to detect duplicate section headings, we piggyback on that.

Please excuse the terrible explanation of this; words are failing me right now. :)

Currently, if there's a single section heading called top, MediaWiki will assume that it's the only thing that has the top anchor. But that's not the case: a top anchor is defined elsewhere. MediaWiki doesn't know that, though. MediaWiki already knows how to handle duplicate section headings (by adding a _$i) to the anchor, so we're utilizing that logic and just making the software aware that there's already something there.

With this patch, the first instance of top as a section heading will be assigned the anchor of top_2.

(Hopefully that's better! 😃)

No longer actively working on this task.

Change 481313 abandoned by AuroraAri:

[mediawiki/core@master] Allow TOC to "duplicate" existing anchors in MediaWiki

Reason:

No longer actively working on this task.

https://gerrit.wikimedia.org/r/481313