Subramanya Sastry has uploaded a new change for review.
https://gerrit.wikimedia.org/r/231008
Change subject: Normalizer: Tweaks to <td> escapable prefix normalization
......................................................................
Normalizer: Tweaks to <td> escapable prefix normalization
* Only the first <td> in a wikitext row needs the escape.
* Added parser tests.
* This seems to be last major source of rt-diffs (from normalizations).
* Ideally, we would move this out of the normalization phase
to the core serialization phase, but that looks like a more complex
undertaking. This fix could capture the majority of scenarios
that need handling.
Change-Id: I2672a2d21ed767e2904fa7bb3d3a746f7b9006bf
---
M lib/wts.normalizeDOM.js
M tests/parserTests.txt
2 files changed, 29 insertions(+), 1 deletion(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid
refs/changes/08/231008/1
diff --git a/lib/wts.normalizeDOM.js b/lib/wts.normalizeDOM.js
index 931bd3d..0ec8894 100644
--- a/lib/wts.normalizeDOM.js
+++ b/lib/wts.normalizeDOM.js
@@ -267,8 +267,15 @@
this.moveTrailingSpacesOut(node);
return node;
- // Table cells
+ // Table cells (first cell of a <tr>)
} else if (node.nodeName === 'TD') {
+ var dp = DU.getDataParsoid(node);
+
+ if (DU.firstNonDeletedChildNode(node.parentNode) !== node &&
+ dp.stx_v === 'row') {
+ return 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..e44c7bc 100644
--- a/tests/parserTests.txt
+++ b/tests/parserTests.txt
@@ -25525,6 +25525,27 @@
|}
!! end
+!! test
+3c. Table cells without escapable prefixes after edits
+!! options
+parsoid={
+ "modes": ["selser"],
+ "scrubWikitext": true,
+ "changes": [
+ [ "td", "html", "-" ]
+ ]
+}
+!! wikitext
+{|
+|a||b
+|}
+!! wikitext/edited
+{|
+| -||-
+|}
+!! end
+
+
# ---------------------------------------------------
# End of tests spec'ing wikitext serialization norms |
# ---------------------------------------------------
--
To view, visit https://gerrit.wikimedia.org/r/231008
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I2672a2d21ed767e2904fa7bb3d3a746f7b9006bf
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