* item 1
!! endarticle
+!! article
+Template:tbl-start
+!! text
+{|
+!! endarticle
+
+!! article
+Template:tbl-end
+!! text
+|}
+!! endarticle
+
!! article
Template:!
!! text
### Comments
###
!! test
-Comments and Pre
+Comments and Indent-Pre
!! input
<!-- comment 1 --> asdf
!! 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
!!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}}
!!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}}
!!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
!!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}}
!!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
###
!!test
-1a. Pre and Comments
+1a. Indent-Pre and Comments
!!input
a
<!--a-->
!!end
!!test
-1b. Pre and Comments
+1b. Indent-Pre and Comments
!!input
a
<!--a-->
!!end
!!test
-1c. Pre and Comments
+1c. Indent-Pre and Comments
!!input
<!--a--> a
!!end
!!test
-2a. Pre and tables
+2a. Indent-Pre and tables
!!input
{|
|-
!!end
!!test
-2b. Pre and tables
+2b. Indent-Pre and tables
!!input
{|
|-
!!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>
!!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
!!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
###
## 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
!! end
+!! test
+Table td-cell syntax variations
+!! input
+{|
+| foo bar foo | baz
+| foo bar foo || baz
+| style='color:red;' | baz
+| style='color:red;' || baz
+|}
+!! result
+<table>
+<tr>
+<td> baz
+</td>
+<td> foo bar foo </td>
+<td> baz
+</td>
+<td style="color:red;"> baz
+</td>
+<td> style='color:red;' </td>
+<td> baz
+</td></tr></table>
+
+!! end
+
!! test
Simple table
!! input
!! 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
!! 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
###
</p>
!! end
+!! test
+Link with HTML entity in suffix / tail
+!! input
+[[Main Page]]", [[Main Page]]a
+!! result
+<p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>", <a href="/wiki/Main_Page" title="Main Page">Main Page</a>a
+</p>
+!! end
+
!! test
Link with 3 brackets
!! input
!!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
</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
!! 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</includeonly>
+</td>
+<td>d</includeonly></includeonly>
+</td></tr></table>
+
+!!end
+
!! article
Template:Includeonly section
!! text
!!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
|bar
|}
!!result
-<table data-parsoid="{"src":"{|\n|{{echo|foo</table>}}\n|bar\n|}"}" 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>
</tr>
</table>
!!result
-<table data-parsoid="{"src":"<table>\n <tr>\n <td>\n <table>\n <tr>\n <td>1. {{echo|foo </table>}}</td>\n <td> bar </td>\n <td>2. {{echo|baz </table>}}</td>\n </tr>\n <tr>\n <td>abc</td>\n </tr>\n </table>\n </td>\n </tr>\n <tr>\n <td>xyz</td>\n </tr>\n</table>"}" about="#mwt1" typeof="mw:Object/Template">
- <tbody><tr data-parsoid="{"stx":"html"}">
- <td data-parsoid="{"stx":"html"}">
- <table data-parsoid="{"stx":"html"}">
- <tbody><tr data-parsoid="{"stx":"html"}">
- <td data-parsoid="{"stx":"html"}">1. foo </td></tr></tbody></table></td>
- <td data-parsoid="{"stx":"html"}"> bar </td>
- <td data-parsoid="{"stx":"html"}">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">
!! end
+!! test
+Image with width attribute at different positions
+!! input
+[[Image:foobar.jpg|200px|right|Caption]]
+[[Image:foobar.jpg|right|200px|Caption]]
+[[Image:foobar.jpg|right|Caption|200px]]
+!! result
+<div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image" title="Caption"><img alt="Caption" src="http://example.com/images/thumb/3/3a/Foobar.jpg/200px-Foobar.jpg" width="200" height="23" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/300px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/400px-Foobar.jpg 2x" /></a></div>
+<div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image" title="Caption"><img alt="Caption" src="http://example.com/images/thumb/3/3a/Foobar.jpg/200px-Foobar.jpg" width="200" height="23" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/300px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/400px-Foobar.jpg 2x" /></a></div>
+<div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image" title="Caption"><img alt="Caption" src="http://example.com/images/thumb/3/3a/Foobar.jpg/200px-Foobar.jpg" width="200" height="23" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/300px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/400px-Foobar.jpg 2x" /></a></div>
+
+!! end
+
!! test
Image with link parameter, wiki target
!! input
!!end
+###
+### HTML tags and HTML attributes
+###
+
!! test
div with no attributes
!! input
!! end
+# The PHP parser escapes the opening brace to { 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
</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
!! input
[[Foo|<nowiki>Foo''boo''</nowiki>]]
!! result
-<a rel="mw:WikiLink" href="Foo" data-parsoid="{"tsr":[0,7],"contentPos":[5,5],"src":"[[Foo]]","bsp":[0,7],"stx":"simple"}">Foo''boo''</a>
+<a rel="mw:WikiLink" href="Foo">Foo''boo''</a>
!! end
!! test
</p>
!! end
+!! test
+Tag-like HTML structures are passed through as text
+!! input
+<x y>
+
+<x.y>
+
+<x-y>
+
+1>2
+
+x<y
+
+a>b
+
+1<d e>f
+!! result
+<p><x y>
+</p><p><x.y>
+</p><p><x-y>
+</p><p>1>2
+</p><p>x<y
+</p><p>a>b
+</p><p>1<d e>f
+</p>
+!! end
+
+
+# This fails in the PHP parser (see bug 40670,
+# https://bugzilla.wikimedia.org/show_bug.cgi?id=40670), so disabled for it.
+!! test
+Tag names followed by punctuation should not be recognized as tags
+!! options
+disabled
+!! input
+<s.ome> text
+!! result
+<p><s.ome> text
+</p>
+!! end
+
+
TODO:
more images
more tables