Page MenuHomePhabricator

Block nesting <ref> tags in the details syntax
Open, Needs TriagePublic

Description

Nesting <ref> tags in <ref> tags is historically forbidden, and needs to stay forbidden, unless we actively make the decision to lift this limitation. At the moment the prototype (see T378814) allows nesting.

<ref details="additional details &lt;ref&gt; sub content &lt;/ref&gt; "> main content </ref>

Event Timeline

Unfortunately, nested refs are allowed and we've seen them on the wikis. The trick is to use {{#tag:ref, here's an example:

https://en.wikipedia.beta.wmflabs.org/wiki/User:Adamw/nested-refs

Article body text{{#tag:ref|Footnote body<ref>Subfootnote body</ref>}}

Good, we even counted them with the scraper under the metric nested_ref_count. There are 400k on English Wikipedia alone, if our scraper is to be trusted!

Good, we even counted them with the scraper under the metric nested_ref_count. There are 400k on English Wikipedia alone, if our scraper is to be trusted!

That sounds like the right order of magnitude, there are 240k transclusions of template:efn the vast majority of which will have at least one reference.

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

[mediawiki/extensions/Cite@master] Add test case for nested <ref> inside the details="…" attribute

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

Change #1129202 merged by jenkins-bot:

[mediawiki/extensions/Cite@master] Add test case for nested <ref> inside the details="…" attribute

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

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

[mediawiki/extensions/Cite@master] Add missing name attribute to recently added parser test

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

Change #1129791 merged by jenkins-bot:

[mediawiki/extensions/Cite@master] Add missing name attribute to recently added parser test

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

Current state:

  • Nesting refs via the main content is possible with and without the details= attribute being involved.
    • With details: {{#tag:ref|Outer ref<ref name="a" details="Inner details" />|name=a|details=Outer details}}
    • Without details: {{#tag:ref|Outer ref<ref name="b">Inner ref</ref>|name=a}}
    • Technically unrelated to this ticket. Just for reference.
  • Refs can be nested in the details= attribute: {{#tag:ref|Outer ref|name=a|details=Outer details<ref name="b">Inner ref</ref>}}
    • ☠️ The legacy parser actually renders this. But in a weird order that feels backwards.
    • ☠️ Parsoid displays an unresolved strip marker from the legacy parser: UNIQ--ref-00000000-QINU.
  • When I use the #tag function for the inner ref: <ref name="a">{{#tag:ref|Inner ref|name=a|details=Inner details}}</ref>
    • ✅ The rendering is the same in both parsers.
    • ☠️ Parsoid doesn't show any error message.

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

[mediawiki/extensions/Cite@master] Add test cases for nesting (sub)refs inside details syntax

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

Just noting that we currently mention the possibility to combine nested references and sub-references on our project page because some community members asked about it https://meta.wikimedia.org/wiki/WMDE_Technical_Wishes/Sub-referencing#Nesting_sub-references – we should revisit that if we decide to make any changes to the current state.

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

[mediawiki/extensions/Cite@master] Block nesting (sub)refs in the details attribute

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

Well, it's currently broken and unusable anyway, at least in Parsoid. Maybe we are talking about two different classes of "nesting"?

I was referring to the option "Nesting refs via the main content" which is technically unrelated to this ticket (and which works in Parsoid). Our project page makes no mention of nesting refs in the details attribute so far. Just wanted to mention that we should check if the statements on our project page is still correct when making changes in this ticket.

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

[mediawiki/extensions/Cite@master] Move check for nested <references> tags into Validator

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

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

[mediawiki/extensions/Cite@master] Report nested <references> tags in Parsoid as well

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

Change #1259001 merged by jenkins-bot:

[mediawiki/extensions/Cite@master] Add test cases for nesting (sub)refs inside details syntax

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