Page MenuHomePhabricator

[refactor] Find a way to create a unique reference list item id in VE
Open, Needs TriagePublic

Description

Parsoid domToWikitext relies on Cite's AnchorFormatter::getNoteTextIdentifier to give reference list item content span an id like mw-reference-text-<normalized-name>-<global-sequence> for named refs or just mw-reference-text-<global-sequence> for unnamed refs, where the reference name has been normalized in a non-reversible way and the global sequence is an integer not indexed anywhere else. Sub-references point to these items by data-mw.mainBody which is used to get the main footnote body when serializing a main+details ref tag as wikitext. Currently, this ID is stored in MWReferenceNode as refListItemId.

This task is about designing and implementing a better ID or other DOM selector—for example by using the reference number to identify refs, since this is a piece of unique and well-formed data which is known at the time of usage: mw-reference-text-<group-name>-<footnote-number>

DOM ID should support any character except whitespace, so we may need to use a 1:1 mapping on group name such as URL escaping.

Note that the reflist item ID is currently used in several places:

  • Anchor target for footnote marker links
  • Parsoid domToWikitext
  • Reference Previews
  • Mobile ref previews

Event Timeline

Change #1194679 had a related patch set uploaded (by Awight; author: Awight):

[mediawiki/extensions/Cite@master] [WIP] Exploring issues with serializing refs

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

Change #1194661 had a related patch set uploaded (by Awight; author: Awight):

[mediawiki/extensions/Cite@master] [WIP] [refactor] Serialize main+details without synthetic ref

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

Change #1195235 had a related patch set uploaded (by Thiemo Kreuz (WMDE); author: Thiemo Kreuz (WMDE)):

[mediawiki/extensions/Cite@master] Normalize whitespace/underscores in group/name much earlier

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

I just realized that the idea to use only the reference group + name to identify it on a page doesn't work, not even with T409909 fixed. Here, this is a valid document, split into two independent sections, both with a [1] reference.

<ref name="a">Test</ref>
<references />
<ref name="a">Something else</ref>
<references />

This is used on help pages. The only way to distinguish these is the global id, which is global per document and not reset between such reference sections.

WMDE-Fisch renamed this task from [refactor] Reference list item DOM ID must be calculable to [refactor] Find a way to create a unique reference list item id in VE.Jan 12 2026, 1:49 PM

Change #1194661 abandoned by WMDE-Fisch:

[mediawiki/extensions/Cite@master] [WIP] [refactor] Serialize main+details without synthetic ref

Reason:

the underlying code is different now and I think the problem less server

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