Merge "Test wiki tables with a lot of comments"
[lhc/web/wiklou.git] / tests / parser / parserTests.txt
index 03a184b..6025ce1 100644 (file)
@@ -65,6 +65,18 @@ Template:inner list
 * item 1
 !! endarticle
 
+!! article
+Template:tbl-start
+!! text
+{|
+!! endarticle
+
+!! article
+Template:tbl-end
+!! text
+|}
+!! endarticle
+
 !! article
 Template:!
 !! text
@@ -542,7 +554,7 @@ nowiki 3
 ### Comments
 ###
 !! test
-Comments and Pre
+Comments and Indent-Pre
 !! input
 <!-- comment 1 --> asdf
 
@@ -948,7 +960,7 @@ Bug 6200: Preformatted in <blockquote>
 !! end
 
 !!test
-Templates: Pre: 1a. Templates that break a line should suppress <pre>
+Templates: Indent-Pre: 1a. Templates that break a line should suppress <pre>
 !!input
  {{echo|}}
 !!result
@@ -956,7 +968,7 @@ Templates: Pre: 1a. Templates that break a line should suppress <pre>
 !!end
 
 !!test
-Templates: Pre: 1b. Templates that break a line should suppress <pre>
+Templates: Indent-Pre: 1b. Templates that break a line should suppress <pre>
 !!input
  {{echo|
 foo}}
@@ -966,7 +978,7 @@ foo}}
 !!end
 
 !! test
-Templates: Pre: 1c: Wrapping should be based on expanded content
+Templates: Indent-Pre: 1c: Wrapping should be based on expanded content
 !! input
  {{echo|a
 b}}
@@ -978,7 +990,7 @@ b}}
 !!end
 
 !! test
-Templates: Pre: 1d: Wrapping should be based on expanded content
+Templates: Indent-Pre: 1d: Wrapping should be based on expanded content
 !! input
  {{echo|a
 b
@@ -999,7 +1011,7 @@ c
 !!end
 
 !!test
-Templates: Pre: 1e. Wrapping should be based on expanded content
+Templates: Indent-Pre: 1e. Wrapping should be based on expanded content
 !!input
 {{echo| foo}}
 
@@ -1030,7 +1042,7 @@ bar
 !!end
 
 !! test
-Templates: Pre: 1f: Wrapping should be based on expanded content
+Templates: Indent-Pre: 1f: Wrapping should be based on expanded content
 !! input
 {{echo| }}a
 
@@ -1120,7 +1132,7 @@ Templates: Strip whitespace from named parameters, but not positional ones
 ###
 
 !!test
-1a. Pre and Comments
+1a. Indent-Pre and Comments
 !!input
  a
 <!--a-->
@@ -1133,7 +1145,7 @@ c
 !!end
 
 !!test
-1b. Pre and Comments
+1b. Indent-Pre and Comments
 !!input
  a
  <!--a-->
@@ -1146,7 +1158,7 @@ c
 !!end
 
 !!test
-1c. Pre and Comments
+1c. Indent-Pre and Comments
 !!input
 <!--a-->  a
 
@@ -1159,7 +1171,7 @@ c
 !!end
 
 !!test
-2a. Pre and tables
+2a. Indent-Pre and tables
 !!input
  {|
  |-
@@ -1180,7 +1192,7 @@ c
 !!end
 
 !!test
-2b. Pre and tables
+2b. Indent-Pre and tables
 !!input
   {|
  |-
@@ -1196,7 +1208,7 @@ c
 !!end
 
 !!test
-3a. Pre and block tags (single-line html)
+3a. Indent-Pre and block tags (single-line html)
 !!input
  <p> foo </p>
  <div> foo </div>
@@ -1209,7 +1221,7 @@ c
 !!end
 
 !!test
-3b. Pre and block tags (pre-content on separate line)
+3b. Indent-Pre and block tags (pre-content on separate line)
 !!input
 <p>
  foo
@@ -1279,6 +1291,80 @@ c
 
 !!end
 
+###
+### HTML-pre (some to spec PHP parser behavior and some Parsoid-RT-centric)
+###
+
+!!test
+HTML-pre: 1. embedded newlines
+!!input
+<pre>foo</pre>
+
+<pre>
+foo
+</pre>
+
+<pre>
+
+foo
+</pre>
+
+<pre>
+
+
+foo
+</pre>
+!!result
+<pre>foo</pre>
+<pre>
+foo
+</pre>
+<pre>
+
+foo
+</pre>
+<pre>
+
+
+foo
+</pre>
+
+!!end
+
+!!test
+HTML-pre: 2: indented text
+!!input
+<pre>
+ foo
+</pre>
+!!result
+<pre>
+ foo
+</pre>
+
+!!end
+
+!!test
+HTML-pre: 3: other wikitext
+!!input
+<pre>
+* foo
+# bar
+= no-h =
+'' no-italic ''
+[[ NoLink ]]
+</pre>
+!!result
+<pre>
+* foo
+# bar
+= no-h =
+'' no-italic ''
+[[ NoLink ]]
+</pre>
+
+!!end
+
 ###
 ### Definition lists
 ###
@@ -1572,6 +1658,66 @@ should be left alone
 ## See also: https://bugzilla.wikimedia.org/show_bug.cgi?id=6569
 ## and http://lists.wikimedia.org/pipermail/wikitext-l/2011-November/000483.html
 
+!! test
+Table / list interaction: indented table with lists in table contents
+!! input
+:{|
+|-
+| a
+* b
+|-
+| c
+* d
+|}
+!! result
+<dl><dd><table>
+
+<tr>
+<td> a
+<ul><li> b
+</li></ul>
+</td></tr>
+<tr>
+<td> c
+<ul><li> d
+</li></ul>
+</td></tr></table></dd></dl>
+
+!! end
+
+!!test
+Table / list interaction: lists nested in tables nested in indented lists
+!!input
+:{|
+|
+:a
+:b
+|
+*c
+*d
+|}
+
+*e
+*f
+!!result
+<dl><dd><table>
+<tr>
+<td>
+<dl><dd>a
+</dd><dd>b
+</dd></dl>
+</td>
+<td>
+<ul><li>c
+</li><li>d
+</li></ul>
+</td></tr></table></dd></dl>
+<ul><li>e
+</li><li>f
+</li></ul>
+
+!!end
+
 !! test
 Definition Lists: Nesting: Multi-level (Parsoid only)
 !! options
@@ -2713,25 +2859,104 @@ Multiplication table
 
 !! end
 
+!! test
+Accept "||" in table headings
+!! input
+{|
+!h1 || h2
+|}
+!! result
+<table>
+<tr>
+<th>h1 </th>
+<th> h2
+</th></tr></table>
+
+!! end
+
+!! test
+Accept "||" in indented table headings
+!! input
+:{|
+!h1 || h2
+|}
+!! result
+<dl><dd><table>
+<tr>
+<th>h1 </th>
+<th> h2
+</th></tr></table></dd></dl>
+
+!! end
+
+!! test
+Accept empty attributes in td/th cells (td/th cells starting with leading ||)
+!! input
+{|
+!| h1
+|| a
+|}
+!! result
+<table>
+<tr>
+<th> h1
+</th>
+<td> a
+</td></tr></table>
+
+!! end
+
 !!test
-Allow +/- in 2nd and later cells in a row
+Accept "| !" at start of line in tables (ignore !-attribute)
 !!input
 {|
+|-
+| !style="color:red" | bar
+|}
+!!result
+<table>
+
+<tr>
+<td> bar
+</td></tr></table>
+
+!!end
+
+!!test
+Allow +/- in 2nd and later cells in a row, in 1st cell when td-attrs are present, or in 1st cell when there is a space between "|" and +/- 
+!!input
+{|
+|-
+|style='color:red;'|+1
+|style='color:blue;'|-1
+|-
 | 1 || 2 || 3
+| 1 ||+2 ||-3
 |-
-| 1 || +2 || -3
+| +1
+| -1
 |}
 !!result
 <table>
+
+<tr>
+<td style="color:red;">+1
+</td>
+<td style="color:blue;">-1
+</td></tr>
 <tr>
 <td> 1 </td>
 <td> 2 </td>
 <td> 3
+</td>
+<td> 1 </td>
+<td>+2 </td>
+<td>-3
 </td></tr>
 <tr>
-<td> 1 </td>
-<td> +2 </td>
-<td> -3
+<td> +1
+</td>
+<td> -1
 </td></tr></table>
 
 !!end
@@ -2900,6 +3125,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
 ###
@@ -2984,6 +3232,15 @@ Link with suffix
 </p>
 !! end
 
+!! test
+Link with HTML entity in suffix / tail
+!! input
+[[Main Page]]&quot;, [[Main Page]]&#97;
+!! result
+<p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>&quot;, <a href="/wiki/Main_Page" title="Main Page">Main Page</a>&#97;
+</p>
+!! end
+
 !! test
 Link with 3 brackets
 !! input
@@ -3871,6 +4128,20 @@ List interrupted by empty line or heading
 
 !!end
 
+!!test
+Multiple list tags generated by templates
+!!input
+{{echo|<li>}}a
+{{echo|<li>}}b
+{{echo|<li>}}c
+!!result
+<li>a
+<li>b
+<li>c</li>
+</li>
+</li>
+
+!!end
 
 ###
 ### Magic Words
@@ -4317,6 +4588,24 @@ Nonexistent template
 </p>
 !! end
 
+!! test
+Template with invalid target containing tags
+!! input
+{{a<b>b</b>|{{echo|foo}}|{{echo|a}}={{echo|b}}|a = b}}
+!! result
+<p>{{a<b>b</b>|foo|a=b|a = b}}
+</p>
+!! end
+
+!! test
+Template with invalid target containing unclosed tag
+!! input
+{{a<b>|{{echo|foo}}|{{echo|a}}={{echo|b}}|a = b}}
+!! result
+<p>{{a<b>|foo|a=b|a = b}}</b>
+</p>
+!! end
+
 !! article
 Template:test
 !! text
@@ -4809,6 +5098,40 @@ Un-closed <onlyinclude>
 !! result
 !! end
 
+!!test
+Self-closed noinclude, includeonly, onlyinclude tags
+!!input
+<noinclude />
+<includeonly />
+<onlyinclude />
+!!result
+<p><br />
+</p>
+!!end
+
+!!test
+Unbalanced includeonly and noinclude tags
+!!input
+{|
+|a</noinclude>
+|b</noinclude></noinclude>
+|c</noinclude></includeonly>
+|d</includeonly></includeonly>
+|}
+!!result
+<table>
+<tr>
+<td>a
+</td>
+<td>b
+</td>
+<td>c&lt;/includeonly&gt;
+</td>
+<td>d&lt;/includeonly&gt;&lt;/includeonly&gt;
+</td></tr></table>
+
+!!end
+
 !! article
 Template:Includeonly section
 !! text
@@ -5288,6 +5611,45 @@ Templates: Wiki Tables: 3. td-content via multiple templates
 
 !!end
 
+!!test
+Templates: Wiki Tables: 4. Templated tags, no content
+!!input
+{{tbl-start}}
+{{tbl-end}}
+!!result
+<table>
+<tr><td></td></tr></table>
+
+!!end
+
+!!test
+Templates: Wiki Tables: 4. Templated tags, regular td-tags
+!!input
+{{tbl-start}}
+|foo
+{{tbl-end}}
+!!result
+<table>
+<tr>
+<td>foo
+</td></tr></table>
+
+!!end
+
+!!test
+Templates: Wiki Tables: 4. Templated tags, templated td-tags
+!!input
+{{tbl-start}}
+{{!}}foo
+{{tbl-end}}
+!!result
+<table>
+<tr>
+<td>foo
+</td></tr></table>
+
+!!end
+
 !!test
 Templates: Lists: Multi-line list-items via templates
 !!input
@@ -5355,7 +5717,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>
@@ -5387,14 +5749,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">
@@ -7166,6 +7528,10 @@ Namespaced link must have a title (bad fragment version)
 !!end
 
 
+###
+### HTML tags and HTML attributes
+###
+
 !! test
 div with no attributes
 !! input
@@ -7224,6 +7590,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
@@ -10623,6 +11001,29 @@ Nested: -{zh-hans:Hi -{zh-cn:China;zh-sg:Singapore;}-;zh-hant:Hello -{zh-tw:Taiw
 </p>
 !! end
 
+!! test
+Proper conversion of text in external links
+!! options
+language=sr variant=sr-ec
+!! input
+http://www.google.com
+gopher://www.google.com
+[http://www.google.com http://www.google.com]
+[gopher://www.google.com gopher://www.google.com]
+[https://www.google.com irc://www.google.com]
+[ftp://www.google.com www.google.com/ftp://dir]
+[//www.google.com www.google.com]
+!! result
+<p><a rel="nofollow" class="external free" href="http://www.google.com">http://www.google.com</a>
+<a rel="nofollow" class="external free" href="gopher://www.google.com">gopher://www.google.com</a>
+<a rel="nofollow" class="external free" href="http://www.google.com">http://www.google.com</a>
+<a rel="nofollow" class="external free" href="gopher://www.google.com">gopher://www.google.com</a>
+<a rel="nofollow" class="external text" href="https://www.google.com">irc://www.google.com</a>
+<a rel="nofollow" class="external text" href="ftp://www.google.com">www.гоогле.цом/фтп://дир</a>
+<a rel="nofollow" class="external text" href="//www.google.com">www.гоогле.цом</a>
+</p>
+!! end
+
 !! test
 Do not convert roman numbers to language variants
 !! options
@@ -12594,7 +12995,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