Marcoil has uploaded a new change for review.
https://gerrit.wikimedia.org/r/188538
Change subject: T88019: Remove unnecessary <meta> tags from inside <ref>s
......................................................................
T88019: Remove unnecessary <meta> tags from inside <ref>s
Also fix internal template expander expanding of parameters to
take into account inTemplate flag, so that this patch can be
tested.
Change-Id: I3ba6f91755627df38c73d4f28e7c17502c38a080
---
M lib/ext.Cite.js
M lib/ext.core.TemplateHandler.js
M lib/mediawiki.TokenTransformManager.js
M tests/parserTests.txt
4 files changed, 28 insertions(+), 2 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid
refs/changes/38/188538/1
diff --git a/lib/ext.Cite.js b/lib/ext.Cite.js
index 7d1c704..af73325 100644
--- a/lib/ext.Cite.js
+++ b/lib/ext.Cite.js
@@ -108,6 +108,18 @@
finalCB = function(toks, contentBody) {
// Marker meta with ref content
var da = Util.clone(refTok.dataAttribs);
+ // Strip meta tags left by template expansion
+ if (contentBody) {
+ var child = contentBody.firstChild;
+ while (child) {
+ var next = child.nextSibling;
+ if (child.nodeName === "META" &&
+
DU.isTplMetaType(child.getAttribute("typeof"))) {
+ contentBody.removeChild(child);
+ }
+ child = next;
+ }
+ }
// Clear stx='html' so that sanitizer doesn't barf
da.stx = undefined;
da.group = refOpts.group || '';
diff --git a/lib/ext.core.TemplateHandler.js b/lib/ext.core.TemplateHandler.js
index fa1d8ba..5719f5d 100644
--- a/lib/ext.core.TemplateHandler.js
+++ b/lib/ext.core.TemplateHandler.js
@@ -189,7 +189,7 @@
// XXX: would likely be faster to do this in a tight loop here
var atm = new AttributeTransformManager(
this.manager,
- { wrapTemplates: false },
+ { wrapTemplates: false, inTemplate:
true },
this._expandTemplate.bind( this, state,
frame, tgt,
accumReceiveToksFromSibling )
);
diff --git a/lib/mediawiki.TokenTransformManager.js
b/lib/mediawiki.TokenTransformManager.js
index 3808600..0a0a879 100644
--- a/lib/mediawiki.TokenTransformManager.js
+++ b/lib/mediawiki.TokenTransformManager.js
@@ -1032,6 +1032,7 @@
// transform the value
this.frame.expand( v, {
wrapTemplates:
this.options.wrapTemplates,
+ inTemplate:
this.options.inTemplate,
type: this._toType,
cb:
this._returnAttributeValue.bind( this, i )
} );
@@ -1399,7 +1400,8 @@
var pipelineOpts = {
isInclude: this.depth > 0,
- wrapTemplates: options.wrapTemplates
+ wrapTemplates: options.wrapTemplates,
+ inTemplate: options.inTemplate
};
var pipeline = this.manager.pipeFactory.getPipeline(
diff --git a/tests/parserTests.txt b/tests/parserTests.txt
index b1a1b86..37cd0a0 100644
--- a/tests/parserTests.txt
+++ b/tests/parserTests.txt
@@ -20025,6 +20025,18 @@
!! 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":"<ref>foo
{{echo|<b>bar</b>}} and {{echo|baz}} boo</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
parsoid
--
To view, visit https://gerrit.wikimedia.org/r/188538
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I3ba6f91755627df38c73d4f28e7c17502c38a080
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Marcoil <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits