Subramanya Sastry has uploaded a new change for review. https://gerrit.wikimedia.org/r/58893
Change subject: Dont try to emit data-mw if tpl encapsulation fails. ...................................................................... Dont try to emit data-mw if tpl encapsulation fails. * Fixes crashers in a couple of pages. Ex: Wikipedia:Articles for deletion/Log/2007 February 14 Change-Id: I488c63d99c0cb74135cbda7b040c6fa46db6587d --- M js/lib/mediawiki.DOMPostProcessor.js 1 file changed, 23 insertions(+), 24 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Parsoid refs/changes/93/58893/1 diff --git a/js/lib/mediawiki.DOMPostProcessor.js b/js/lib/mediawiki.DOMPostProcessor.js index fe9330f..4462c43 100644 --- a/js/lib/mediawiki.DOMPostProcessor.js +++ b/js/lib/mediawiki.DOMPostProcessor.js @@ -1293,7 +1293,29 @@ } } - if (!done) { + if (done) { + var tplArray = tplArrays[range.id]; + if (tplArray) { + // Add any leading wikitext + var firstTplInfo = tplArray[0]; + if (firstTplInfo.dsr[0] > dp1.dsr[0]) { + tplArray = [{ wt: env.page.src.substring(dp1.dsr[0], firstTplInfo.dsr[0]) }].concat(tplArray); + } + + // Add any trailing wikitext + var lastTplInfo = tplArray[tplArray.length-1]; + if (lastTplInfo.dsr[1] < dp1.dsr[1]) { + tplArray.push({ wt: env.page.src.substring(lastTplInfo.dsr[1], dp1.dsr[1]) }); + } + + // Map the array of { dsr: .. , args: .. } objects to just the args property + tplArray = tplArray.map(function(a) { return a.wt ? a.wt : {template: a.args }; }); + + // Output the data-mw obj. + var datamw = (tplArray.length === 1) ? tplArray[0].template : { parts: tplArray }; + range.start.setAttribute("data-mw", JSON.stringify(datamw)); + } + } else { console.warn("ERROR: Do not have necessary info. to RT Tpl: " + i); console.warn("Start Elt : " + startElem.outerHTML); console.warn("End Elt : " + range.endElem.innerHTML); @@ -1308,29 +1330,6 @@ // a marker meta added for the template. if (DU.hasNodeName(startElem, "meta")) { deleteNode(startElem); - } - - // Add templateParams meta-tag after the endElem - var tplArray = tplArrays[range.id]; - if (tplArray) { - // Add any leading wikitext - var firstTplInfo = tplArray[0]; - if (firstTplInfo.dsr[0] > dp1.dsr[0]) { - tplArray = [{ wt: env.page.src.substring(dp1.dsr[0], firstTplInfo.dsr[0]) }].concat(tplArray); - } - - // Add any trailing wikitext - var lastTplInfo = tplArray[tplArray.length-1]; - if (lastTplInfo.dsr[1] < dp1.dsr[1]) { - tplArray.push({ wt: env.page.src.substring(lastTplInfo.dsr[1], dp1.dsr[1]) }); - } - - // Map the array of { dsr: .. , args: .. } objects to just the args property - tplArray = tplArray.map(function(a) { return a.wt ? a.wt : {template: a.args }; }); - - // Output the data-mw obj. - var datamw = (tplArray.length === 1) ? tplArray[0].template : { parts: tplArray }; - range.start.setAttribute("data-mw", JSON.stringify(datamw)); } deleteNode(range.endElem); -- To view, visit https://gerrit.wikimedia.org/r/58893 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I488c63d99c0cb74135cbda7b040c6fa46db6587d Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Parsoid Gerrit-Branch: master Gerrit-Owner: Subramanya Sastry <ssas...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits