jenkins-bot has submitted this change and it was merged.
Change subject: Add new redirect tests; fix an html2html bug with non-English
redirects.
......................................................................
Add new redirect tests; fix an html2html bug with non-English redirects.
I wrote these for change I1bd36f32a5e46b90261895e5499a0308875e5e05 but they
got lost in a forgotten branch of my repo.
The html2wt tests all appear to fail because we re-serialize the #redirect
link as [[./Main Page]] instead of [[Main Page]].
Change-Id: I997cae79216d31559fb0a3abe555a26cc41acea0
---
M js/lib/mediawiki.WikitextSerializer.js
M js/tests/parserTests-blacklist.js
M js/tests/parserTests.txt
3 files changed, 79 insertions(+), 3 deletions(-)
Approvals:
Subramanya Sastry: Looks good to me, approved
jenkins-bot: Verified
diff --git a/js/lib/mediawiki.WikitextSerializer.js
b/js/lib/mediawiki.WikitextSerializer.js
index 2cfe772..98d36f6 100644
--- a/js/lib/mediawiki.WikitextSerializer.js
+++ b/js/lib/mediawiki.WikitextSerializer.js
@@ -1160,7 +1160,7 @@
} else if ( /^mw:PageProp\/redirect$/.test( rtData.type ) ) {
rtData.tail = '';
rtData.prefix = dp.src ||
- ( ( env.conf.wiki.mwAliases.redirect || '#REDIRECT' ) +
' ' );
+ ( ( env.conf.wiki.mwAliases.redirect[0] || '#REDIRECT'
) + ' ' );
rtData.content.string = dp.content || (dp.sa && dp.sa.href) ||
href;
}
diff --git a/js/tests/parserTests-blacklist.js
b/js/tests/parserTests-blacklist.js
index 84b3aa8..bb32dce 100644
--- a/js/tests/parserTests-blacklist.js
+++ b/js/tests/parserTests-blacklist.js
@@ -1464,9 +1464,11 @@
add("html2wt", "Double interlanguage link, with prefix links (bug 8897)");
add("html2wt", "Parsoid-specific test: Wikilinks with should RT
properly");
add("html2wt", "Simple redirect to page");
-add("html2wt", "Redirect to image page");
+add("html2wt", "Redirect to image page (1)");
+add("html2wt", "Redirect to image page (2)");
add("html2wt", "Redirect to language");
add("html2wt", "Redirect to interwiki");
+add("html2wt", "Non-English #REDIRECT");
add("html2wt", "<br> to <br />");
add("html2wt", "Incorrecly removing closing slashes from correctly formed
XHTML");
add("html2wt", "Failing to transform badly formed HTML into correct XHTML");
@@ -2957,6 +2959,9 @@
add("selser", "Double interlanguage link, with prefix links (bug 8897)
[[4,0,2,2]]");
add("selser", "Double interlanguage link, with prefix links (bug 8897)
[[0,2,0,4]]");
add("selser", "Parsoid-specific test: Wikilinks with should RT properly
[[2]]");
+add("selser", "Non-English #REDIRECT [3,2]");
+add("selser", "Non-English #REDIRECT [0,2]");
+add("selser", "Non-English #REDIRECT [4,2]");
add("selser", "Handling html with a div self-closing tag [0,0,4,0,1]");
add("selser", "Handling html with a div self-closing tag
[0,2,0,2,[0,1,2,4,3,1]]");
add("selser", "Handling html with a div self-closing tag
[4,0,0,0,[2,2,0,0,0,2]]");
diff --git a/js/tests/parserTests.txt b/js/tests/parserTests.txt
index e36d82e..2b549c8 100644
--- a/js/tests/parserTests.txt
+++ b/js/tests/parserTests.txt
@@ -4844,11 +4844,61 @@
!! end
!! test
+Optional colon in #REDIRECT
+!! options
+# the colon is archaic syntax. we support it for wt2html, but we
+# don't care that it roundtrips back to the modern syntax.
+parsoid=wt2html,html2html
+!! input
+#REDIRECT:[[Main Page]]
+!! result
+<link rel="mw:PageProp/redirect" href="./Main_Page">
+!! end
+
+!! test
+Whitespace in #REDIRECT with optional colon
+!! options
+# the colon and gratuitous whitespace is archaic syntax. we support
+# it for wt2html, but we don't care that it roundtrips back to the
+# modern syntax (without extra whitespace)
+parsoid=wt2html,html2html
+!! input
+
+ #REDIRECT
+:
+[[Main Page]]
+!! result
+<link rel="mw:PageProp/redirect" href="./Main_Page">
+!! end
+
+!! test
+Piped link in #REDIRECT
+!! options
+# content after piped link is ignored. we support this syntax,
+# but don't care that the piped link is lost when we roundtrip this.
+parsoid=wt2html
+!! input
+#REDIRECT [[Main Page|bar]]
+!! result
+<link rel="mw:PageProp/redirect" href="./Main_Page">
+!! end
+
+!! test
Redirect to category
!! options
parsoid=wt2html
!! input
#REDIRECT [[Category:Foo]]
+!! result
+<link rel="mw:PageProp/redirect" href="./Category:Foo"><link
rel="mw:WikiLink/Category" href="./Category:Foo">
+!! end
+
+!! test
+Redirect to category with URL encoding
+!! options
+parsoid=wt2html
+!! input
+#REDIRECT [[Category%3AFoo]]
!! result
<link rel="mw:PageProp/redirect" href="./Category:Foo"><link
rel="mw:WikiLink/Category" href="./Category:Foo">
!! end
@@ -4864,11 +4914,21 @@
!! end
!! test
-Redirect to image page
+Redirect to image page (1)
!! options
parsoid
!! input
#REDIRECT [[File:Wiki.png]]
+!! result
+<link rel="mw:PageProp/redirect" href="./File:Wiki.png">
+!! end
+
+!! test
+Redirect to image page (2)
+!! options
+parsoid
+!! input
+#REDIRECT [[Image:Wiki.png]]
!! result
<link rel="mw:PageProp/redirect" href="./File:Wiki.png">
!! end
@@ -4893,6 +4953,17 @@
<link rel="mw:PageProp/redirect" href="File:Wiki.png">
!! end
+!! test
+Non-English #REDIRECT
+!! options
+parsoid
+language=is
+!! input
+#TILVĂSUN [[Main Page]]
+!! result
+<link rel="mw:PageProp/redirect" href="./Main_Page">
+!! end
+
##
## XHTML tidiness
###
--
To view, visit https://gerrit.wikimedia.org/r/77815
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I997cae79216d31559fb0a3abe555a26cc41acea0
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Parsoid
Gerrit-Branch: master
Gerrit-Owner: Cscott <[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