jenkins-bot has submitted this change and it was merged.
Change subject: (Bug 49405) Dont rely on dp.src while serializing
tpls/exts/params
......................................................................
(Bug 49405) Dont rely on dp.src while serializing tpls/exts/params
* Even though the serializer had the ability to serialize new
transclusions, extension uses, or params, the serializer handler
fetching code was still checking for the presence of original
source for these uses which prevented new <ref> tags from being
serialized properly.
* No change in parser test results.
Change-Id: I797b2bd87da10cd44c5eecd7b5c814777ea1a05e
---
M js/lib/mediawiki.WikitextSerializer.js
1 file changed, 41 insertions(+), 32 deletions(-)
Approvals:
GWicke: Looks good to me, approved
jenkins-bot: Verified
diff --git a/js/lib/mediawiki.WikitextSerializer.js
b/js/lib/mediawiki.WikitextSerializer.js
index 2529c2f..f8ec9a9 100644
--- a/js/lib/mediawiki.WikitextSerializer.js
+++ b/js/lib/mediawiki.WikitextSerializer.js
@@ -2640,43 +2640,52 @@
typeOf = node.getAttribute( 'typeof' ) || '';
// XXX: Convert into separate handlers?
- if ( dp.src !== undefined ) {
- //console.log(node.parentNode.outerHTML);
- if
(/\bmw:(?:Transclusion\b|Param\b|Extension\/[^\s]+)/.test(typeOf)) {
- // Source-based template/extension round-tripping for
now
- return {
- handle: function () {
- // In RT-testing mode, there will not
be any edits to tpls/extensions.
- // So, use original source to eliminate
spurious diffs showing up
- // in RT testing results.
- var src, dataMW;
- if (state.rtTesting) {
- src = dp.src;
- } else if
(/mw:Extension\//.test(typeOf)) {
- dataMW =
JSON.parse(node.getAttribute("data-mw"));
- src = !dataMW ? dp.src :
state.serializer._buildExtensionWT(state, node, dataMW);
+ if (/\bmw:(?:Transclusion\b|Param\b|Extension\/[^\s]+)/.test(typeOf)) {
+ return {
+ handle: function () {
+ // In RT-testing mode, there will not be any
edits to tpls/extensions.
+ // So, use original source to eliminate
spurious diffs showing up
+ // in RT testing results.
+ var src, dataMW;
+ if (state.rtTesting && dp.src !== undefined) {
+ src = dp.src;
+ } else if (/mw:Extension\//.test(typeOf)) {
+ dataMW =
JSON.parse(node.getAttribute("data-mw"));
+ src = !dataMW ? dp.src :
state.serializer._buildExtensionWT(state, node, dataMW);
+ } else {
+ dataMW =
JSON.parse(node.getAttribute("data-mw"));
+ if (dataMW) {
+ src =
state.serializer._buildTemplateWT(state, dataMW.parts || [{ template: dataMW
}]);
} else {
- dataMW =
JSON.parse(node.getAttribute("data-mw"));
- if (dataMW) {
- src =
state.serializer._buildTemplateWT(state, dataMW.parts || [{ template: dataMW
}]);
- } else {
- console.error("ERROR:
No data-mw for: " + node.outerHTML);
- src = dp.src;
- }
+ console.error("ERROR: No
data-mw for: " + node.outerHTML);
+ src = dp.src;
}
+ }
+
+ if (src) {
self.emitWikitext(src, state, cb, node);
return
self.skipOverEncapsulatedContent(node);
- },
- sepnls: {
- // XXX: This is questionable, as the
template can expand
- // to newlines too. Which default
should we pick for new
- // content? We don't really want to
make separator
- // newlines in HTML significant for the
semantics of the
- // template content.
- before: id({min:0, max:2})
+ } else {
+ console.error("ERROR: No handler for: "
+ node.outerHTML);
+ console.error("Serializing as HTML.");
+ return self._htmlElementHandler(node,
state);
}
- };
- } else if (typeOf === "mw:Placeholder" ||
+ },
+ sepnls: {
+ // XXX: This is questionable, as the template
can expand
+ // to newlines too. Which default should we
pick for new
+ // content? We don't really want to make
separator
+ // newlines in HTML significant for the
semantics of the
+ // template content.
+ before: id({min:0, max:2})
+ }
+ };
+ }
+
+ if ( dp.src !== undefined ) {
+ // Source-based template/extension round-tripping for now
+ //console.log(node.parentNode.outerHTML);
+ if (typeOf === "mw:Placeholder" ||
(typeOf === "mw:Nowiki" && node.textContent ===
dp.src )) {
// implement generic src round-tripping:
// return src, and drop the generated content
--
To view, visit https://gerrit.wikimedia.org/r/67888
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I797b2bd87da10cd44c5eecd7b5c814777ea1a05e
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry <[email protected]>
Gerrit-Reviewer: GWicke <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits