Cscott has uploaded a new change for review.

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

Change subject: T88318: Fix regression in <nowiki> behavior with nested - in 
<td>.
......................................................................

T88318: Fix regression in <nowiki> behavior with nested - in <td>.

Ensure we only emit <nowiki> if the `-` or `+` is the first thing in
its node and *all of its parents* are zero-width tags (emit no wikitext).
This ensures that the `-` or `+` is actually at start-of-line position.

Change-Id: Idc10a43b4569c115be997ef2b9d265128d056ebf
---
M lib/wts.escapeWikitext.js
M tests/parserTests.txt
2 files changed, 23 insertions(+), 3 deletions(-)


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

diff --git a/lib/wts.escapeWikitext.js b/lib/wts.escapeWikitext.js
index a71ac26..e6e52d7 100644
--- a/lib/wts.escapeWikitext.js
+++ b/lib/wts.escapeWikitext.js
@@ -193,9 +193,13 @@
                        state.currLine.text === '' &&
                        // Has to be the first content node in the <td>.
                        // In <td><a ..>..</a>-foo</td>, even though "-foo" 
meets the other conditions,
-                       // we don't need to escape it.
-                       this.isFirstContentNode(opts.node) &&
-                       text.match(/^[\-+]/)
+                       // we don't need to escape it.  We also don't need to 
escape <td><small>-</small></td>;
+                       // make sure every node on the path is the first child 
of its parent & is zero-width.
+                       text.match(/^[\-+]/) &&
+                       opts.node && DU.pathToAncestor(opts.node, 
tdNode).every(function(n) {
+                               return this.isFirstContentNode(n) &&
+                                       (n===opts.node || 
DU.isZeroWidthWikitextElt(n));
+                       }, this)
                ));
 };
 
diff --git a/tests/parserTests.txt b/tests/parserTests.txt
index 486a64b..098fbac 100644
--- a/tests/parserTests.txt
+++ b/tests/parserTests.txt
@@ -23567,6 +23567,7 @@
 <table><tbody>
 <tr><th><p>-</p></th><th><p>- </p></th></tr>
 <tr><td><p>-</p></td><td><p>- </p></td></tr>
+<tr><td><small>-</small></td><td><br/><p>-</p></td><td><br/>-</td></tr>
 </tbody></table>
 !! wikitext
 {|
@@ -23575,6 +23576,12 @@
 |-
 |<nowiki>-</nowiki>
 |<nowiki>- </nowiki>
+|-
+|<small>-</small>
+|<br>
+-
+|<br>
+-
 |}
 !! html/php+tidy
 <table>
@@ -23586,6 +23593,15 @@
 <td>-</td>
 <td>-</td>
 </tr>
+<tr>
+<td><small>-</small></td>
+<td><br />
+<p>-</p>
+</td>
+<td><br />
+<p>-</p>
+</td>
+</tr>
 </table>
 !! end
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Idc10a43b4569c115be997ef2b9d265128d056ebf
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Cscott <[email protected]>

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

Reply via email to