Skip to content

Commit

Permalink
T88019: Remove unnecessary <meta> transclusion tags
Browse files Browse the repository at this point in the history
Change-Id: I3ba6f91755627df38c73d4f28e7c17502c38a080
  • Loading branch information
marcoil committed Feb 5, 2015
1 parent 7fce14b commit dcba403
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
6 changes: 2 additions & 4 deletions lib/dom.cleanup.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ var DU = require('./mediawiki.DOMUtils.js').DOMUtils,

// Extension/ref/Marker nodes are now processed on the final top-level dom only
// and have to be preserved all the way till that time.
//
// TODO: Use /Start for all Transclusion / Param markers!
var topLevelRE = /(?:^|\s)mw:(StartTag|EndTag|Extension\/ref\/Marker|TSRMarker)\/?[^\s]*/;
var nonTopLevelRE = /(?:^|\s)mw:(StartTag|EndTag|TSRMarker)\/?[^\s]*/;
var topLevelRE = /(?:^|\s)mw:(StartTag|EndTag|Extension\/ref\/Marker|TSRMarker|Transclusion)\/?[^\s]*/;
var nonTopLevelRE = /(?:^|\s)mw:(StartTag|EndTag|TSRMarker|Transclusion)\/?[^\s]*/;

function stripMarkerMetas(rtTestMode, node, atTopLevel) {
// Sometimes a non-tpl meta node might get the mw:Transclusion typeof
Expand Down
2 changes: 1 addition & 1 deletion tests/parserTests-blacklist.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions tests/parserTests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20052,6 +20052,18 @@ B <span about="#mwt4" class="reference" id="cite_ref-b_2-0" rel="dc:references"
<ol class="references" typeof="mw:Extension/references" about="#mwt8" data-mw='{"name":"references","body":{"extsrc":"&lt;ref name=\"b\">foo&lt;/ref>","html":"\n&lt;span about=\"#mwt10\" class=\"reference\" rel=\"dc:references\" typeof=\"mw:Extension/ref\" data-parsoid=&#39;{\"src\":\"&amp;lt;ref name=\\\"b\\\">foo&amp;lt;/ref>\",\"dsr\":[96,119,14,6]}&#39; data-mw=&#39;{\"name\":\"ref\",\"body\":{\"html\":\"foo\"},\"attrs\":{\"name\":\"b\"}}&#39;>&lt;a href=\"#cite_note-b-2\">[X 1]&lt;/a>&lt;/span>\n"},"attrs":{"group":"X"}}'><li about="#cite_note-b-2" id="cite_note-b-2"><span rel="mw:referencedBy"><a href="#cite_ref-b_2-0">↑</a></span> foo</li></ol>
!! end

!! test
References: 8. T88019: Remove <meta>s from templates inside <ref> that's itself inside a template
!! options
parsoid
!! wikitext
X{{echo|<ref>foo {{echo|<b>bar</b>}} and {{echo|baz}} boo</ref>}}
<references />
!! html
<p>X<span about="#mwt2" class="reference" id="cite_ref-1" rel="dc:references" typeof="mw:Transclusion mw:Extension/ref" 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-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 <b data-parsoid='{"stx":"html"}'>bar</b> and baz boo</li></ol>
!!end

!! test
Entities in ref name
!! options
Expand Down

0 comments on commit dcba403

Please sign in to comment.