jenkins-bot has submitted this change and it was merged.

Change subject: Encapsulate protected table attributes from wt
......................................................................


Encapsulate protected table attributes from wt

Change-Id: I08d67aa6167d3cc2c0e315dd86afeb9d550cba94
---
M lib/wt2html/pegTokenizer.pegjs.txt
M lib/wt2html/tokenizer.utils.js
M tests/parserTests.txt
3 files changed, 22 insertions(+), 10 deletions(-)

Approvals:
  Subramanya Sastry: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/lib/wt2html/pegTokenizer.pegjs.txt 
b/lib/wt2html/pegTokenizer.pegjs.txt
index abb4ac7..22c9577 100644
--- a/lib/wt2html/pegTokenizer.pegjs.txt
+++ b/lib/wt2html/pegTokenizer.pegjs.txt
@@ -1219,14 +1219,10 @@
         v:generic_attribute_newline_value { return v; })?
 {
     var res;
-
     // Encapsulate protected attributes.
-    if (typeof name === "string") {
-        name = name.replace(
-            /^(about|data-mw.*|data-parsoid.*|data-x.*|property|rel|typeof)$/i,
-            "data-x-$1");
+    if (typeof name === 'string') {
+        name = tu.protectAttrs(name);
     }
-
     if (valueData !== null) {
         var value = valueData.value;
         res = new KV(name, value);
@@ -1249,9 +1245,11 @@
     valueData:(optionalSpaceToken
         v:table_attribute_value { return v; })?
 {
-    // FIXME: name might just be a template, which can expand to a key-value
-    // pair later. We'll need to handle that in the AttributeTransformManager.
     var res;
+    // Encapsulate protected attributes.
+    if (typeof name === 'string') {
+        name = tu.protectAttrs(name);
+    }
     if (valueData !== null) {
         var value = valueData.value;
         res = new KV(name, value);
diff --git a/lib/wt2html/tokenizer.utils.js b/lib/wt2html/tokenizer.utils.js
index 4488c9a..590cd71 100644
--- a/lib/wt2html/tokenizer.utils.js
+++ b/lib/wt2html/tokenizer.utils.js
@@ -323,6 +323,13 @@
                        }
                }
        },
+
+       protectAttrs: function(name) {
+               return name.replace(
+                       
/^(about|data-mw.*|data-parsoid.*|data-x.*|property|rel|typeof)$/i,
+                       'data-x-$1');
+       },
+
 };
 
 
diff --git a/tests/parserTests.txt b/tests/parserTests.txt
index c110444..2fabd94 100644
--- a/tests/parserTests.txt
+++ b/tests/parserTests.txt
@@ -24767,9 +24767,16 @@
 Encapsulate protected attributes from wt
 !! wikitext
 <div typeof="mw:placeholder stuff" data-mw="whoo" data-parsoid="weird" 
data-parsoid-other="no" about="time" rel="mw:true">foo</div>
+
+{| typeof="mw:placeholder stuff" data-mw="whoo" data-parsoid="weird" 
data-parsoid-other="no" about="time" rel="mw:true"
+| ok
+|}
 !! html/parsoid
-<body><div data-x-typeof="mw:placeholder stuff" data-x-data-mw="whoo" 
data-x-data-parsoid="weird" data-x-data-parsoid-other="no" data-x-about="time" 
data-x-rel="mw:true">foo</div>
-</body>
+<div data-x-typeof="mw:placeholder stuff" data-x-data-mw="whoo" 
data-x-data-parsoid="weird" data-x-data-parsoid-other="no" data-x-about="time" 
data-x-rel="mw:true">foo</div>
+
+<table data-x-typeof="mw:placeholder stuff" data-x-data-mw="whoo" 
data-x-data-parsoid="weird" data-x-data-parsoid-other="no" data-x-about="time" 
data-x-rel="mw:true">
+<tbody><tr><td data-parsoid='{"autoInsertedEnd":true}'> ok</td></tr>
+</tbody></table>
 !!end
 
 ## Currently the p-wrapper is fragile in how it adds / removes transformations.

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I08d67aa6167d3cc2c0e315dd86afeb9d550cba94
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Arlolra <abrea...@wikimedia.org>
Gerrit-Reviewer: C. Scott Ananian <canan...@wikimedia.org>
Gerrit-Reviewer: Subramanya Sastry <ssas...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to