Page MenuHomePhabricator

Information about ref name is not provided if the ref is generated by a template and it's the root
Open, MediumPublic

Description

Consider:

Some text.{{1x|<ref name="foo" />}}
<references>
<ref name="foo">asdf</ref>
</references>

Parsing result is (skipping the irrelevant parts):

<span about="#mwt2" class="mw-ref" id="cite_ref-foo_1-0" rel="dc:references" typeof="mw:Transclusion  mw:Extension/ref" data-mw='{"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"&lt;ref name=\"foo\" />"}},"i":0}}]}'><a href="#cite_note-foo-1" style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a></span>

While we have typeof mw:Extension/ref to indicate that this is a reference, the reference name foo is not provided at all in a machine-readable format.

I would expect it to be included, like it is when the reference is not template-generated:

Some text.<ref name="foo" />
<references>
<ref name="foo">asdf</ref>
</references>
<span about="#mwt2" class="mw-ref" id="cite_ref-foo_1-0" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"name":"foo"}}'><a href="#cite_note-foo-1" style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a></span>

…or when the reference is template-generated, but not the root element of it:

Some text.{{1x|<b><ref name="foo" /></b>}}
<references>
<ref name="foo">asdf</ref>
</references>
<b about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"&lt;b>&lt;ref name=\"foo\" />&lt;/b>"}},"i":0}}]}' id="mwAg"><span about="#mwt8" class="mw-ref" id="cite_ref-foo_1-0" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"name":"foo"}}'><a href="#cite_note-foo-1" style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a></span></b>

Event Timeline

While these examples are made up, this is a real problem affecting Template:R on Polish Wikipedia ({{r|foo|bar}} is a shortcut for <ref name="foo" /><ref name="bar" />). Example page: https://pl.wikipedia.org/wiki/Adrenalina. I was looking into adding support for editing these references in VE, but this bug makes it basically impossible.

ssastry triaged this task as Medium priority.Nov 14 2016, 2:58 AM