Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/388680 )

Change subject: Rename stx_v data-parsoid flag to stx
......................................................................

Rename stx_v data-parsoid flag to stx

Accept both stx and stx_v for now till RESTBase storage turns over
or is refreshed. Might be worth getting this out before or during
the upcoming HTML version bump.

Step 1 of mw:Parsoid/Internals/data-parsoid#Proposal:_Maybe_move_to_data-mw.3F

Change-Id: I768041bcb02b748c4b957f3e710211f7f6c27b70
---
M lib/html2wt/DOMHandlers.js
M lib/html2wt/WTSUtils.js
M lib/html2wt/normalizeDOM.js
M lib/wt2html/pegTokenizer.pegjs
M tests/parserTests-blacklist.js
M tests/parserTests.txt
6 files changed, 29 insertions(+), 21 deletions(-)


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

diff --git a/lib/html2wt/DOMHandlers.js b/lib/html2wt/DOMHandlers.js
index 3165aa6..6085676 100644
--- a/lib/html2wt/DOMHandlers.js
+++ b/lib/html2wt/DOMHandlers.js
@@ -514,7 +514,8 @@
 
 function stxInfoValidForTableCell(state, node) {
        // If there is no syntax info, nothing to worry about
-       if (!DU.getDataParsoid(node).stx_v) {
+       var dp = DU.getDataParsoid(node);
+       if (!dp.stx && !dp.stx_v) {
                return true;
        }
 
@@ -768,7 +769,7 @@
                        var attrSepSrc = usableDP ? (dp.attrSepSrc || null) : 
null;
                        var startTagSrc = usableDP ? dp.startTagSrc : '';
                        if (!startTagSrc) {
-                               startTagSrc = (usableDP && dp.stx_v === 'row') 
? '!!' : '!';
+                               startTagSrc = (usableDP && (dp.stx_v === 'row' 
|| dp.stx === 'row')) ? '!!' : '!';
                        }
 
                        // T149209: Special case to deal with scenarios
@@ -795,7 +796,8 @@
                sepnls: {
                        before: function(node, otherNode, state) {
                                if (otherNode.nodeName === 'TH' &&
-                                               DU.getDataParsoid(node).stx_v 
=== 'row') {
+                                       (DU.getDataParsoid(node).stx === 'row' 
||
+                                        DU.getDataParsoid(node).stx_v === 
'row')) {
                                        // force single line
                                        return { min: 0, max: 
maxNLsInTable(node, otherNode) };
                                } else {
@@ -819,7 +821,7 @@
                        var attrSepSrc = usableDP ? (dp.attrSepSrc || null) : 
null;
                        var startTagSrc = usableDP ? dp.startTagSrc : '';
                        if (!startTagSrc) {
-                               startTagSrc = (usableDP && dp.stx_v === 'row') 
? '||' : '|';
+                               startTagSrc = (usableDP && (dp.stx === 'row' || 
dp.stx_v === 'row')) ? '||' : '|';
                        }
 
                        // T149209: Special case to deal with scenarios
@@ -845,7 +847,8 @@
                sepnls: {
                        before: function(node, otherNode, state) {
                                if (otherNode.nodeName === 'TD' &&
-                                               DU.getDataParsoid(node).stx_v 
=== 'row') {
+                                       (DU.getDataParsoid(node).stx === 'row' 
||
+                                        DU.getDataParsoid(node).stx_v === 
'row')) {
                                        // force single line
                                        return { min: 0, max: 
maxNLsInTable(node, otherNode) };
                                } else {
diff --git a/lib/html2wt/WTSUtils.js b/lib/html2wt/WTSUtils.js
index 0b711fa..0c68889 100644
--- a/lib/html2wt/WTSUtils.js
+++ b/lib/html2wt/WTSUtils.js
@@ -91,7 +91,10 @@
                // If it didn't have a stx_v marker that indicated that the cell
                // showed up on the same line via the "||" or "!!" syntax, 
nothing
                // to worry about.
-               return DU.getDataParsoid(node).stx_v !== 'row';
+               var dp = DU.getDataParsoid(node);
+               // Temporarily check for both stx_v and stx till
+               // the old flag expires in cache / storage.
+               return dp.stx_v !== 'row' && dp.stx !== 'row';
        } else if (node.nodeName === 'TR' && 
!DU.getDataParsoid(node).startTagSrc) {
                // If this <tr> didn't have a startTagSrc, it would have been
                // the first row of a table in original wikitext. So, it is safe
diff --git a/lib/html2wt/normalizeDOM.js b/lib/html2wt/normalizeDOM.js
index 37350ec..cd551a3 100644
--- a/lib/html2wt/normalizeDOM.js
+++ b/lib/html2wt/normalizeDOM.js
@@ -358,11 +358,13 @@
 
                // * HTML <td>s won't have escapable prefixes
                // * First cell should always be checked for escapable prefixes
-               // * Second and later cells in a wikitext td row (with 
stx_v='row' flag)
+               // * Second and later cells in a wikitext td row (with 
stx='row' flag)
                //   won't have escapable prefixes.
                if (dp.stx === 'html' ||
                        (DU.firstNonSepChildNode(node.parentNode) !== node &&
-                       dp.stx_v === 'row')) {
+                       // Temporarily check for both stx_v and stx till
+                       // the old flag expires in cache / storage.
+                       (dp.stx_v === 'row' || dp.stx === 'row'))) {
                        return node;
                }
 
diff --git a/lib/wt2html/pegTokenizer.pegjs b/lib/wt2html/pegTokenizer.pegjs
index 7ab6600..580ef15 100644
--- a/lib/wt2html/pegTokenizer.pegjs
+++ b/lib/wt2html/pegTokenizer.pegjs
@@ -1841,7 +1841,7 @@
   = ( pp:( pipe_pipe / p:pipe & row_syntax_table_args { return p; } )
       tdt:table_data_tag {
         var da = tdt[0].dataAttribs;
-        da.stx_v = "row";
+        da.stx = "row";
         da.tsr[0] -= pp.length; // include "||"
         if (pp !== "||" || (da.startTagSrc && da.startTagSrc !== pp)) {
           // Variation from default
@@ -1883,7 +1883,7 @@
     th:table_heading_tag
     ths:( pp:("!!" / pipe_pipe) tht:table_heading_tag {
             var da = tht[0].dataAttribs;
-            da.stx_v = 'row';
+            da.stx = 'row';
             da.tsr[0] -= pp.length; // include "!!" or "||"
 
             if (pp !== "!!" || (da.startTagSrc && da.startTagSrc !== pp)) {
diff --git a/tests/parserTests-blacklist.js b/tests/parserTests-blacklist.js
index 187710b..c1f5a31 100644
--- a/tests/parserTests-blacklist.js
+++ b/tests/parserTests-blacklist.js
@@ -374,7 +374,7 @@
 add("html2html", "Templates with invalid templated targets", "<p 
about=\"#mwt2\" typeof=\"mw:Transclusion\" 
data-parsoid='{\"dsr\":[0,21,0,0],\"pi\":[[]]}' 
data-mw='{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\\n{{echo|foo}}\"},\"params\":{},\"i\":0}}]}'>{{echo\nfoo}}</p>");
 add("html2html", "Template with complex arguments", "<p 
data-parsoid='{\"dsr\":[0,84,0,0]}'><a rel=\"mw:WikiLink\" 
href=\"./Wiki/Template:Complextemplate\" 
title=\"Wiki/Template:Complextemplate\" 
data-parsoid='{\"stx\":\"piped\",\"a\":{\"href\":\"./Wiki/Template:Complextemplate\"},\"sa\":{\"href\":\"wiki/Template:Complextemplate\"},\"dsr\":[0,38,32,2]}'>link</a>
 This is a test template with parameter (test)</p>\n");
 add("html2html", "T2553: link with two variables in a piped link", "<table 
data-parsoid='{\"dsr\":[0,43,2,2]}'>\n<tbody 
data-parsoid='{\"dsr\":[3,41,0,0]}'><tr 
data-parsoid='{\"autoInsertedEnd\":true,\"autoInsertedStart\":true,\"dsr\":[3,40,0,0]}'><td
 data-parsoid='{\"autoInsertedEnd\":true,\"dsr\":[3,40,1,0]}'>[[<span 
about=\"#mwt7\" typeof=\"mw:Param\" 
data-parsoid='{\"pi\":[[]],\"dsr\":[6,13,null,null]}' 
data-mw='{\"parts\":[{\"templatearg\":{\"target\":{\"wt\":\"1\"},\"params\":{},\"i\":0}}]}'>{{{1}}}</span><span
 typeof=\"mw:Nowiki\" data-parsoid='{\"dsr\":[13,31,8,9]}'>|</span><span 
about=\"#mwt8\" typeof=\"mw:Param\" 
data-parsoid='{\"pi\":[[]],\"dsr\":[31,38,null,null]}' 
data-mw='{\"parts\":[{\"templatearg\":{\"target\":{\"wt\":\"2\"},\"params\":{},\"i\":0}}]}'>{{{2}}}</span>]]</td></tr>\n</tbody></table>\n");
-add("html2html", "Abort table cell attribute parsing on wikilink", "<table 
data-parsoid='{\"dsr\":[0,151,2,2]}'>\n<tbody 
data-parsoid='{\"dsr\":[3,149,0,0]}'><tr 
data-parsoid='{\"autoInsertedEnd\":true,\"autoInsertedStart\":true,\"dsr\":[3,148,0,0]}'><td
 data-parsoid='{\"autoInsertedEnd\":true,\"dsr\":[3,50,1,0]}'> testing <a 
rel=\"mw:WikiLink\" href=\"./One\" title=\"One\" 
data-parsoid='{\"stx\":\"piped\",\"a\":{\"href\":\"./One\"},\"sa\":{\"href\":\"one\"},\"dsr\":[13,24,6,2]}'>two</a><span
 typeof=\"mw:Nowiki\" data-parsoid='{\"dsr\":[24,50,8,9]}'> | three 
</span></td><td 
data-parsoid='{\"stx_v\":\"row\",\"autoInsertedEnd\":true,\"dsr\":[50,57,2,0]}'>
 four</td>\n<td 
data-parsoid='{\"a\":{\"testing\":null,\"one\":null,\"two\":null},\"sa\":{\"testing\":\"\",\"one\":\"\",\"two\":\"\"},\"autoInsertedEnd\":true,\"dsr\":[58,84,19,0]}'>
 three </td><td 
data-parsoid='{\"stx_v\":\"row\",\"autoInsertedEnd\":true,\"dsr\":[84,91,2,0]}'>
 four</td>\n<td data-parsoid='{\"autoInsertedEnd\":true,\"dsr\":[92,141,1,0]}'> 
testing=\"<a rel=\"mw:WikiLink\" href=\"./One\" title=\"One\" 
data-parsoid='{\"stx\":\"piped\",\"a\":{\"href\":\"./One\"},\"sa\":{\"href\":\"one\"},\"dsr\":[103,114,6,2]}'>two</a><span
 typeof=\"mw:Nowiki\" data-parsoid='{\"dsr\":[114,141,8,9]}'>\" | three 
</span></td><td 
data-parsoid='{\"stx_v\":\"row\",\"autoInsertedEnd\":true,\"dsr\":[141,148,2,0]}'>
 four</td></tr>\n</tbody></table>\n");
+add("html2html", "Abort table cell attribute parsing on wikilink", "<table 
data-parsoid='{\"dsr\":[0,151,2,2]}'>\n<tbody 
data-parsoid='{\"dsr\":[3,149,0,0]}'><tr 
data-parsoid='{\"autoInsertedEnd\":true,\"autoInsertedStart\":true,\"dsr\":[3,148,0,0]}'><td
 data-parsoid='{\"autoInsertedEnd\":true,\"dsr\":[3,50,1,0]}'> testing <a 
rel=\"mw:WikiLink\" href=\"./One\" title=\"One\" 
data-parsoid='{\"stx\":\"piped\",\"a\":{\"href\":\"./One\"},\"sa\":{\"href\":\"one\"},\"dsr\":[13,24,6,2]}'>two</a><span
 typeof=\"mw:Nowiki\" data-parsoid='{\"dsr\":[24,50,8,9]}'> | three 
</span></td><td 
data-parsoid='{\"stx\":\"row\",\"autoInsertedEnd\":true,\"dsr\":[50,57,2,0]}'> 
four</td>\n<td 
data-parsoid='{\"a\":{\"testing\":null,\"one\":null,\"two\":null},\"sa\":{\"testing\":\"\",\"one\":\"\",\"two\":\"\"},\"autoInsertedEnd\":true,\"dsr\":[58,84,19,0]}'>
 three </td><td 
data-parsoid='{\"stx\":\"row\",\"autoInsertedEnd\":true,\"dsr\":[84,91,2,0]}'> 
four</td>\n<td data-parsoid='{\"autoInsertedEnd\":true,\"dsr\":[92,141,1,0]}'> 
testing=\"<a rel=\"mw:WikiLink\" href=\"./One\" title=\"One\" 
data-parsoid='{\"stx\":\"piped\",\"a\":{\"href\":\"./One\"},\"sa\":{\"href\":\"one\"},\"dsr\":[103,114,6,2]}'>two</a><span
 typeof=\"mw:Nowiki\" data-parsoid='{\"dsr\":[114,141,8,9]}'>\" | three 
</span></td><td 
data-parsoid='{\"stx\":\"row\",\"autoInsertedEnd\":true,\"dsr\":[141,148,2,0]}'>
 four</td></tr>\n</tbody></table>\n");
 add("html2html", "Template parameter as link source", "<p 
data-parsoid='{\"dsr\":[0,23,0,0]}'><a rel=\"mw:WikiLink\" 
href=\"./Wiki/Main_Page\" title=\"Wiki/Main Page\" 
data-parsoid='{\"stx\":\"piped\",\"a\":{\"href\":\"./Wiki/Main_Page\"},\"sa\":{\"href\":\"wiki/Main
 Page\"},\"dsr\":[0,23,17,2]}'>link</a></p>\n");
 add("html2html", "Template as link source", "<p 
data-parsoid='{\"dsr\":[0,28,0,0]}'><a rel=\"mw:WikiLink\" 
href=\"./Wiki/Main_Page\" title=\"Wiki/Main Page\" 
data-parsoid='{\"stx\":\"piped\",\"a\":{\"href\":\"./Wiki/Main_Page\"},\"sa\":{\"href\":\"wiki/Main
 Page\"},\"dsr\":[0,28,17,2]}'>Main Page</a></p>\n\n<p 
data-parsoid='{\"dsr\":[30,58,0,0]}'><a rel=\"mw:WikiLink\" 
href=\"./Wiki/Main_Page\" title=\"Wiki/Main Page\" 
data-parsoid='{\"stx\":\"piped\",\"a\":{\"href\":\"./Wiki/Main_Page\"},\"sa\":{\"href\":\"wiki/Main
 Page\"},\"dsr\":[30,58,17,2]}'>Main Page</a></p>\n\n<p 
data-parsoid='{\"dsr\":[60,92,0,0]}'><a rel=\"mw:WikiLink\" 
href=\"./Wiki/Main_Page\" title=\"Wiki/Main Page\" 
data-parsoid='{\"stx\":\"piped\",\"a\":{\"href\":\"./Wiki/Main_Page\"},\"sa\":{\"href\":\"wiki/Main
 Page\"},\"dsr\":[60,88,17,2]}'>Main Page</a>Page</p>\n");
 add("html2html", "Template infinite loop", "<p 
data-parsoid='{\"dsr\":[0,89,0,0]}'><span class=\"error\" 
data-parsoid='{\"stx\":\"html\",\"dsr\":[0,89,20,7]}'>Template loop detected: 
<a rel=\"mw:WikiLink\" href=\"./Wiki/Template:Loop1\" 
title=\"Wiki/Template:Loop1\" 
data-parsoid='{\"stx\":\"piped\",\"a\":{\"href\":\"./Wiki/Template:Loop1\"},\"sa\":{\"href\":\"wiki/Template:Loop1\"},\"dsr\":[44,82,22,2]}'>Template:Loop1</a></span></p>\n");
diff --git a/tests/parserTests.txt b/tests/parserTests.txt
index 42693ff..057e794 100644
--- a/tests/parserTests.txt
+++ b/tests/parserTests.txt
@@ -6350,7 +6350,7 @@
 
 !! html/parsoid
 <table>
-<tbody><tr 
data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td 
data-parsoid='{"autoInsertedEnd":true}'> Foo!! </td><td 
data-parsoid='{"stx_v":"row","autoInsertedEnd":true}'></td></tr>
+<tbody><tr 
data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td 
data-parsoid='{"autoInsertedEnd":true}'> Foo!! </td><td 
data-parsoid='{"stx":"row","autoInsertedEnd":true}'></td></tr>
 </tbody></table>
 !! end
 
@@ -6626,7 +6626,7 @@
 !! html/parsoid
 <table><tbody>
 <tr>
-<td data-parsoid='{"startTagSrc":"| 
","attrSepSrc":"|","autoInsertedEnd":true}'>[<a rel="mw:ExtLink" 
href="ftp://%7Cx"; 
data-parsoid='{"stx":"url","a":{"href":"ftp://%7Cx"},"sa":{"href":"ftp://|x"}}'>ftp://%7Cx</a></td><td
 data-parsoid='{"stx_v":"row","autoInsertedEnd":true}'>]" 
onmouseover="alert(document.cookie)">test</td></tr></tbody></table>
+<td data-parsoid='{"startTagSrc":"| 
","attrSepSrc":"|","autoInsertedEnd":true}'>[<a rel="mw:ExtLink" 
href="ftp://%7Cx"; 
data-parsoid='{"stx":"url","a":{"href":"ftp://%7Cx"},"sa":{"href":"ftp://|x"}}'>ftp://%7Cx</a></td><td
 data-parsoid='{"stx":"row","autoInsertedEnd":true}'>]" 
onmouseover="alert(document.cookie)">test</td></tr></tbody></table>
 !! end
 
 !! test
@@ -6683,7 +6683,7 @@
 
 !! html/parsoid
 <table>
-<tbody><tr><td> style="color: red !important;" data-contrived="put this here 
</td><td 
data-parsoid='{"stx_v":"row","a":{"\"":null},"sa":{"\"":""},"autoInsertedEnd":true}'>
 foo</td></tr>
+<tbody><tr><td> style="color: red !important;" data-contrived="put this here 
</td><td 
data-parsoid='{"stx":"row","a":{"\"":null},"sa":{"\"":""},"autoInsertedEnd":true}'>
 foo</td></tr>
 </tbody></table>
 !! end
 
@@ -11467,9 +11467,9 @@
 
 !! html/parsoid
 <table>
-<tbody><tr 
data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td 
data-parsoid='{"autoInsertedEnd":true}'> testing <a rel="mw:WikiLink" 
href="./One" title="One" 
data-parsoid='{"stx":"piped","a":{"href":"./One"},"sa":{"href":"one"}}'>two</a> 
| three </td><td data-parsoid='{"stx_v":"row","autoInsertedEnd":true}'> 
four</td>
-<td 
data-parsoid='{"a":{"testing":null,"one":null,"two":null},"sa":{"testing":"","one":"","two":""},"autoInsertedEnd":true}'>
 three </td><td data-parsoid='{"stx_v":"row","autoInsertedEnd":true}'> four</td>
-<td> testing="<a rel="mw:WikiLink" href="./One" title="One" 
data-parsoid='{"stx":"piped","a":{"href":"./One"},"sa":{"href":"one"}}'>two</a>"
 | three </td><td data-parsoid='{"stx_v":"row","autoInsertedEnd":true}'> 
four</td></tr>
+<tbody><tr 
data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td 
data-parsoid='{"autoInsertedEnd":true}'> testing <a rel="mw:WikiLink" 
href="./One" title="One" 
data-parsoid='{"stx":"piped","a":{"href":"./One"},"sa":{"href":"one"}}'>two</a> 
| three </td><td data-parsoid='{"stx":"row","autoInsertedEnd":true}'> four</td>
+<td 
data-parsoid='{"a":{"testing":null,"one":null,"two":null},"sa":{"testing":"","one":"","two":""},"autoInsertedEnd":true}'>
 three </td><td data-parsoid='{"stx":"row","autoInsertedEnd":true}'> four</td>
+<td> testing="<a rel="mw:WikiLink" href="./One" title="One" 
data-parsoid='{"stx":"piped","a":{"href":"./One"},"sa":{"href":"one"}}'>two</a>"
 | three </td><td data-parsoid='{"stx":"row","autoInsertedEnd":true}'> 
four</td></tr>
 </tbody></table>
 !! end
 
@@ -28182,17 +28182,17 @@
 <tbody>
 <tr><td>a
 b
-</td><td data-parsoid='{"stx_v":"row"}'>c</td></tr>
+</td><td data-parsoid='{"stx":"row"}'>c</td></tr>
 <tr><td><p>x</p>
-</td><td data-parsoid='{"stx_v":"row", "startTagSrc": 
"{{!}}{{!}}"}'>y</td></tr>
+</td><td data-parsoid='{"stx":"row", "startTagSrc": "{{!}}{{!}}"}'>y</td></tr>
 </tbody></table>
 <table>
 <tbody>
 <tr><th>a
 b
-</th><th data-parsoid='{"stx_v":"row"}'>c</th></tr>
+</th><th data-parsoid='{"stx":"row"}'>c</th></tr>
 <tr><th><p>x</h>
-</th><th data-parsoid='{"stx_v":"row"}'>y</th></tr>
+</th><th data-parsoid='{"stx":"row"}'>y</th></tr>
 </tbody></table>
 !! wikitext
 {|

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

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

Reply via email to