Merge "Don't display multiple language links to the same language"
[lhc/web/wiklou.git] / tests / parser / parserTests.txt
index 7c2f291..3a15ed5 100644 (file)
@@ -36,13 +36,13 @@ Main Page
 blah blah
 !! endarticle
 
-!!article 
+!!article
 Template:Foo
 !!text
 FOO
 !!endarticle
 
-!! article 
+!! article
 Template:Blank
 !! text
 !! endarticle
@@ -65,6 +65,12 @@ Template:inner list
 * item 1
 !! endarticle
 
+!! article
+Template:echo
+!! text
+{{{1}}}
+!! endarticle
+
 ###
 ### Basic tests
 ###
@@ -499,14 +505,30 @@ nowiki 3
 ### Comments
 ###
 !! test
-Comment test 1
+Comments and Pre
 !! input
+<!-- comment 1 --> asdf
+
 <!-- comment 1 --> asdf
 <!-- comment 2 -->
+
+<!-- comment 1 --> asdf
+<!-- comment 2 -->xyz
+
+<!-- comment 1 --> asdf
+<!-- comment 2 --> xyz
 !! result
 <pre>asdf
 </pre>
-
+<pre>asdf
+</pre>
+<pre>asdf
+</pre>
+<p>xyz
+</p>
+<pre>asdf
+xyz
+</pre>
 !! end
 
 !! test
@@ -868,6 +890,127 @@ Bug 6200: Preformatted in <blockquote>
 </p>
 !! end
 
+!!test
+Templates: Pre: 1a. Templates that break a line should suppress <pre>
+!!input
+ {{echo|}}
+!!result
+
+!!end
+
+!!test
+Templates: Pre: 1b. Templates that break a line should suppress <pre>
+!!input
+ {{echo|
+foo}}
+!!result
+<p>foo
+</p>
+!!end
+
+!! test
+Templates: Pre: 1c: Wrapping should be based on expanded content
+!! input
+ {{echo|a
+b}}
+!!result
+<pre>a
+</pre>
+<p>b
+</p>
+!!end
+
+!! test
+Templates: Pre: 1d: Wrapping should be based on expanded content
+!! input
+ {{echo|a
+b
+c
+ d
+e
+}}
+!!result
+<pre>a
+</pre>
+<p>b
+c
+</p>
+<pre>d
+</pre>
+<p>e
+</p>
+!!end
+
+!!test
+Templates: Pre: 1e. Wrapping should be based on expanded content
+!!input
+{{echo| foo}}
+
+{{echo| foo}}
+{{echo| bar}}
+
+{{echo|<!--cmt--> foo}}
+
+<!--cmt-->{{echo| foo}}
+
+{{echo|{{echo| }}bar}}
+!!result
+<pre>foo
+</pre>
+<pre>foo
+bar
+</pre>
+<pre>foo
+</pre>
+<pre>foo
+</pre>
+<pre>bar
+</pre>
+!!end
+
+###
+### Parsoid-centric tests for testing RT edge cases
+### around comments and white-space inside pre blocks
+###
+
+!!test
+1a. Pre and Comments
+!!input
+ a
+<!--a-->
+c
+!!result
+<pre>a
+</pre>
+<p>c
+</p>
+!!end
+
+!!test
+1b. Pre and Comments
+!!input
+ a
+ <!--a-->
+c
+!!result
+<pre>a
+</pre>
+<p>c
+</p>
+!!end
+
+!!test
+1c. Pre and Comments
+!!input
+<!--a-->  a
+
+ <!--a--> a
+!!result
+<pre> a
+</pre>
+<pre> a
+</pre>
+!!end
 
 ###
 ### Definition lists
@@ -1123,7 +1266,7 @@ Definition Lists: Indentation: Multi-level indent
 ##
 ## All Parsoid only definition list tests have this difference.
 ##
-## See also: https://bugzilla.wikimedia.org/show_bug.cgi?id=6569 
+## See also: https://bugzilla.wikimedia.org/show_bug.cgi?id=6569
 ## and http://lists.wikimedia.org/pipermail/wikitext-l/2011-November/000483.html
 
 !! test
@@ -1505,6 +1648,15 @@ second]
 </p>
 !!end
 
+!! test
+External links: Pipe char between url and text
+!! input
+[http://example.com | link]
+!! result
+<p><a rel="nofollow" class="external text" href="http://example.com">| link</a>
+</p>
+!!end
+
 !! test
 External links: protocol-relative URL in brackets
 !! input
@@ -2076,7 +2228,7 @@ A table with no data.
 # this as <p>caption</p>
 !! test
 A table with nothing but a caption
-!! input 
+!! input
 {|
 |+ caption
 |}
@@ -2816,6 +2968,16 @@ Blah blah blah
 </p>
 !! end
 
+!! test
+Parsoid-specific test: Wikilinks with &nbsp; should RT properly
+!! options
+language=ln
+!! input
+[[WW&nbsp;II]]
+!!result
+<p><a href="/index.php?title=WW_II&amp;action=edit&amp;redlink=1" class="new" title="WW II (lonkásá  ezalí tɛ̂)">WW&#160;II</a>
+</p>
+!! end
 
 ##
 ## XHTML tidiness
@@ -2839,7 +3001,7 @@ Incorrecly removing closing slashes from correctly formed XHTML
 </p>
 !! end
 
-!! test 
+!! test
 Failing to transform badly formed HTML into correct XHTML
 !! input
 <br style="clear: left;">
@@ -2852,6 +3014,47 @@ Failing to transform badly formed HTML into correct XHTML
 </p>
 !!end
 
+!! test
+Handling html with a div self-closing tag
+!! input
+<div title />
+<div title/>
+<div title/ >
+<div title=bar />
+<div title=bar/>
+<div title=bar/ >
+!! result
+<p>&lt;div title /&gt;
+&lt;div title/&gt;
+</p>
+<div>
+<p>&lt;div title=bar /&gt;
+&lt;div title=bar/&gt;
+</p>
+<div title="bar/"></div>
+</div>
+
+!! end
+
+!! test
+Handling html with a br self-closing tag
+!! input
+<br title />
+<br title/>
+<br title/ >
+<br title=bar />
+<br title=bar/>
+<br title=bar/ >
+!! result
+<p><br title="title" />
+<br title="title" />
+<br />
+<br title="bar" />
+<br title="bar" />
+<br title="bar/" />
+</p>
+!! end
+
 !! test
 Horizontal ruler (should it add that extra space?)
 !! input
@@ -4120,14 +4323,88 @@ section=1
 !! end
 
 ###
-### Parsoid-centric tests to stress Parsoid's ability to RT them unchanged
+### <includeonly> and <noinclude> in attributes
 ###
+!!test
+1. includeonly around the entire attribute
+!!input
+<span <includeonly>id="v1"</includeonly><noinclude>id="v2"</noinclude>>bar</span>
+!!result
+<p><span id="v2">bar</span>
+</p>
+!!end
+
+!!test
+2. includeonly in html attr key
+!!input
+<span <noinclude>id</noinclude><includeonly>about</includeonly>="foo">bar</span>
+!!result
+<p><span id="foo">bar</span>
+</p>
+!!end
+
+!!test
+3. includeonly in html attr value
+!!input
+<span id="<noinclude>v1</noinclude><includeonly>v2</includeonly>">bar</span>
+<span id=<noinclude>"v1"</noinclude><includeonly>"v2"</includeonly>>bar</span>
+!!result
+<p><span id="v1">bar</span>
+<span id="v1">bar</span>
+</p>
+!!end
+
+!!test
+4. includeonly in part of an attr value
+!!input
+<span style="color:<noinclude>red</noinclude><includeonly>blue</includeonly>;">bar</span>
+!!result
+<p><span style="color:red;">bar</span>
+</p>
+!!end
+
+###
+### Testing parsing of templates where a template arg
+### has the same name as the template itself.
+###
+
 !! article
-Template:echo
+Template:quote
 !! text
-{{{1}}}
+{{{quote|{{{1}}}}}}
 !! endarticle
 
+!!test
+Templates: Template Name/Arg clash: 1. Use of positional param
+!!input
+{{quote|foo}}
+!!result
+<p>foo
+</p>
+!!end
+
+!!test
+Templates: Template Name/Arg clash: 2. Use of named param
+!!input
+{{quote|quote=foo}}
+!!result
+<p>foo
+</p>
+!!end
+
+!!test
+Templates: Template Name/Arg clash: 3. Use of named param with empty input
+!!input
+{{quote|quote}}
+!!result
+<p>quote
+</p>
+!!end
+
+###
+### Parsoid-centric tests to stress Parsoid's ability to RT them unchanged
+###
+
 !!test
 Templates: 1. Simple use
 !!input
@@ -4310,7 +4587,7 @@ Templates: HTML Tag: 4. Generation of starting piece of HTML attr value
 !!end
 
 !!test
-Templates: HTML Tag: 5. Generation of middle piece of HTML attr value 
+Templates: HTML Tag: 5. Generation of middle piece of HTML attr value
 !!input
 <div title="This is a long title with just {{echo|one piece}} templated">foo</div>
 !!result
@@ -4319,7 +4596,7 @@ Templates: HTML Tag: 5. Generation of middle piece of HTML attr value
 !!end
 
 !!test
-Templates: HTML Tag: 6. Generation of end piece of HTML attr value 
+Templates: HTML Tag: 6. Generation of end piece of HTML attr value
 !!input
 <div title="This is a long title with just one piece {{echo|templated}}">foo</div>
 !!result
@@ -4417,24 +4694,6 @@ Templates: Tables: 4f. Generating a single tag of a HTML table
 
 !!end
 
-!!test
-Templates: Pre: 1a. Templates that break a line should suppress <pre> 
-!!input
- {{echo|}}
-!!result
-
-!!end
-
-!!test
-Templates: Pre: 1b. Templates that break a line should suppress <pre> 
-!!input
- {{echo|
-foo}}
-!!result
-<p>foo
-</p>
-!!end
-
 !!test
 Parser Functions: 1. Simple example
 !!input
@@ -5423,7 +5682,7 @@ Custom class
 </p>
 !! end
 
-!! article 
+!! article
 File:Barfoo.jpg
 !! text
 #REDIRECT [[File:Barfoo.jpg]]
@@ -5538,6 +5797,48 @@ PAGESINCATEGORY invalid title fatal (r33546 fix)
 </p>
 !! end
 
+!! test
+Category with different sort key
+!! options
+cat
+!! input
+[[Category:MediaWiki User's Guide|Foo]]
+!! result
+<a href="/wiki/Category:MediaWiki_User%27s_Guide" title="Category:MediaWiki User's Guide">MediaWiki User's Guide</a>
+!! end
+
+!! test
+Category with identical sort key
+!! options
+cat
+!! input
+[[Category:MediaWiki User's Guide|MediaWiki User's Guide]]
+!! result
+<a href="/wiki/Category:MediaWiki_User%27s_Guide" title="Category:MediaWiki User's Guide">MediaWiki User's Guide</a>
+!! end
+
+!! test
+Category with empty sort key
+!! options
+cat
+pst
+!! input
+[[Category:MediaWiki User's Guide|]]
+!! result
+[[Category:MediaWiki User's Guide|MediaWiki User's Guide]]
+!! end
+
+!! test
+Category with empty sort key and parentheses
+!! options
+cat
+pst
+!! input
+[[Category:Foo (bar)|]]
+!! result
+[[Category:Foo (bar)|Foo]]
+!! end
+
 ###
 ### Inter-language links
 ###
@@ -5639,7 +5940,7 @@ Some text
 # perl -e 'print "="x$_," Level $_ heading","="x$_,"\n" for 1..10'
 !! test
 Handling of sections up to level 6 and beyond
-!! input 
+!! input
 = Level 1 Heading=
 == Level 2 Heading==
 === Level 3 Heading===
@@ -7848,7 +8149,7 @@ section=2
 !! end
 
 
-# Formerly testing for bug 2587, now resolved by the use of unmarked sections 
+# Formerly testing for bug 2587, now resolved by the use of unmarked sections
 # instead of respecting commented sections
 !! test
 Section extraction prefixed by comment (section 1)
@@ -7873,7 +8174,7 @@ section=2
 !!end
 
 
-# Formerly testing for bug 2607, now resolved by the use of unmarked sections 
+# Formerly testing for bug 2607, now resolved by the use of unmarked sections
 # instead of respecting HTML-style headings
 !! test
 Section extraction, mixed wiki and html (section 1)
@@ -8656,7 +8957,7 @@ HTML Hex character encoding mixed case
 
 !! test
 __FORCETOC__ override
-!! input 
+!! input
 __NEWSECTIONLINK__
 __FORCETOC__
 !! result
@@ -8710,7 +9011,7 @@ RFC RFC 1234
 !! end
 
 !! test
-Double RFC with a wiki link 
+Double RFC with a wiki link
 !! input
 RFC [[RFC 1234]]
 !! result
@@ -9430,7 +9731,7 @@ Fridrih IV je car.
 
 !! test
 Unclosed language converter markup "-{"
-!! options 
+!! options
 language=sr
 !! input
 -{T|hello
@@ -9445,12 +9746,12 @@ Don't convert raw rule "-{R|=&gt;}-" to "=>"
 language=sr
 !! input
 -{R|=&gt;}-
-!! result 
+!! result
 <p>=&gt;
 </p>
 !!end
 
-!!article 
+!!article
 Template:Bullet
 !!text
 * Bar
@@ -10200,7 +10501,7 @@ Screen
 <p>this is not the the title
 </p>
 !! end
+
 !! test
 preload: check <noinclude> and <includeonly>
 !! options
@@ -10210,7 +10511,7 @@ Hello <noinclude>cruel</noinclude><includeonly>kind</includeonly> world.
 !! result
 Hello kind world.
 !! end
+
 !! test
 preload: check <onlyinclude>
 !! options
@@ -10242,7 +10543,7 @@ preload
 !! end
 
 !! test
-Play a bit with r67090 and bug 3158 
+Play a bit with r67090 and bug 3158
 !! options
 disabled
 !! input
@@ -10451,7 +10752,7 @@ __TOC__
 !! end
 
 !! test
-Bug 26375: TOC with bold 
+Bug 26375: TOC with bold
 !! options
 title=[[Main Page]]
 !! input
@@ -10560,6 +10861,37 @@ __TOC__
 
 !! end
 
+!! test
+span tags with directionality in TOC
+!! input
+__TOC__
+== <span dir="ltr">C++</span> ==
+
+== <span dir="rtl">זבנג!</span> ==
+
+== <span style="font-style: italic">The attributes on these span tags must be deleted from the TOC</span> ==
+
+== <span style="font-style: italic" dir="ltr">All attributes on these span tags must be deleted from the TOC</span> ==
+
+== <span dir="ltr" style="font-style: italic">Attributes after dir on these span tags must be deleted from the TOC</span> ==
+!! result
+<table id="toc" class="toc"><tr><td><div id="toctitle"><h2>Contents</h2></div>
+<ul>
+<li class="toclevel-1 tocsection-1"><a href="#C.2B.2B"><span class="tocnumber">1</span> <span class="toctext"><span dir="ltr">C++</span></span></a></li>
+<li class="toclevel-1 tocsection-2"><a href="#.D7.96.D7.91.D7.A0.D7.92.21"><span class="tocnumber">2</span> <span class="toctext"><span dir="rtl">זבנג!</span></span></a></li>
+<li class="toclevel-1 tocsection-3"><a href="#The_attributes_on_these_span_tags_must_be_deleted_from_the_TOC"><span class="tocnumber">3</span> <span class="toctext"><span>The attributes on these span tags must be deleted from the TOC</span></span></a></li>
+<li class="toclevel-1 tocsection-4"><a href="#All_attributes_on_these_span_tags_must_be_deleted_from_the_TOC"><span class="tocnumber">4</span> <span class="toctext"><span>All attributes on these span tags must be deleted from the TOC</span></span></a></li>
+<li class="toclevel-1 tocsection-5"><a href="#Attributes_after_dir_on_these_span_tags_must_be_deleted_from_the_TOC"><span class="tocnumber">5</span> <span class="toctext"><span dir="ltr">Attributes after dir on these span tags must be deleted from the TOC</span></span></a></li>
+</ul>
+</td></tr></table>
+<h2><span class="editsection">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: C++">edit</a>]</span> <span class="mw-headline" id="C.2B.2B"> <span dir="ltr">C++</span> </span></h2>
+<h2><span class="editsection">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Edit section: זבנג!">edit</a>]</span> <span class="mw-headline" id=".D7.96.D7.91.D7.A0.D7.92.21"> <span dir="rtl">זבנג!</span> </span></h2>
+<h2><span class="editsection">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;section=3" title="Edit section: The attributes on these span tags must be deleted from the TOC">edit</a>]</span> <span class="mw-headline" id="The_attributes_on_these_span_tags_must_be_deleted_from_the_TOC"> <span style="font-style: italic">The attributes on these span tags must be deleted from the TOC</span> </span></h2>
+<h2><span class="editsection">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;section=4" title="Edit section: All attributes on these span tags must be deleted from the TOC">edit</a>]</span> <span class="mw-headline" id="All_attributes_on_these_span_tags_must_be_deleted_from_the_TOC"> <span style="font-style: italic" dir="ltr">All attributes on these span tags must be deleted from the TOC</span> </span></h2>
+<h2><span class="editsection">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;section=5" title="Edit section: Attributes after dir on these span tags must be deleted from the TOC">edit</a>]</span> <span class="mw-headline" id="Attributes_after_dir_on_these_span_tags_must_be_deleted_from_the_TOC"> <span dir="ltr" style="font-style: italic">Attributes after dir on these span tags must be deleted from the TOC</span> </span></h2>
+
+!! end
+
 !! article
 MediaWiki:Bug32057
 !! text