GWicke has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/54607


Change subject: Two table round-tripping bug fixes
......................................................................

Two table round-tripping bug fixes

Fixes two new wt2wt tests added in https://gerrit.wikimedia.org/r/54595.

Change-Id: I828fc511c9c648b23894c06108550f7ad7b7d070
---
M js/lib/mediawiki.WikitextSerializer.js
1 file changed, 24 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Parsoid 
refs/changes/07/54607/1

diff --git a/js/lib/mediawiki.WikitextSerializer.js 
b/js/lib/mediawiki.WikitextSerializer.js
index 63929ea..ebf0cc4 100644
--- a/js/lib/mediawiki.WikitextSerializer.js
+++ b/js/lib/mediawiki.WikitextSerializer.js
@@ -1498,8 +1498,9 @@
                        // in the source wikitext and we emit it -- if not, we 
ignore it.
                        var dp = node.data.parsoid;
                        if (node.previousSibling || dp.startTagSrc) {
-                               cb(WSP._serializeTableTag(dp.startTagSrc || 
"|-", '', state,
-                                                       DU.mkTagTk(node) ) );
+                               var res = WSP._serializeTableTag(dp.startTagSrc 
|| "|-", '', state,
+                                                       DU.mkTagTk(node) );
+                               emitStartTag(res, node, state, cb);
                        }
                        state.serializeChildren(node.childNodes, cb);
                },
@@ -1519,14 +1520,15 @@
        },
        th: {
                handle: function (node, state, cb) {
-                       var dp = node.data.parsoid;
+                       var dp = node.data.parsoid, res;
                        if ( dp.stx_v === 'row' ) {
-                               cb(WSP._serializeTableTag(dp.startTagSrc || 
"!!",
-                                                       dp.attrSepSrc || null, 
state, DU.mkTagTk(node)));
+                               res = WSP._serializeTableTag(dp.startTagSrc || 
"!!",
+                                                       dp.attrSepSrc || null, 
state, DU.mkTagTk(node));
                        } else {
-                               cb(WSP._serializeTableTag(dp.startTagSrc || 
"!", dp.attrSepSrc || null,
-                                               state, DU.mkTagTk(node)));
+                               res = WSP._serializeTableTag(dp.startTagSrc || 
"!", dp.attrSepSrc || null,
+                                               state, DU.mkTagTk(node));
                        }
+                       emitStartTag(res, node, state, cb);
                        state.serializeChildren(node.childNodes, cb, 
WSP.wteHandlers.thHandler);
                },
                sepnls: {
@@ -1558,7 +1560,7 @@
                        if(res.length > 1) {
                                state.inWideTD = true;
                        }
-                       cb(res);
+                       emitStartTag(res, node, state, cb);
                        state.resetCurrLine();
                        state.serializeChildren(node.childNodes, cb, 
WSP.wteHandlers.tdHandler);
                        // FIXME: bad state hack!
@@ -1580,7 +1582,9 @@
                handle: function (node, state, cb) {
                        var dp = node.data.parsoid;
                        // Serialize the tag itself
-                       cb(WSP._serializeTableTag(dp.startTagSrc || "|+", null, 
state, DU.mkTagTk(node)));
+                       var res = WSP._serializeTableTag(
+                                       dp.startTagSrc || "|+", null, state, 
DU.mkTagTk(node));
+                       emitStartTag(res, node, state, cb);
                        state.serializeChildren(node.childNodes, cb);
                },
                sepnls: {
@@ -1615,7 +1619,16 @@
                                                return {min: 0, max:0};
                                        }
                                } else if (otherNode === node.previousSibling &&
-                                               ((nodeName === '#text' && 
otherNode === previousNonSepSibling(node)) ||
+                                               // XXX: also check if parent 
node and first sibling
+                                               // serializes(|d) to single line
+                                               ((nodeName === '#text' &&
+                                                 otherNode === 
previousNonSepSibling(node) &&
+                                                 // FIXME HACK: Avoid forcing 
two newlines if the
+                                                 // first line is a text node 
that ends up on the
+                                                 // same line as a block
+                                                 
!(!previousNonSepSibling(otherNode) &&
+                                                         
DU.isBlockNode(node.parentNode) &&
+                                                         
!otherNode.nodeValue.match(/\n(?!$)/))) ||
                                                 nodeName === 'p')) {
                                        // Treat similar to p/p transition
 
@@ -1624,6 +1637,7 @@
                                        // needed in that case. Example:
                                        // <div>foo</div> a
                                        // b
+
                                        return {min:2, max:2};
                                } else {
                                        return {min:1, max:2};

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I828fc511c9c648b23894c06108550f7ad7b7d070
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Parsoid
Gerrit-Branch: master
Gerrit-Owner: GWicke <[email protected]>

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

Reply via email to