Subramanya Sastry has uploaded a new change for review.
https://gerrit.wikimedia.org/r/75767
Change subject: (Bug 51919) Finetuning of td nowiki escape handler
......................................................................
(Bug 51919) Finetuning of td nowiki escape handler
* Updated existing parser test with a new <td> cell
* Also verified fix by RTing nl:Ford_RS200
Change-Id: Ie5064115b9e579d2e398985597c4a0de1e3154b2
---
M js/lib/mediawiki.WikitextSerializer.js
M js/tests/parserTests.txt
2 files changed, 16 insertions(+), 3 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Parsoid
refs/changes/67/75767/1
diff --git a/js/lib/mediawiki.WikitextSerializer.js
b/js/lib/mediawiki.WikitextSerializer.js
index f78e751..7a1679a 100644
--- a/js/lib/mediawiki.WikitextSerializer.js
+++ b/js/lib/mediawiki.WikitextSerializer.js
@@ -188,9 +188,13 @@
return text.match(/\]$/);
};
-WEHP.tdHandler = function(state, text) {
- return text.match(/\|/) ||
- (state.currLine.text === '' && text.match(/^[\-+]/) &&
!state.inWideTD);
+WEHP.tdHandler = function(state, text, opts) {
+ // As long as this is not a p-wrapped text node:
+ // * | in a td should be escaped
+ // * +- in SOL position for the first node on the current line should
be escaped
+ return (!opts.node || opts.node.parentNode.nodeName !== 'P') &&
+ (text.match(/\|/) ||
+ state.currLine.text === '' && text.match(/^[\-+]/) &&
!state.inWideTD);
};
WEHP.hasWikitextTokens = function ( state, onNewline, text, linksOnly ) {
diff --git a/js/tests/parserTests.txt b/js/tests/parserTests.txt
index 3084e95..f81e3a1 100644
--- a/js/tests/parserTests.txt
+++ b/js/tests/parserTests.txt
@@ -15658,11 +15658,20 @@
|-
|''foo''-bar
|''foo''+bar
+|-
+|foo
+bar|baz
++bar
+-bar
|}
!! result
<table><tbody>
<tr><td>foo-bar</td><td>foo+bar</td></tr>
<tr><td><i>foo</i>-bar</td><td><i>foo</i>+bar</td></tr>
+<tr><td>foo
+<p>bar|baz
++bar
+-bar</p></td></tr>
</tbody></table>
!! end
--
To view, visit https://gerrit.wikimedia.org/r/75767
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie5064115b9e579d2e398985597c4a0de1e3154b2
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits