Subramanya Sastry has uploaded a new change for review.
https://gerrit.wikimedia.org/r/230969
Change subject: Normalizer: Bug fix in <td> escapable prefix normalization
......................................................................
Normalizer: Bug fix in <td> escapable prefix normalization
* Only the first <td> needs the escape.
* Added a parser test.
* This seems to be last source of rt-diffs (from the normalizations).
* There is still the known failing test:
"3b. Table cells without escapable prefixes after edits"
Counting # of attributes in a <td> after eliminating data-parsoid
and data-parsoid-diff and seeing if there are any left is one
way of detecting this.
Change-Id: I71ad8f48297ca0d767f49744b7a590bf17daee1a
---
M lib/wts.normalizeDOM.js
M tests/parserTests.txt
2 files changed, 26 insertions(+), 2 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid
refs/changes/69/230969/1
diff --git a/lib/wts.normalizeDOM.js b/lib/wts.normalizeDOM.js
index 931bd3d..2f5b2a5 100644
--- a/lib/wts.normalizeDOM.js
+++ b/lib/wts.normalizeDOM.js
@@ -267,8 +267,10 @@
this.moveTrailingSpacesOut(node);
return node;
- // Table cells
- } else if (node.nodeName === 'TD') {
+ // Table cells (first cell of a <tr>)
+ } else if (node.nodeName === 'TD' &&
+ DU.firstNonDeletedChildNode(node.parentNode) === node) {
+
var first = DU.firstNonDeletedChildNode(node);
// Emit a space before escapable prefix
// This is preferable to serializing with a nowiki.
diff --git a/tests/parserTests.txt b/tests/parserTests.txt
index df5f5cd..9183e5e 100644
--- a/tests/parserTests.txt
+++ b/tests/parserTests.txt
@@ -25525,6 +25525,28 @@
|}
!! end
+!! test
+3c. Table cells without escapable prefixes after edits
+!! options
+parsoid={
+ "modes": ["selser"],
+ "scrubWikitext": true,
+ "changes": [
+ [ "table tbody tr:first-child td:first-child", "html", "x" ],
+ [ "td", "html", "-" ]
+ ]
+}
+!! wikitext
+{|
+|a||b
+|}
+!! wikitext/edited
+{|
+| -||-
+|}
+!! end
+
+
# ---------------------------------------------------
# End of tests spec'ing wikitext serialization norms |
# ---------------------------------------------------
--
To view, visit https://gerrit.wikimedia.org/r/230969
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I71ad8f48297ca0d767f49744b7a590bf17daee1a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits