jenkins-bot has submitted this change and it was merged.

Change subject: Bugs 50603, 50589: Handle nested templates as well
......................................................................


Bugs 50603, 50589: Handle nested templates as well

This adds a slightly hacky work-around that enabled the TD fixup even for
nested transclusions as found on
http://en.wikipedia.org/wiki/5_O%27Clock_%28T-Pain_song%29.

We don't encapsulate nested transclusion content on the DOM, but (currently)
leave in data-parsoid.src. This patch uses that to detect the
|{{echo|{{!}}foo}} case.

In the longer term we'd like to remove data-parsoid.src for nested content. We
should think about a cleaner way to handle this, potentially by marking up
nested templates somehow.

Change-Id: Ib3cdaaf2712f7a7513af47df14a46a67d01fb407
---
M js/lib/dom.t.TDFixups.js
M js/tests/parserTests.txt
2 files changed, 23 insertions(+), 3 deletions(-)

Approvals:
  Subramanya Sastry: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/js/lib/dom.t.TDFixups.js b/js/lib/dom.t.TDFixups.js
index e5ea8ee..65fb3ad 100644
--- a/js/lib/dom.t.TDFixups.js
+++ b/js/lib/dom.t.TDFixups.js
@@ -14,9 +14,12 @@
                nextNode !== null &&
            nextNode.nodeName === 'TD' &&
            !DU.isLiteralHTMLNode(nextNode) &&
-               // FIXME: will not be set for nested templates
-               DU.isEncapsulatedElt(nextNode) &&
-           DU.nodeEssentiallyEmpty(node))
+               DU.nodeEssentiallyEmpty(node) &&
+               (// FIXME: will not be set for nested templates
+                DU.isEncapsulatedElt(nextNode) ||
+                // Hacky work-around for nested templates
+                /^{{.*?}}$/.test(nextNode.data.parsoid.src))
+           )
        {
                // Update the dsr. Since we are coalescing the first
                // node with the second (or, more precisely, deleting
diff --git a/js/tests/parserTests.txt b/js/tests/parserTests.txt
index 71bf309..7f33f47 100644
--- a/js/tests/parserTests.txt
+++ b/js/tests/parserTests.txt
@@ -7214,6 +7214,23 @@
 <tbody><td about="#mwt1" typeof="mw:Transclusion" 
data-mw='{"i":0,"parts":["|",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"{{!}}foo"}},"i":0}}]}'>foo</td></tr></tbody></table>
 !! end
 
+!! test
+Parsoid: Merge double tds in nested transclusion content (bug 50603)
+!! options
+parsoid=wt2html,wt2wt
+!! input
+{{echo|<div>}}
+{|
+|{{echo|{{!}} foo}}
+|}
+{{echo|</div>}}
+!! result
+<div typeof="mw:Transclusion">
+<table>
+<tbody><td>foo</td></tr></tbody></table>
+</div>
+!! end
+
 ###
 ### <includeonly> and <noinclude> in attributes
 ###

-- 
To view, visit https://gerrit.wikimedia.org/r/79817
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ib3cdaaf2712f7a7513af47df14a46a67d01fb407
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/Parsoid
Gerrit-Branch: master
Gerrit-Owner: GWicke <[email protected]>
Gerrit-Reviewer: Subramanya Sastry <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to