Subramanya Sastry has uploaded a new change for review.

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

Change subject: WIP: T137406: Emit |- between thead/tbody/tfoot
......................................................................

WIP: T137406: Emit |- between thead/tbody/tfoot

* Fixed a parser test that was using buggy wikitext all this time.

TODO:
1. Do we need more tests?
2. An alternative to this fix is to strip the thead/tbody/tfoot
   in the normalization phase .. but not convinced yet that is
   a good thing.

Change-Id: I8073e5121d8856f6443a60739a7a6014a5537e9d
---
M lib/html2wt/DOMHandlers.js
M tests/parserTests.txt
2 files changed, 17 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid 
refs/changes/81/293881/1

diff --git a/lib/html2wt/DOMHandlers.js b/lib/html2wt/DOMHandlers.js
index c93ab8f..3eeb247 100644
--- a/lib/html2wt/DOMHandlers.js
+++ b/lib/html2wt/DOMHandlers.js
@@ -690,13 +690,22 @@
        tfoot: justChildren,
        tr: {
                handle: Promise.method(function(node, state, wrapperUnmodified) 
{
-                       // If the token has 'startTagSrc' set, it means that 
the tr
-                       // was present in the source wikitext and we emit it -- 
if not,
-                       // we ignore it.
                        var dp = DU.getDataParsoid(node);
-                       // ignore comments and ws
+                       var needsTrWikitext = function() {
+                               // If the token has 'startTagSrc' set, it means 
that the tr
+                               // was present in the source wikitext and we 
emit it -- if not,
+                               // we ignore it.
+                               // ignore comments and ws
+                               if (dp.startTagSrc || 
DU.previousNonSepSibling(node)) {
+                                       return true;
+                               } else {
+                                       var parentSibling = 
DU.previousNonSepSibling(node.parentNode);
+                                       return parentSibling && 
parentSibling.nodeName !== 'CAPTION';
+                               }
+                       }
+
                        var p;
-                       if (DU.previousNonSepSibling(node) || dp.startTagSrc) {
+                       if (needsTrWikitext()) {
                                p = serializeTableTag(dp.startTagSrc || "|-", 
'', state, node,
                                                
wrapperUnmodified).then(function(tableTag) {
                                        WTSUtils.emitStartTag(tableTag, node, 
state);
@@ -704,6 +713,7 @@
                        } else {
                                p = Promise.resolve();
                        }
+
                        return p.then(function() {
                                return state.serializeChildren(node);
                        });
diff --git a/tests/parserTests.txt b/tests/parserTests.txt
index d4d43b1..92ee19d 100644
--- a/tests/parserTests.txt
+++ b/tests/parserTests.txt
@@ -7117,6 +7117,7 @@
 !Month
 !Savings
 
+|-
 |January
 |$100
 
@@ -7124,6 +7125,7 @@
 |February
 |$80
 
+|-
 |Sum
 |$180
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8073e5121d8856f6443a60739a7a6014a5537e9d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/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

Reply via email to