Arlolra has uploaded a new change for review.

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

Change subject: Move sol transparent link hoisting behind scrubWikitext
......................................................................

Move sol transparent link hoisting behind scrubWikitext

 * Now that T105239 is in production.

Change-Id: I844fe2002e70da7f5b5287a5344b8649c3af110a
---
M lib/wts.normalizeDOM.js
M tests/parserTests.txt
2 files changed, 58 insertions(+), 16 deletions(-)


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

diff --git a/lib/wts.normalizeDOM.js b/lib/wts.normalizeDOM.js
index 2976307..09d3edc 100644
--- a/lib/wts.normalizeDOM.js
+++ b/lib/wts.normalizeDOM.js
@@ -113,8 +113,8 @@
  */
 
 function normalizeNode(env, node) {
-       // Right now, only newly inserted elements are normalized
-       if (!DU.isNewElt(node)) {
+       // Only newly inserted elements are scrubbed
+       if (!env.scrubWikitext || !DU.isNewElt(node)) {
                return node;
        }
 
@@ -122,11 +122,6 @@
        if (isHeading) {
                hoistLinks(env, node, false);
                hoistLinks(env, node, true);
-       }
-
-       // This can be moved up when VE enables it.
-       if (!env.scrubWikitext) {
-               return node;
        }
 
        // Empty headings and style tags are stripped
diff --git a/tests/parserTests.txt b/tests/parserTests.txt
index b4be0eb..de9a871 100644
--- a/tests/parserTests.txt
+++ b/tests/parserTests.txt
@@ -24120,9 +24120,43 @@
 !! end
 
 !! test
-Headings: Force sol-transparent links and behavior switches to serialize 
before/after
+1. Headings: Force sol-transparent links and behavior switches to serialize 
before/after
 !! options
-parsoid=html2wt
+parsoid={
+  "modes": ["html2wt"],
+  "scrubWikitext": false
+}
+!! html
+<h2>hello there<link href="Category:A1" rel="mw:PageProp/Category" /></h2>
+<h2><link href="Category:A2" rel="mw:PageProp/Category" />hi pal</h2>
+
+<h2><!--foo-->  <link href="Category:A3" rel="mw:PageProp/Category" />   how 
goes it</h2>
+<h2>it goes well   <link href="Category:A4" rel="mw:PageProp/Category" />  
<!--bar--></h2>
+
+<h2 data-parsoid='{}'>howdy<link href="Category:A5" rel="mw:PageProp/Category" 
/></h2>
+
+<h2><meta property="mw:PageProp/toc" /> ok</h2>
+!! wikitext
+== hello there [[Category:A1]]  ==
+
+==  [[Category:A2]] hi pal ==
+
+== <!--foo-->   [[Category:A3]]    how goes it ==
+
+== it goes well    [[Category:A4]]  <!--bar-->  ==
+
+==howdy [[Category:A5]] ==
+
+==  __TOC__  ok ==
+!! end
+
+!! test
+2. Headings: Force sol-transparent links and behavior switches to serialize 
before/after
+!! options
+parsoid={
+  "modes": ["html2wt"],
+  "scrubWikitext": true
+}
 !! html
 <h2>hello there<link href="Category:A1" rel="mw:PageProp/Category" /></h2>
 <h2><link href="Category:A2" rel="mw:PageProp/Category" />hi pal</h2>
@@ -24157,7 +24191,10 @@
 !! test
 Headings: Don't hoist metas that come from templates
 !! options
-parsoid=html2wt
+parsoid={
+  "modes": ["html2wt"],
+  "scrubWikitext": true
+}
 !! html
 <h2><span about="#mwt1" typeof="mw:Transclusion" data-parsoid="{}" 
data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo
 [[Category:Foo]]"}},"i":0}}]}'>foo </span><link rel="mw:PageProp/Category" 
href="./Category:Foo" about="#mwt1" data-parsoid="{}" /></h2>
 !! wikitext
@@ -24167,7 +24204,10 @@
 !! test
 Headings: Category in ref isn't hoisted
 !! options
-parsoid=html2wt
+parsoid={
+  "modes": ["html2wt"],
+  "scrubWikitext": true
+}
 !! html
 <h2> foo <span about="#mwt2" class="reference" id="cite_ref-1" 
rel="dc:references" typeof="mw:Extension/ref" 
data-mw='{"name":"ref","body":{"id":"mw-reference-text-cite_note-1"},"attrs":{}}'><a
 href="#cite_note-1">[1]</a></span> </h2>
 
@@ -24797,7 +24837,7 @@
 !! end
 
 !! test
-Headings: Add space before/after == (T53744)
+1. Headings: Add space before/after == (T53744)
 !! options
 parsoid=html2wt
 !! html
@@ -24805,9 +24845,6 @@
 <h2> bar</h2>
 <h2>baz </h2>
 <h2><span> baz</span></h2>
-
-<!-- Even after hoisted content -->
-<h2> <link href="Category:A2" rel="mw:PageProp/Category" />ok</h2>
 !! wikitext
 == foo ==
 
@@ -24816,8 +24853,18 @@
 == baz ==
 
 == <span> baz</span> ==
+!! end
 
-<!-- Even after hoisted content -->
+!! test
+2. Headings: Add space before/after == even after hoisted content
+!! options
+parsoid={
+  "modes": ["html2wt"],
+  "scrubWikitext": true
+}
+!! html
+<h2> <link href="Category:A2" rel="mw:PageProp/Category" />ok</h2>
+!! wikitext
  [[Category:A2]]
 
 == ok ==

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

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

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

Reply via email to