Marcoil has uploaded a new change for review.
https://gerrit.wikimedia.org/r/188585
Change subject: Don't use data-parsoid.src to serialize magicword page
properties
......................................................................
Don't use data-parsoid.src to serialize magicword page properties
Fixes regressions introduced by stripping data-parsoid.src in
32d603d3a6b234437e8bc8a721240f179b66d629.
Change-Id: If7cbb1a3027dcf62dea446742823a1c6ddfa00a5
---
M lib/dom.cleanup.js
M lib/wts.TagHandlers.js
M tests/parserTests.txt
3 files changed, 21 insertions(+), 11 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid
refs/changes/85/188585/1
diff --git a/lib/dom.cleanup.js b/lib/dom.cleanup.js
index 29f91fd..c7647c0 100644
--- a/lib/dom.cleanup.js
+++ b/lib/dom.cleanup.js
@@ -68,11 +68,9 @@
// should reduce data-parsoid bloat.
if (validDataMW && WTSUtils.isValidDSR(dp.dsr)) {
dp.src = undefined;
- }
- // Transcluded nodes will not have dp.tsr set and dont
need dp.src either
- if
(/(?:^|\s)mw:(Transclusion|Extension)(?=$|\s)/.test(node.getAttribute("typeof"))
&&
- !dp.tsr)
- {
+ } else if
(/(?:^|\s)mw:(Transclusion|Extension)(?=$|\s)/.test(node.getAttribute("typeof"))
&&
+ !dp.tsr) {
+ // Transcluded nodes will not have dp.tsr set
and dont need dp.src either
dp.src = undefined;
}
diff --git a/lib/wts.TagHandlers.js b/lib/wts.TagHandlers.js
index 29160bd..7b5c59c 100644
--- a/lib/wts.TagHandlers.js
+++ b/lib/wts.TagHandlers.js
@@ -790,14 +790,15 @@
var out = switchType[1];
var cat =
out.match(/^(?:category)?(.*)/);
if ( cat && Util.magicMasqs.has(cat[1])
) {
- if (dp.src) {
- // Use content so that
VE modifications are preserved
- var contentInfo =
state.serializer.serializedAttrVal(node, "content", {});
- out =
dp.src.replace(/^([^:]+:)(.*)$/, "$1" + contentInfo.value + "}}");
+ var wtSource =
DU.getWTSource(state.env, node);
+ // Use content so that VE
modifications are preserved
+ var contentInfo =
state.serializer.serializedAttrVal(node, "content", {});
+ if (wtSource) {
+ out =
wtSource.replace(/^([^:]+:)(.*)$/, "$1" + contentInfo.value + "}}");
} else {
var magicWord =
cat[1].toUpperCase();
- state.env.log("error",
cat[1] + ' is missing source. Rendering as ' + magicWord + ' magicword');
- out = "{{" + magicWord
+ ":" + content + "}}";
+
state.env.log("warning", cat[1] + ' is missing source. Rendering as ' +
magicWord + ' magicword');
+ out = "{{" + magicWord
+ ":" + contentInfo.value + "}}";
}
} else {
out =
state.env.conf.wiki.getMagicWordWT( switchType[1], dp.magicSrc ) || '';
diff --git a/tests/parserTests.txt b/tests/parserTests.txt
index b1a1b86..c887c29 100644
--- a/tests/parserTests.txt
+++ b/tests/parserTests.txt
@@ -8787,6 +8787,17 @@
</p>
!! end
+# From plwiki:PLOS_ONE
+!! test
+Parsoid: Page property magic word with magic word contents
+!! options
+parsoid
+!! wikitext
+{{DISPLAYTITLE:''{{PAGENAME}}''}}
+!! html
+<meta property="mw:PageProp/displaytitle" content="Main Page" about="#mwt2"
typeof="mw:ExpandedAttrs"
data-mw='{"attribs":[[{"txt":"content"},{"html":"<i
data-parsoid=\"{&quot;dsr&quot;:[15,31,2,2]}\"><span about=\"#mwt1\"
typeof=\"mw:Transclusion\"
data-parsoid=\"{&quot;pi&quot;:[[]],&quot;dsr&quot;:[17,29,null,null]}\"
data-mw=\"{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;PAGENAME&quot;,&quot;function&quot;:&quot;pagename&quot;},&quot;params&quot;:{},&quot;i&quot;:0}}]}\">Main
Page</span></i>"}]]}'/>
+!! end
+
!! test
Namespace 1 {{ns:1}}
!! wikitext
--
To view, visit https://gerrit.wikimedia.org/r/188585
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: If7cbb1a3027dcf62dea446742823a1c6ddfa00a5
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