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

Change subject: (Bug 52405) Updated handling of sol-transparent tokens
......................................................................


(Bug 52405) Updated handling of sol-transparent tokens

* In the PHP preprocessor, category links just change page state
  and get preprocessed to an empty string and are therefore,
  transparent to further passes.  In particular, in Parsoid,
  this affects sol-transparency checks in the pre-handler.

* This makes category links sol-transparent which in turn
  fixes the pre-handler issues.  I removed custom sol-transparent
  checks in paragraph-handler, improved sol-transparency checks
  and used same checks in pre- and p-handlers.

  This also exposed buggy p-wrapping for "14. Ref." test.
  I updated the test to include a missing p-wrapper.

* Added new parsoid-only parser tests. Didn't add php tests
  since the "Category / paragraph interactions" test captures
  the empty-output behavior of the php parser.

* Tested on pl:Polietylen and pl:Darmsztadt and verified the
  absence of <pre>s

* Unrelated fix: Fixed an oversight from 6f6ac1db where I was
  meant to be testing nested ext-tags rather than just nested
  ref-tags.

Change-Id: Ifccdcfd3d01aec50f9ac8966a2cbfe7cbfc2eec9
---
M js/lib/ext.core.ParagraphWrapper.js
M js/lib/mediawiki.Util.js
M js/lib/mediawiki.WikitextSerializer.js
M js/tests/parserTests.txt
4 files changed, 38 insertions(+), 19 deletions(-)

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



diff --git a/js/lib/ext.core.ParagraphWrapper.js 
b/js/lib/ext.core.ParagraphWrapper.js
index fb92ae8..df46619 100644
--- a/js/lib/ext.core.ParagraphWrapper.js
+++ b/js/lib/ext.core.ParagraphWrapper.js
@@ -271,15 +271,7 @@
                console.warn("T:p-wrap:any: " + JSON.stringify(token));
        }
 
-       var res,
-               tc = token.constructor,
-               isNamedTagToken = function ( token, names ) {
-                       return ( token.constructor === TagTk ||
-                                       token.constructor === SelfclosingTagTk 
||
-                                       token.constructor === EndTagTk ) &&
-                                       names[token.name];
-               };
-
+       var res, tc = token.constructor;
        if (tc === TagTk && token.name === 'pre') {
                if (this.hasOpenHTMLPTag) {
                        // No pre-tokens inside html-p-tags -- replace it with 
a ' '
@@ -325,10 +317,7 @@
                        this.nlWsTokens.push(token);
                        return {};
                }
-       } else if (isNamedTagToken(token, {'link':1}) ||
-                       // TODO: narrow this down a bit more to take typeof 
into account
-                       (tc === SelfclosingTagTk && token.name === 'meta' && 
token.dataAttribs.stx !== 'html'))
-       {
+       } else if (tc !== String && Util.isSolTransparent(token)) {
                if (this.newLineCount === 0) {
                        this.currLine.tokens.push(token);
                        // Safe to push these out since we have no pending 
newlines to trip us up.
diff --git a/js/lib/mediawiki.Util.js b/js/lib/mediawiki.Util.js
index f0d5bf7..6adc9cb 100644
--- a/js/lib/mediawiki.Util.js
+++ b/js/lib/mediawiki.Util.js
@@ -259,18 +259,25 @@
                        
['table','tbody','caption','th','tr','td'].indexOf(token.name) !== -1;
        },
 
+       isSolTransparentLinkTag: function(token) {
+               var tc = token.constructor;
+               return (tc === pd.SelfclosingTagTk || tc === pd.TagTk || tc === 
pd.EndTagTk) &&
+                       token.name === 'link' &&
+                       
/mw:(WikiLink\/Category|PageProp\/redirect)/.test(token.getAttribute('rel'));
+       },
+
        isSolTransparent: function(token) {
                var tc = token.constructor;
                if (tc === String) {
-                       if (token.match(/[^\s]/)) {
-                               return false;
-                       }
+                       return token.match(/^\s*$/);
+               } else if (this.isSolTransparentLinkTag(token)) {
+                       return true;
                } else if (tc !== pd.CommentTk &&
                           (tc !== pd.SelfclosingTagTk || token.name !== 
'meta')) {
                        return false;
                }
 
-               // BUG 47854: Treat all mw:Ext/* tokens as non-SOL.
+               // BUG 47854: Treat all mw:Extension/* tokens as non-SOL.
                if (token.name === 'meta' && 
/\bmw:Extension\//.test(token.getAttribute('typeof'))) {
                        return false;
                } else {
diff --git a/js/lib/mediawiki.WikitextSerializer.js 
b/js/lib/mediawiki.WikitextSerializer.js
index c037c01..a613f12 100644
--- a/js/lib/mediawiki.WikitextSerializer.js
+++ b/js/lib/mediawiki.WikitextSerializer.js
@@ -217,7 +217,7 @@
                // Ignore non-whitelisted html tags
                if (t.isHTMLTag()) {
                        if (/\bmw:Extension\b/.test(t.getAttribute("typeof")) &&
-                               (options.extName !== 'ref' || 
t.getAttribute("name") !== 'ref'))
+                               options.extName !== t.getAttribute("name"))
                        {
                                return true;
                        }
diff --git a/js/tests/parserTests.txt b/js/tests/parserTests.txt
index e36d82e..14bd834 100644
--- a/js/tests/parserTests.txt
+++ b/js/tests/parserTests.txt
@@ -1863,6 +1863,29 @@
 </p>
 !! end
 
+!! test
+7a. Indent-pre and category links
+!! options
+parsoid=wt2html,wt2wt
+!! input
+ [[Category:foo]] <!-- No pre-wrapping -->
+{{echo| [[Category:foo]]}} <!-- No pre-wrapping -->
+!! result
+  <span typeof="mw:Transclusion"> </span> 
+!! end
+
+!! test
+7b. Indent-pre and category links
+!! options
+parsoid=wt2html,wt2wt
+!! input
+ [[Category:foo]] a
+ [[Category:foo]] {{echo|b}}
+!! result
+<pre> a <span typeof="mw:Transclusion">b</span>
+</pre>
+!! end
+
 ###
 ### HTML-pre (some to spec PHP parser behavior and some Parsoid-RT-centric)
 ###
@@ -14998,7 +15021,7 @@
 
 <references />
 !!result
-<span about="#mwt1" class="reference" 
data-mw="{&quot;name&quot;:&quot;ref&quot;,&quot;body&quot;:{&quot;html&quot;:&quot;foo
 &amp;lt;ref&amp;gt;bar&amp;lt;/ref&amp;gt; baz&quot;},&quot;attrs&quot;:{}}" 
id="cite_ref-1-0" rel="dc:references" typeof="mw:Extension/ref"><a 
href="#cite_note-1">[1]</a></span>
+<p><span about="#mwt1" class="reference" 
data-mw="{&quot;name&quot;:&quot;ref&quot;,&quot;body&quot;:{&quot;html&quot;:&quot;foo
 &amp;lt;ref&amp;gt;bar&amp;lt;/ref&amp;gt; baz&quot;},&quot;attrs&quot;:{}}" 
id="cite_ref-1-0" rel="dc:references" typeof="mw:Extension/ref"><a 
href="#cite_note-1">[1]</a></span></p>
 
 <ol class="references" typeof="mw:Extension/references" about="#mwt2" 
data-mw="{&quot;name&quot;:&quot;references&quot;,&quot;attrs&quot;:{}}">
 <li about="#cite_note-1" id="cite_note-1" data-parsoid="{}"><span 
rel="mw:referencedBy"><a href="#cite_ref-1-0">↑</a></span> foo 
&lt;ref&gt;bar&lt;/ref&gt; baz</li></ol>

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ifccdcfd3d01aec50f9ac8966a2cbfe7cbfc2eec9
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/Parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry <[email protected]>
Gerrit-Reviewer: Cscott <[email protected]>
Gerrit-Reviewer: GWicke <[email protected]>
Gerrit-Reviewer: Subramanya Sastry <[email protected]>
Gerrit-Reviewer: jenkins-bot

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

Reply via email to