Page MenuHomePhabricator

Parser inconsistency when a <hX> tag has an id attribute
Open, Needs TriagePublic

Description

Given the following wikitext: <h2 id="attr">text</h2>
We get very different parser outputs:

Parsoid:<h2 id="attr">text</h2>
Legacy parser, legacy heading mode:<h2 id="attr"><span class="mw-headline" id="text">text</span></h2>
Legacy parser, new heading mode:<h2 id="text" id="attr">text</h2>

Also, the link in the TOC goes to #attr in Parsoid, but to #text in legacy parser in both modes.

We definitely should fix legacy parser's new heading mode to not output a duplicate attribute. The other inconsistencies may be acceptable, but seem worth considering.

Event Timeline

Change #1036714 had a related patch set uploaded (by Bartosz Dziewoński; author: Bartosz Dziewoński):

[mediawiki/core@master] OutputTransform: Fix double IDs on headings

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

Would be ideal if legacy could match Parsoid...