Subramanya Sastry has uploaded a new change for review.
https://gerrit.wikimedia.org/r/77245
Change subject: WIP: (Bug 52405) Make category links sol-transparent
......................................................................
WIP: (Bug 52405) Make category links sol-transparent
* 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.
* Added new parser tests.
- The new tests fail wt2html mode because the normalization
is not able to strip out all insignificant whitespace and
mw:Transclusion markers. For now, blacklisting the test,
but worth investigating normalization.
- 3 selser paragraph/category links interaction tests are
now failing because of the change. To be investigated.
Hence WIP.
* Tested on pl:Polietylen and pl:Darmsztadt and verified the
absence of <pre>s
Change-Id: Ifccdcfd3d01aec50f9ac8966a2cbfe7cbfc2eec9
---
M js/lib/mediawiki.Util.js
M js/tests/parserTests-blacklist.js
M js/tests/parserTests.txt
3 files changed, 35 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Parsoid
refs/changes/45/77245/1
diff --git a/js/lib/mediawiki.Util.js b/js/lib/mediawiki.Util.js
index f0d5bf7..cb55375 100644
--- a/js/lib/mediawiki.Util.js
+++ b/js/lib/mediawiki.Util.js
@@ -259,12 +259,20 @@
['table','tbody','caption','th','tr','td'].indexOf(token.name) !== -1;
},
+ isCategoryLinkTag: function(token) {
+ return token.constructor === pd.SelfclosingTagTk &&
+ token.name === 'link' &&
+ token.getAttribute('rel') === 'mw:WikiLink/Category';
+ },
+
isSolTransparent: function(token) {
var tc = token.constructor;
if (tc === String) {
if (token.match(/[^\s]/)) {
return false;
}
+ } else if (this.isCategoryLinkTag(token)) {
+ return true;
} else if (tc !== pd.CommentTk &&
(tc !== pd.SelfclosingTagTk || token.name !==
'meta')) {
return false;
diff --git a/js/tests/parserTests-blacklist.js
b/js/tests/parserTests-blacklist.js
index 34cd0ef..7f0e39c 100644
--- a/js/tests/parserTests-blacklist.js
+++ b/js/tests/parserTests-blacklist.js
@@ -55,6 +55,8 @@
add("wt2html", "2c. Indent-Pre and tables (bug 42252)");
add("wt2html", "4. Multiple spaces at start-of-line");
add("wt2html", "5. White-space in indent-pre\nNOTE: the white-space char on
2nd line is significant");
+add("wt2html", "6a. Indent-pre and category links");
+add("wt2html", "6b. Indent-pre and category links");
add("wt2html", "Definition Lists: Nesting: Multi-level (Parsoid only)");
add("wt2html", "Definition Lists: Nesting: Test 2 (Parsoid only)");
add("wt2html", "Definition Lists: Nesting: Test 3 (Parsoid only)");
@@ -3164,6 +3166,9 @@
add("selser", "BUG 561: {{/Subpage}} [[3]]");
add("selser", "BUG 561: {{/Subpage}} [[4]]");
add("selser", "BUG 561: {{/Subpage}} [[2]]");
+add("selser", "Category / paragraph interactions
[3,2,1,3,0,4,1,2,1,2,0,2,0,0,0,0,0,4,0,0,0,0,0,3]");
+add("selser", "Category / paragraph interactions
[[2,3,3],2,4,2,1,3,[2],0,0,2,2,2,4,3,0,0,4,2,4,3,3,0,0,1]");
+add("selser", "Category / paragraph interactions
[[4,0,0],3,3,2,[3,3,0],4,3,4,2,2,0,2,0,0,0,0,0,0,0,1,3,0,0,3]");
add("selser", "Handling of sections up to level 6 and beyond
[1,2,1,2,1,0,[3],2,2,4,[2],4,0,0,1,0,0,3,1]");
add("selser", "Handling of sections up to level 6 and beyond
[[2],0,3,3,4,4,4,3,0,2,1,0,4,2,[3],0,[3],4,4]");
add("selser", "Handling of sections up to level 6 and beyond
[1,0,1,0,0,3,2,3,0,0,4,0,[4],0,1,0,0,4,0]");
diff --git a/js/tests/parserTests.txt b/js/tests/parserTests.txt
index 76388d9..830bf66 100644
--- a/js/tests/parserTests.txt
+++ b/js/tests/parserTests.txt
@@ -1826,6 +1826,28 @@
</pre>
!! end
+!! test
+6a. Indent-pre and category links
+!! options
+parsoid=wt2html,wt2wt
+!! input
+ [[Category:foo]] <!-- No pre-wrapping -->
+{{echo| [[Category:foo]]}} <!-- No pre-wrapping -->
+!! result
+!! end
+
+!! test
+6b. Indent-pre and category links
+!! options
+parsoid=wt2html,wt2wt
+!! input
+ [[Category:foo]] a
+ [[Category:foo]] {{echo|b}}
+!! result
+<pre>a b
+</pre>
+!! end
+
###
### HTML-pre (some to spec PHP parser behavior and some Parsoid-RT-centric)
###
--
To view, visit https://gerrit.wikimedia.org/r/77245
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifccdcfd3d01aec50f9ac8966a2cbfe7cbfc2eec9
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