Merge "Links created by Linker::makeExternalLink didn't include rel=nofollow"
[lhc/web/wiklou.git] / tests / parser / parserTests.txt
index 0e6e83e..63c9e65 100644 (file)
@@ -785,6 +785,24 @@ x <div>foo</div> z
 
 !! end
 
+!! test
+Empty lines between block tags to test open p-tags are closed between the block tags
+!! input
+<div></div>
+
+
+<div></div>a
+
+b
+!! result
+<div></div>
+<p><br />
+</p>
+<div></div>a
+<p>b
+</p>
+!! end
+
 ###
 ### Preformatted text
 ###
@@ -1207,6 +1225,23 @@ c
 
 !!end
 
+!!test
+2c. Indent-Pre and tables (bug 42252)
+!!input
+{|
+ |+ foo
+ !  | bar
+|}
+!!result
+<table>
+<caption> foo
+</caption>
+<tr>
+<th> bar
+</th></tr></table>
+
+!!end
+
 !!test
 3a. Indent-Pre and block tags (single-line html)
 !!input
@@ -1291,6 +1326,20 @@ c
 
 !!end
 
+!! test
+5. White-space in indent-pre
+NOTE: the white-space char on 2nd line is significant
+!! input
+ a<br/>
+ b
+!! result
+<pre>a<br />
+
+b
+</pre>
+!! end
+
 ###
 ### HTML-pre (some to spec PHP parser behavior and some Parsoid-RT-centric)
 ###
@@ -2724,6 +2773,45 @@ A table with nothing but a caption
 
 !! end
 
+!! test
+A table with caption with default-spaced attributes and a table row
+!! input
+{|
+|+ style="color: red;" | caption1
+|-
+| foo
+|}
+!! result
+<table>
+<caption style="color: red;"> caption1
+</caption>
+<tr>
+<td> foo
+</td></tr></table>
+
+!! end
+
+!! test
+A table with captions with non-default spaced attributes and a table row
+!! input
+{|
+|+style="color: red;"|caption2
+|+ style="color: red;"| caption3
+|-
+| foo
+|}
+!! result
+<table>
+<caption style="color: red;">caption2
+</caption>
+<caption style="color: red;"> caption3
+</caption>
+<tr>
+<td> foo
+</td></tr></table>
+
+!! end
+
 !! test
 Table td-cell syntax variations
 !! input
@@ -3125,6 +3213,29 @@ disabled
 
 !! end
 
+!! test
+Wikitext table with a lot of comments
+!! input
+{|
+<!-- c0 -->
+| foo
+<!-- c1 -->
+|- <!-- c2 -->
+<!-- c3 -->
+|<!-- c4 -->
+<!-- c5 -->
+|}
+!! result
+<table>
+<tr>
+<td> foo
+</td></tr>
+<tr>
+<td>
+</td></tr></table>
+
+!! end
+
 ###
 ### Internal links
 ###
@@ -3209,6 +3320,28 @@ Link with suffix
 </p>
 !! end
 
+!! article
+prefixed article
+!! text
+Some text
+!! endarticle
+
+!! test
+Bug 43661: Piped links with identical prefixes
+!! input
+[[prefixed article|prefixed articles with spaces]]
+
+[[prefixed article|prefixed articlesaoeu]]
+
+[[Main Page|Main Page test]]
+!! result
+<p><a href="/wiki/Prefixed_article" title="Prefixed article">prefixed articles with spaces</a>
+</p><p><a href="/wiki/Prefixed_article" title="Prefixed article">prefixed articlesaoeu</a>
+</p><p><a href="/wiki/Main_Page" title="Main Page">Main Page test</a>
+</p>
+!! end
+
+
 !! test
 Link with HTML entity in suffix / tail
 !! input
@@ -3579,6 +3712,24 @@ language=kaa
 </p>
 !! end
 
+!! test
+Parsoid-centric test: Whitespace in ext- and wiki-links should be preserved
+!! input
+[[Foo|  bar]]
+
+[[Foo|  ''bar'']]
+
+[http://wp.org   foo]
+
+[http://wp.org   ''foo'']
+!! result
+<p><a href="/index.php?title=Foo&amp;action=edit&amp;redlink=1" class="new" title="Foo (page does not exist)">  bar</a>
+</p><p><a href="/index.php?title=Foo&amp;action=edit&amp;redlink=1" class="new" title="Foo (page does not exist)">  <i>bar</i></a>
+</p><p><a rel="nofollow" class="external text" href="http://wp.org">foo</a>
+</p><p><a rel="nofollow" class="external text" href="http://wp.org"><i>foo</i></a>
+</p>
+!! end
+
 ###
 ### Interwiki links (see maintenance/interwiki.sql)
 ###
@@ -4041,6 +4192,54 @@ Nested lists 8 (multiple nesting transitions)
 
 !! end
 
+!! test
+Unbalanced closing block tags break a list
+(Disabled since php parser generates broken html -- relies on Tidy to fix up)
+!! options
+disabled
+!! input
+<div>
+*a</div><div>
+*b</div>
+!! result
+<div>
+<ul><li>a
+</li></ul></div><div>
+<ul><li>b
+</li></ul></div>
+!! end
+
+!! test
+Unbalanced closing non-block tags don't break a list
+(Disabled since php parser generates broken html -- relies on Tidy to fix up)
+!! options
+disabled
+!! input
+<span>
+*a</span><span>
+*b</span>
+!! result
+<p><span></span>
+</p>
+<ul><li>a<span></span>
+</li><li>b
+</li></ul>
+!! end
+
+!! test
+Unclosed formatting tags that straddle lists are closed and reopened
+(Disabled since php parser generates broken html -- relies on Tidy to fix up)
+!! options
+disabled
+!! input
+# <s> a
+# b </s>
+!! result
+<ol><li> <s> a </s>
+</li><li> <s> b </s>
+</li></ol>
+!! end
+
 !! test
 List items are not parsed correctly following a <pre> block (bug 785)
 !! input
@@ -4855,8 +5054,14 @@ Main Page
 Template as link source
 !! input
 [[{{linktest2}}]]
+
+[[{{linktest2}}|Main Page]]
+
+[[{{linktest2}}]]Page
 !! result
 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
+</p><p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
+</p><p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>Page
 </p>
 !! end
 
@@ -5370,8 +5575,23 @@ Templates: Links: 2. Generation of link href
 Templates: Links: 3. Generation of part of a link href
 !!input
 [[Fo{{echo|o}}|bar]]
+
+[[Foo{{echo|bar}}]]
+
+[[Foo{{echo|bar}}baz]]
+
+[[Foo{{echo|bar}}|bar]]
+
+[[:Foo{{echo|bar}}]]
+
+[[:Foo{{echo|bar}}|bar]]
 !!result
 <p><a href="/index.php?title=Foo&amp;action=edit&amp;redlink=1" class="new" title="Foo (page does not exist)">bar</a>
+</p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
+</p><p><a href="/index.php?title=Foobarbaz&amp;action=edit&amp;redlink=1" class="new" title="Foobarbaz (page does not exist)">Foobarbaz</a>
+</p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">bar</a>
+</p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
+</p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">bar</a>
 </p>
 !!end
 
@@ -5694,7 +5914,7 @@ disabled
 |bar
 |}
 !!result
-<table data-parsoid="{&quot;src&quot;:&quot;{|\n|{{echo|foo&lt;/table&gt;}}\n|bar\n|}&quot;}" about="#mwt1" typeof="mw:Object/Template ">
+<table  about="#mwt1" typeof="mw:Object/Template ">
 <tbody><tr><td>foo</td></tr></tbody></table><span about="#mwt1">
 bar</span><span about="#mwt1">
 </span>
@@ -5726,14 +5946,14 @@ disabled
   </tr>
 </table>
 !!result
-<table data-parsoid="{&quot;src&quot;:&quot;&lt;table&gt;\n  &lt;tr&gt;\n    &lt;td&gt;\n    &lt;table&gt;\n      &lt;tr&gt;\n        &lt;td&gt;1. {{echo|foo &lt;/table&gt;}}&lt;/td&gt;\n        &lt;td&gt; bar &lt;/td&gt;\n        &lt;td&gt;2. {{echo|baz &lt;/table&gt;}}&lt;/td&gt;\n      &lt;/tr&gt;\n      &lt;tr&gt;\n        &lt;td&gt;abc&lt;/td&gt;\n      &lt;/tr&gt;\n    &lt;/table&gt;\n    &lt;/td&gt;\n  &lt;/tr&gt;\n  &lt;tr&gt;\n    &lt;td&gt;xyz&lt;/td&gt;\n  &lt;/tr&gt;\n&lt;/table&gt;&quot;}" about="#mwt1" typeof="mw:Object/Template">
-  <tbody><tr data-parsoid="{&quot;stx&quot;:&quot;html&quot;}">
-    <td data-parsoid="{&quot;stx&quot;:&quot;html&quot;}">
-    <table data-parsoid="{&quot;stx&quot;:&quot;html&quot;}">
-      <tbody><tr data-parsoid="{&quot;stx&quot;:&quot;html&quot;}">
-        <td data-parsoid="{&quot;stx&quot;:&quot;html&quot;}">1. foo </td></tr></tbody></table></td>
-        <td data-parsoid="{&quot;stx&quot;:&quot;html&quot;}"> bar </td>
-        <td data-parsoid="{&quot;stx&quot;:&quot;html&quot;}">2. baz </td></tr></tbody></table><span about="#mwt1">
+<table  about="#mwt1" typeof="mw:Object/Template">
+  <tbody><tr >
+    <td >
+    <table >
+      <tbody><tr >
+        <td >1. foo </td></tr></tbody></table></td>
+        <td > bar </td>
+        <td >2. baz </td></tr></tbody></table><span about="#mwt1">
       </span><span about="#mwt1">
       
         abc</span><span about="#mwt1">
@@ -5747,6 +5967,28 @@ disabled
 </span>
 !!end
 
+!! test
+Templates: Ugly templates: 3. newline-only template parameter
+!! input
+foo {{echo|
+}}
+!! result
+<p>foo 
+</p>
+!! end
+
+# This looks like a bug: a single newline triggers p/br for some reason.
+!! test
+Templates: Ugly templates: 4. newline-only template parameter inconsistency
+!! input
+{{echo|
+}}
+!! result
+<p><br />
+</p>
+!! end
+
+
 !!test
 Parser Functions: 1. Simple example
 !!input
@@ -7505,6 +7747,10 @@ Namespaced link must have a title (bad fragment version)
 !!end
 
 
+###
+### HTML tags and HTML attributes
+###
+
 !! test
 div with no attributes
 !! input
@@ -7563,6 +7809,18 @@ disabled
 
 !! end
 
+# The PHP parser escapes the opening brace to &#123; for some reason, so
+# disabled this test for it.
+!! test
+div with braces in attribute value
+!! options
+disabled
+!! input
+<div title="{}">Foo</div>
+!! result
+<div title="{}">Foo</div>
+!! end
+
 # This it very inconsistent in the PHP parser: it returns 
 # class="class" if there is a space between the name and the equal sign (see
 # 'div with empty attribute value, space before equals'), but strips the
@@ -7649,6 +7907,15 @@ I always thought &eacute; was a cute letter.
 </p>
 !! end
 
+!! test
+text with entity-escaped character entity-like string: eacute
+!! input
+I always thought &amp;eacute; was a cute letter.
+!! result
+<p>I always thought &amp;eacute; was a cute letter.
+</p>
+!! end
+
 !! test
 text with undefined character entity: xacute
 !! input
@@ -10800,6 +11067,29 @@ language=sr cat
 !! end
 
 
+!! article
+Category:分类
+!! text
+blah
+!! endarticle
+
+!! article
+Category:分類
+!! text
+blah
+!! endarticle
+
+!! test
+Don't convert blue categorylinks to another variant (bug 33210)
+!! options
+language=zh cat
+!! input
+[[A]][[Category:分类]]
+!! result
+<a href="/wiki/Category:%E5%88%86%E7%B1%BB" title="Category:分类">分类</a>
+!! end
+
+
 !! test
 Stripping -{}- tags (language variants)
 !! options
@@ -10872,6 +11162,20 @@ language=zh variant=zh-tw
 !! end
 
 
+!! test
+Conversion around HTML tags
+!! options
+language=sr variant=sr-ec
+!! input
+-{H|span=>sr-ec:script;title=>sr-ec:src;}-
+<span title="La-{sr-el:L;sr-ec:C;}-tin">ski</span>
+!! result
+<p>
+<span title="ЛаCтин">ски</span>
+</p>
+!! end
+
+
 !! test
 Explicit session-wise language variant mapping (A flag and - flag)
 !! options
@@ -10926,6 +11230,20 @@ China
 </p>
 !! end
 
+!! test
+Recursive conversion of alt and title attrs shouldn't clear converter state
+!! options
+language=zh variant=zh-cn showtitle
+!! input
+-{H|zh-cn:Exclamation;zh-tw:exclamation;}-
+Should be stripped-{T|zh-cn:China;zh-tw:Taiwan}-<span title="exclamation">!</span>
+!! result
+China
+<p>
+Should be stripped<span title="Exclamation">!</span>
+</p>
+!! end
+
 !! test
 Bug 24072: more test on conversion rule for title
 !! options
@@ -12942,6 +13260,23 @@ disabled
 </tbody></table>
 !! end
 
+!! test
+Tables: 4d. No escaping needed
+!! input
+{|
+||+1
+||-2
+|}
+!! result
+<table>
+<tr>
+<td>+1
+</td>
+<td>-2
+</td></tr></table>
+
+!! end
+
 #### --------------- Links ---------------
 #### 1. Quote marks in link text
 #### 2. Wikilinks: Escapes needed
@@ -12956,7 +13291,7 @@ disabled
 !! input
 [[Foo|<nowiki>Foo''boo''</nowiki>]]
 !! result
-<a rel="mw:WikiLink" href="Foo" data-parsoid="{&quot;tsr&quot;:[0,7],&quot;contentPos&quot;:[5,5],&quot;src&quot;:&quot;[[Foo]]&quot;,&quot;bsp&quot;:[0,7],&quot;stx&quot;:&quot;simple&quot;}">Foo''boo''</a>
+<a rel="mw:WikiLink" href="Foo">Foo''boo''</a>
 !! end
 
 !! test
@@ -13198,6 +13533,23 @@ disabled
 </p>
 !! end
 
+!! test
+HTML tag with necessary entities in attributes
+!! input
+<span title="&amp;amp;">foo</span>
+!! result
+<p><span title="&amp;amp;">foo</span>
+</p>
+!! end
+
+!! test
+HTML tag with 'unnecessary' entity encoding in attributes
+!! input
+<span title="&amp;">foo</span>
+!! result
+<p><span title="&amp;">foo</span>
+</p>
+!! end
 
 TODO:
 more images