Last modified: 2013-07-18 20:58:14 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T51555, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 49555 - Support nested <ref> tags
Support nested <ref> tags
Status: RESOLVED FIXED
Product: Parsoid
Classification: Unclassified
General (Other open bugs)
unspecified
All All
: High normal
: ---
Assigned To: ssastry
:
: 50383 (view as bug list)
Depends on:
Blocks: 49536
  Show dependency treegraph
 
Reported: 2013-06-14 00:06 UTC by James Forrester
Modified: 2013-07-18 20:58 UTC (History)
6 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description James Forrester 2013-06-14 00:06:35 UTC
It is (sadly) possible and known for users to create nested <ref> tags, using {{#tag:ref|foo<ref>bar</ref>}}.

Real-world example:

https://en.wikipedia.org/wiki/Fomitiporia_ellipsoidea

Wikitext fragment:

{{#tag:ref|These sizes are based on the original [[species description|description]] offered by Cui and Dai in 2008.<ref>Cui and Dai 2008</ref> Dai described the [[type specimen]] as "not huge", and a significantly larger specimen has since been found. Dai said that, before the discovery, he and Cui "did not know the fungus [could] grow so huge".<ref name="BBC">Walker 2011</ref>|group=note}}

Output HTML from PHP parser in <references group="note" /> block:

<li id="cite_note-12"><span class="mw-cite-backlink"><b><a href="#cite_ref-12">^</a></b></span> <span class="reference-text">These sizes are based on the original <a href="/wiki/Species_description" title="Species description">description</a> offered by Cui and Dai in 2008.<sup id="cite_ref-10" class="reference"><a href="#cite_note-10"><span>[</span>10<span>]</span></a></sup> Dai described the <a href="/wiki/Type_specimen" title="Type specimen" class="mw-redirect">type specimen</a> as "not huge", and a significantly larger specimen has since been found. Dai said that, before the discovery, he and Cui "did not know the fungus [could] grow so huge".<sup id="cite_ref-BBC_11-0" class="reference"><a href="#cite_note-BBC-11"><span>[</span>11<span>]</span></a></sup></span></li>

Output HTML from Parsoid for above:

<li about="#cite_note-1" id="cite_note-1"><span rel="mw:referencedBy"><a href="#cite_ref-1-0">↑</a></span> <span>These sizes are based on the original <a rel="mw:WikiLink" href="./Species_description" data-parsoid="{&quot;a&quot;:{&quot;href&quot;:&quot;./Species_description&quot;},&quot;sa&quot;:{&quot;href&quot;:&quot;species description&quot;},&quot;stx&quot;:&quot;piped&quot;,&quot;dsr&quot;:[56,91,22,2]}">description</a> offered by Cui and Dai in 2008.<span about="#mwt161" class="reference" data-mw="{&quot;name&quot;:&quot;ref&quot;,&quot;body&quot;:{&quot;html&quot;:&quot;Cui and Dai 2008&quot;},&quot;attrs&quot;:{}}" id="cite_ref-1-0" rel="dc:references" typeof="mw:Extension/ref" data-parsoid="{&quot;src&quot;:&quot;&lt;ref&gt;Cui and Dai 2008&quot;,&quot;dsr&quot;:[123,144,5,0]}"><a href="#cite_note-1">[1]</a></span></span></li>
Comment 1 Gerrit Notification Bot 2013-06-18 19:57:35 UTC
Related URL: https://gerrit.wikimedia.org/r/69354 (Gerrit Change I43bb8b710bd10a9ddbea27818ff8aaf97ddb3fdc)
Comment 2 Gerrit Notification Bot 2013-06-19 16:35:15 UTC
https://gerrit.wikimedia.org/r/69354 (Gerrit Change I43bb8b710bd10a9ddbea27818ff8aaf97ddb3fdc) | change APPROVED and MERGED [by jenkins-bot]
Comment 3 Gabriel Wicke 2013-06-21 02:31:20 UTC
A 90% solution was merged. This won't support nested {{#tag:ref|..<ref>..</ref>..}} structures within templates, but will support them in the content page itself. That should be the common case.

Supporting these nested refs inside of templates would be extremely complex. Fortunately that use seems to be very rare.
Comment 4 ssastry 2013-06-27 20:25:50 UTC
Nested ref tags via sfn/efn templates aren't handled correctly.

{{sfn|Vallance|1991|pp=30–31}}{{efn|Timetables of the time did not differentiate clearly between through and connecting trains.{{sfn|Vallance|1991|p=31}}}}

from page: https://en.wikipedia.org/wiki/User:Edgepedia/VE/GNoSR
Comment 5 Andre Klapper 2013-07-04 10:35:11 UTC
[Parsoid component reorg by merging JS/General and General. See bug 50685 for more information. Filter bugmail on this comment. parsoidreorg20130704]
Comment 6 ssastry 2013-07-15 02:44:16 UTC
*** Bug 50383 has been marked as a duplicate of this bug. ***
Comment 7 ssastry 2013-07-15 19:48:28 UTC
Referring to Gabriel's comment above, as it turns out, the "rare" case is not so rare after all.  [[Template:efn]] has a nested {{#tag:ref..}} in the template's body which is why we don't correctly handle it.

Since the PHP parser will not tell us where its <ref> tag came from (via a literal <ref> or a {{#tag:ref}}), we cannot use existing heuristics to support this.  Short of instrumenting the php parser or analyzing the template body and correlating parser output with it (both of which are complicated), one solution to this would be to "trust" templates, i.e. if a template is producing a nested ref-tag, "trust" the template author to know what (s)he is doing and simply accept the nested <ref> tag whereas if it showed up at the top-level, we would have rejected it as malformed.

Unless there are objections, I am going to go with this approach for now.
Comment 8 Gerrit Notification Bot 2013-07-15 22:35:36 UTC
Change 73886 had a related patch set uploaded by Subramanya Sastry:
(Bug 49555): Step #2: Support more nested ref scenarios.

https://gerrit.wikimedia.org/r/73886
Comment 9 Gerrit Notification Bot 2013-07-18 20:51:47 UTC
Change 73886 merged by jenkins-bot:
Take #2: (Bug 49555): Support all nested ref scenarios

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

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links