Subramanya Sastry has uploaded a new change for review.

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


Change subject: Tweaks to <p> and <li> sep constraints when surrounded by HTML 
nodes
......................................................................

Tweaks to <p> and <li> sep constraints when surrounded by HTML nodes

* With HTML like "<p>a</p>\n<p stx:html>b</p>", we dont need two
  newlines between "a" and "<p>b</p>" on serialization.
  "a\n<p>b</p>" is acceptable.

* Similarly for <li> nodes.

* This reduces selser failures in the big separator handling patch
  that continues to still be WIP.

Change-Id: Iff239e616608c28dcb7eefc7d1c4a227a07b6203
---
M js/lib/mediawiki.WikitextSerializer.js
M js/tests/parserTests-blacklist.js
2 files changed, 13 insertions(+), 11 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Parsoid 
refs/changes/48/99448/1

diff --git a/js/lib/mediawiki.WikitextSerializer.js 
b/js/lib/mediawiki.WikitextSerializer.js
index 8e3c33c..b6decce 100644
--- a/js/lib/mediawiki.WikitextSerializer.js
+++ b/js/lib/mediawiki.WikitextSerializer.js
@@ -2319,7 +2319,9 @@
                } else {
                        return {min:1, max:2};
                }
-       } else if (DU.isList(otherNode)) {
+       } else if (DU.isList(otherNode) ||
+                       (DU.isElt(otherNode) && otherNode.data.parsoid.stx === 
'html'))
+       {
                // last child in ul/ol (the list element is our parent), defer
                // separator constraints to the list.
                return {};
@@ -2406,8 +2408,8 @@
                },
                sepnls: {
                        before: function (node, otherNode) {
-                               if (otherNode === node.parentNode &&
-                                               otherNode.nodeName in {UL:1, 
OL:1})
+                               if ((otherNode === node.parentNode && 
otherNode.nodeName in {UL:1, OL:1}) ||
+                                       (DU.isElt(otherNode) && 
otherNode.data.parsoid.stx === 'html'))
                                {
                                        return {}; //{min:0, max:1};
                                } else {
@@ -2651,7 +2653,7 @@
                                } else if (
                                        otherNode === node.previousSibling &&
                                        // p-p transition
-                                       otherNodeName === 'P' ||
+                                       (otherNodeName === 'P' && 
otherNode.data.parsoid.stx !== 'html') ||
                                        // Treat text/p similar to p/p 
transition
                                        (
                                                DU.isText(otherNode) &&
@@ -2666,7 +2668,7 @@
                        },
                        after: function(node, otherNode) {
                                if (!(node.lastChild && node.lastChild.nodeName 
=== 'BR') &&
-                                       otherNode.nodeName === 'P') /* || 
otherNode.nodeType === node.TEXT_NODE*/
+                                       otherNode.nodeName === 'P' && 
otherNode.data.parsoid.stx !== 'html') /* || otherNode.nodeType === 
node.TEXT_NODE*/
                                {
                                        return {min: 2, max: 2};
                                } else {
diff --git a/js/tests/parserTests-blacklist.js 
b/js/tests/parserTests-blacklist.js
index abaa641..075408a 100644
--- a/js/tests/parserTests-blacklist.js
+++ b/js/tests/parserTests-blacklist.js
@@ -2832,15 +2832,15 @@
 add("selser", "Test the li-hack\n(Cannot test this with PHP parser since it 
relies on Tidy for the hack) [[4,2,[3],0,0,0,[4,2,3],3],0,2]", "* 
3snwnj5c00nhr529\n* mfkpew81wvrvygb9\n* <li></li>\n* {{echo|<li>templated 
li-hack}}\n*kbtd2envs0rg4x6rrdmeyz7tc016pqfr<!--foo-->\n\nvygyuzctg43zyqfr<ul>\n<li><li>not
 a li-hack\n</li>\n</ul>");
 add("selser", "Test the li-hack\n(Cannot test this with PHP parser since it 
relies on Tidy for the hack) [[3,0,0,0,0,0,[2,0,0],0],0,[0,0,1,0]]", "\n* 
<li>li-hack\n* {{echo|<li>templated li-hack}}\n*9irufodzdrt3xr <!--foo--> <li> 
unsupported li-hack with preceding comments\n\n<ul>\n<li><li 
data-foobar=\"apbhpw1eacpfzuxr\">not a li-hack\n</li>\n</ul>");
 add("selser", "Test the li-hack\n(Cannot test this with PHP parser since it 
relies on Tidy for the hack) [[4,3,2,0,0,0,3,4],4,2]", "* heew4bmxhynl8fr\n* 
jxmnsyhftuik9* <li>li-hack\n* {{echo|<li>templated li-hack}}\n* 
ut2i94jm55sfko6rx0q9zelof75y7gb9u5hls1u63x72e29<ul>\n<li><li>not a 
li-hack\n</li>\n</ul>");
-add("selser", "Test the li-hack\n(Cannot test this with PHP parser since it 
relies on Tidy for the hack) [[0,2,0,2,0,0,4,4],0,[2,0,0,0]]", "* foo\n* 
e9pz8g9s5urkvs4i\n* <li>li-hack\n* 88uxy4iag0v8to6r\n* {{echo|<li>templated 
li-hack}}\n* 7liw9g5hwshpk3xr\n* 
3c6cjbi2xoagu8fr\n\n<ul><li>85y3plf128hhncdi</li>\n<li><li>not a 
li-hack\n</li>\n</ul>");
-add("selser", "Test the li-hack\n(Cannot test this with PHP parser since it 
relies on Tidy for the hack) [[0,4,[4],4,0,0,4,1],2,1]", "* foo\n* 
06p0h25k869zr529* <li>ck3o9hquxu7bvs4i</li>\n* av6idg5yinyu8fr* 
{{echo|<li>templated li-hack}}\n* vpxn77vta2359udi<li 
data-foobar=\"36vyqhh4blp1ra4i\"> unsupported li-hack with preceding 
comments</li>6t739sww9i9t3xr\n\n<ul 
data-foobar=\"vipn4uvetdquxr\">\n<li><li>not a li-hack\n</li>\n</ul>");
-add("selser", "Test the li-hack\n(Cannot test this with PHP parser since it 
relies on Tidy for the hack) [[2,0,1,2,0,4,4,[2]],0,[2,1,3,4]]", "* 
4fcfg01itfbt9\n* foo\n* <li data-foobar=\"0z6ozqqgcuhj8aor\">li-hack</li>\n* 
j7zcorwdpqcwhfr\n* {{echo|<li>templated li-hack}}\n* bokpqklqw8doyldi\n* 
9w0icw4mbv4mquxr<li>wknfoz3exkhs38fr unsupported li-hack with preceding 
comments</li>\n\n<ul><li>n98t8h34r5m6lxr</li>\n<li 
data-foobar=\"0oq8zfsydnobhuxr\"><li>pdivy8meuxt4vx6r</li></ul>");
-add("selser", "Test the li-hack\n(Cannot test this with PHP parser since it 
relies on Tidy for the hack) [[4,0,2,4,0,2,3,3],4,4]", "* c3l5ffzv0jwwb3xr\n* 
p6p7595foquayvi* <li>li-hack\n* wy3enk6r0pmn29* {{echo|<li>templated 
li-hack}}\n* yxtwd1qrc4xqolxr\n9ua2ar70knle4s4inkt86ylgawwb3xr");
-add("selser", "Test the li-hack\n(Cannot test this with PHP parser since it 
relies on Tidy for the hack) [[1,3,[4],2,0,4,[0,0,4],0],4,1]", "* foo\n* 
<li>ry12r5fojmt8d7vi</li>\n* yksxp7g11dvg3nmi\n* {{echo|<li>templated 
li-hack}}\n* 3c5qjoexwrvn29\n* <!--foo-->r8ffzehvrnewmi<li> unsupported li-hack 
with preceding commentsg87527axiqf47vi<ul 
data-foobar=\"hq405qjopr5dn29\">\n<li><li>not a li-hack\n</li>\n</ul>");
+add("selser", "Test the li-hack\n(Cannot test this with PHP parser since it 
relies on Tidy for the hack) [[0,2,0,2,0,0,4,4],0,[2,0,0,0]]", "* foo\n* 
e9pz8g9s5urkvs4i\n* <li>li-hack* 88uxy4iag0v8to6r\n* {{echo|<li>templated 
li-hack}}\n* 7liw9g5hwshpk3xr\n* 
3c6cjbi2xoagu8fr\n\n<ul><li>85y3plf128hhncdi</li>\n<li><li>not a 
li-hack\n</li>\n</ul>");
+add("selser", "Test the li-hack\n(Cannot test this with PHP parser since it 
relies on Tidy for the hack) [[0,4,[4],4,0,0,4,1],2,1]", "* foo\n* 
06p0h25k869zr529* <li>ck3o9hquxu7bvs4i</li>* av6idg5yinyu8fr* 
{{echo|<li>templated li-hack}}\n* vpxn77vta2359udi<li 
data-foobar=\"36vyqhh4blp1ra4i\"> unsupported li-hack with preceding 
comments</li>6t739sww9i9t3xr\n\n<ul 
data-foobar=\"vipn4uvetdquxr\">\n<li><li>not a li-hack\n</li>\n</ul>");
+add("selser", "Test the li-hack\n(Cannot test this with PHP parser since it 
relies on Tidy for the hack) [[2,0,1,2,0,4,4,[2]],0,[2,1,3,4]]", "* 
4fcfg01itfbt9\n* foo\n* <li data-foobar=\"0z6ozqqgcuhj8aor\">li-hack</li>* 
j7zcorwdpqcwhfr\n* {{echo|<li>templated li-hack}}* bokpqklqw8doyldi\n* 
9w0icw4mbv4mquxr<li>wknfoz3exkhs38fr unsupported li-hack with preceding 
comments</li>\n\n<ul><li>n98t8h34r5m6lxr</li>\n<li 
data-foobar=\"0oq8zfsydnobhuxr\"><li>pdivy8meuxt4vx6r</li></ul>");
+add("selser", "Test the li-hack\n(Cannot test this with PHP parser since it 
relies on Tidy for the hack) [[4,0,2,4,0,2,3,3],4,4]", "* c3l5ffzv0jwwb3xr\n* 
p6p7595foquayvi* <li>li-hack* wy3enk6r0pmn29* {{echo|<li>templated li-hack}}* 
yxtwd1qrc4xqolxr\n9ua2ar70knle4s4inkt86ylgawwb3xr");
+add("selser", "Test the li-hack\n(Cannot test this with PHP parser since it 
relies on Tidy for the hack) [[1,3,[4],2,0,4,[0,0,4],0],4,1]", "* foo\n* 
<li>ry12r5fojmt8d7vi</li>* yksxp7g11dvg3nmi\n* {{echo|<li>templated li-hack}}* 
3c5qjoexwrvn29\n* <!--foo-->r8ffzehvrnewmi<li> unsupported li-hack with 
preceding commentsg87527axiqf47vi<ul 
data-foobar=\"hq405qjopr5dn29\">\n<li><li>not a li-hack\n</li>\n</ul>");
 add("selser", "Test the li-hack\n(Cannot test this with PHP parser since it 
relies on Tidy for the hack) [[1,0,[4],0,0,0,1,2],0,0]", "* foo\n* 
<li>pm72fwa3theka9k9</li>\n* {{echo|<li>templated li-hack}}\n* <!--foo--> \n* 
3tj3q66km52ep14i<li> unsupported li-hack with preceding 
comments\n\n<ul>\n<li><li>not a li-hack\n</li>\n</ul>");
 add("selser", "Test the li-hack\n(Cannot test this with PHP parser since it 
relies on Tidy for the hack) [1,0,3]", "* foo\n* <li>li-hack\n* 
{{echo|<li>templated li-hack}}\n* <!--foo--> <li> unsupported li-hack with 
preceding comments\n");
 add("selser", "Test the li-hack\n(Cannot test this with PHP parser since it 
relies on Tidy for the hack) [[[4],3,1,0,0,0,[2,2,4],0],4,3]", 
"*cn76ap9tripgy14i\n* <li data-foobar=\"oracqmygc1tyy14i\">li-hack</li>\n* 
{{echo|<li>templated li-hack}}\n*hn5qq2d950nc23xr 
so80nmz3ozz7iudi<!--foo-->zla2a4bxr4zehfr<li> unsupported li-hack with 
preceding commentszlauq3hv36f4unmi");
-add("selser", "Test the li-hack\n(Cannot test this with PHP parser since it 
relies on Tidy for the hack) [[3,4,4,0,0,4,[2,4,4],0],0,3]", "* 
fxkmu1c9q5omvx6r\n* y6x6k3okfdlblnmi\n* {{echo|<li>templated li-hack}}\n* 
rnkwtsd7b4deu3di\n*mtpmswpvciz77gb9 xur0tfk2l2mg3nmiw03ly5i7pc26s9k9<li> 
unsupported li-hack with preceding comments\n");
+add("selser", "Test the li-hack\n(Cannot test this with PHP parser since it 
relies on Tidy for the hack) [[3,4,4,0,0,4,[2,4,4],0],0,3]", "* 
fxkmu1c9q5omvx6r\n* y6x6k3okfdlblnmi\n* {{echo|<li>templated li-hack}}* 
rnkwtsd7b4deu3di\n*mtpmswpvciz77gb9 xur0tfk2l2mg3nmiw03ly5i7pc26s9k9<li> 
unsupported li-hack with preceding comments\n");
 add("selser", "Test the li-hack\n(Cannot test this with PHP parser since it 
relies on Tidy for the hack) [2,0,2]", "v63uarsscvo8yqfr\n* foo\n* 
<li>li-hack\n* {{echo|<li>templated li-hack}}\n* <!--foo--> <li> unsupported 
li-hack with preceding comments\n\nfl0wa30cmdndn29<ul>\n<li><li>not a 
li-hack\n</li>\n</ul>");
 add("selser", "Test the li-hack\n(Cannot test this with PHP parser since it 
relies on Tidy for the hack) [2,2,1]", "phdtjgrh0wvwvcxr\n* foo\n* 
<li>li-hack\n* {{echo|<li>templated li-hack}}\n* <!--foo--> <li> unsupported 
li-hack with preceding commentse3qh364hiowasjor\n\n<ul 
data-foobar=\"q20dntdz62p22o6r\">\n<li><li>not a li-hack\n</li>\n</ul>");
 add("selser", "Test the li-hack\n(Cannot test this with PHP parser since it 
relies on Tidy for the hack) [[[3],3,1,0,0,3,[2,0,0],4],0,[3,0,1,2]]", "*\n* 
<li data-foobar=\"49afghrf0njw0zfr\">li-hack</li>\n* {{echo|<li>templated 
li-hack}}\n*12sgn2zg2no8ncdi <!--foo--> \n* ayqvyg3gs800be29\n\n<ul>\n<li><li 
data-foobar=\"5ybbamd7x0gm0a4i\">not a 
li-hack\n</li><li>wxxylvwx7t9jxlxr</li>\n</ul>");

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iff239e616608c28dcb7eefc7d1c4a227a07b6203
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

Reply via email to