Page MenuHomePhabricator

Transclusion marker meta tags being left behind in some nested extension/transclusion scenarios
Closed, ResolvedPublic8 Estimated Story Points

Description

See the wikitext and the output below. We have stray <meta> tags left behind. Looks like VE is probably working around this, but we should not be leaving them behind.

[subbu@earth tests] echo "X{{echo|<ref>foo {{echo|<b>bar</b>}} and {{echo|baz}} boo</ref>}}\n<references />" | node parse
<!DOCTYPE html>
<html prefix="dc: http://purl.org/dc/terms/ mw: http://mediawiki.org/rdf/"><head prefix="mwr: http://en.wikipedia.org/wiki/Special:Redirect/"><meta property="mw:articleNamespace" content="0"/><meta property="mw:parsoidVersion" content="0"/><link rel="dc:isVersionOf" href="//en.wikipedia.org/wiki/Main%20Page"/><title></title><base href="//en.wikipedia.org/wiki/"/><link rel="stylesheet" href="//en.wikipedia.org/w/load.php?modules=mediawiki.legacy.commonPrint,shared|mediawiki.skinning.elements|mediawiki.skinning.content|mediawiki.skinning.interface|skins.vector.styles|site|mediawiki.skinning.content.parsoid&amp;only=styles&amp;debug=true&amp;skin=vector"/></head><body data-parsoid='{"dsr":[0,81,0,0]}' lang="en" class="mw-content-ltr sitedir-ltr ltr mw-body mw-body-content mediawiki" dir="ltr"><p data-parsoid='{"dsr":[0,65,0,0]}'>X<span about="#mwt2" class="reference" id="cite_ref-1" rel="dc:references" typeof="mw:Transclusion  mw:Extension/ref" data-parsoid='{"dsr":[1,65,null,null]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;ref>foo {{echo|&lt;b>bar&lt;/b>}} and {{echo|baz}} boo&lt;/ref>"}},"i":0}}]}'><a href="#cite_note-1">[1]</a></span></p>
<ol class="references" typeof="mw:Extension/references" about="#mwt4" data-parsoid='{"src":"&lt;references />","dsr":[66,80,2,2]}' data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><span rel="mw:referencedBy"><a href="#cite_ref-1">↑</a></span> foo <meta typeof="mw:Transclusion" about="#mwt7" data-parsoid="{}"/><b data-parsoid='{"stx":"html"}'>bar</b><meta typeof="mw:Transclusion/End" about="#mwt7" data-parsoid="{}"/> and <meta typeof="mw:Transclusion" about="#mwt8" data-parsoid="{}"/>baz<meta typeof="mw:Transclusion/End" about="#mwt8" data-parsoid="{}"/> boo</li></ol>
</body></html>

Event Timeline

ssastry raised the priority of this task from to High.
ssastry updated the task description. (Show Details)
ssastry added subscribers: Aklapper, ssastry.
gerritbot subscribed.

Change 188046 had a related patch set uploaded (by Marcoil):
WIP: T88019: Ensure templates inside <ref>s are wrapped

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

Patch-For-Review

Change 188538 had a related patch set uploaded (by Marcoil):
T88019: Remove unnecessary <meta> tags from inside <ref>s

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

Patch-For-Review

Differences between the two patches (and the interesting part of their output for "X{{echo|<ref>foo {{echo|<b>bar</b>}} and {{echo|baz}} boo</ref>}}\n<references />"):

  • The first one produces correctly wrapped templates, including their metadata, for the interior templates:
<li about="#cite_note-1" id="cite_note-1"><span rel="mw:referencedBy"><a href="#cite_ref-1">↑</a></span> foo <b about="#mwt7" typeof="mw:Transclusion" data-parsoid='{"stx":"html","dsr":[9,28,null,null],"pi":[[{"k":"1","spc":["","","",""]}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;b>bar&lt;/b>"}},"i":0}}]}'>bar</b> and <span about="#mwt8" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"1","spc":["","","",""]}]],"dsr":[33,45,null,null]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"baz"}},"i":0}}]}'>baz</span> boo</li>

It contains a different way of extracting template parameters from source: Instead of doing so using directly their srcOffsets on the whole page source (which won't work for templates inside the output of an extension like <ref>), it uses the parameter's srcOffsets relative to the template's stored src. This (or something like this) is also necessary for T73161 to work.

  • The second one just strips <meta> tags from inside the <ref>:
<li about="#cite_note-1" id="cite_note-1"><span rel="mw:referencedBy"><a href="#cite_ref-1">↑</a></span> foo <b data-parsoid='{"stx":"html"}'>bar</b> and baz boo</li>

As the <ref> contents in this case can't be directly edited in VE (the whole <ref> comes from a template, which is what will be editable), the full metadata for the interior templates isn't necessary. It will be, though, when T71870 enabled DOM editing of template parameters.

Change 188538 merged by jenkins-bot:
T88019: Remove unnecessary <meta> transclusion tags

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

Closing for now, but if/when DOM editing of transclusion parameters is enabled we may need to change to the other patch.