Merge "Parser test to test language conversion around HTML tags."
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Fri, 4 Jan 2013 11:48:26 +0000 (11:48 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 4 Jan 2013 11:48:26 +0000 (11:48 +0000)
1  2 
tests/parser/parserTests.txt

@@@ -48,7 -48,7 +48,7 @@@ Template:Blan
  !! endarticle
  
  !! article
 -Template:!
 +Template:pipe
  !! text
  |
  !! endarticle
@@@ -65,61 -65,12 +65,61 @@@ Template:inner lis
  * item 1
  !! endarticle
  
 +!! article
 +Template:tbl-start
 +!! text
 +{|
 +!! endarticle
 +
 +!! article
 +Template:tbl-end
 +!! text
 +|}
 +!! endarticle
 +
 +!! article
 +Template:!
 +!! text
 +|
 +!! endarticle
 +
  !! article
  Template:echo
  !! text
  {{{1}}}
  !! endarticle
  
 +!! article
 +Template:echo_with_span
 +!! text
 +<span>{{{1}}}</span>
 +!! endarticle
 +
 +!! article
 +Template:echo_with_div
 +!! text
 +<div>{{{1}}}</div>
 +!! endarticle
 +
 +!! article
 +Template:attr_str
 +!! text
 +{{{1}}}="{{{2}}}"
 +!! endarticle
 +
 +!! article
 +Template:table_attribs
 +!! text
 +<noinclude>
 +|</noinclude>style="color: red"| Foo
 +!! endarticle
 +
 +!! article
 +A?b
 +!! text
 +Weirdo titles!
 +!! endarticle
 +
  ###
  ### Basic tests
  ###
@@@ -554,7 -505,7 +554,7 @@@ nowiki 
  ### Comments
  ###
  !! test
 -Comments and Pre
 +Comments and Indent-Pre
  !! input
  <!-- comment 1 --> asdf
  
@@@ -805,17 -756,6 +805,17 @@@ And a <a href="/wiki/Main_Page" title="
  </pre>
  !! end
  
 +!! test
 +Ident preformatting with inline content
 +!! input
 + a
 + ''b''
 +!! result
 +<pre>a
 +<i>b</i>
 +</pre>
 +!! end
 +
  !! test
  <pre> with <nowiki> inside (compatibility with 1.6 and earlier)
  !! input
@@@ -950,17 -890,8 +950,17 @@@ Bug 6200: Preformatted in <blockquote
  </p>
  !! end
  
 +!! test
 +</pre> inside nowiki
 +!! input
 +<nowiki></pre></nowiki>
 +!! result
 +<p>&lt;/pre&gt;
 +</p>
 +!! 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}}
  
 +{{echo| foo}}{{echo| bar}}
 +
  {{echo| foo}}
  {{echo| bar}}
  
  !!result
  <pre>foo
  </pre>
 +<pre>foo bar
 +</pre>
  <pre>foo
  bar
  </pre>
  </pre>
  !!end
  
 +!! test
 +Templates: Indent-Pre: 1f: Wrapping should be based on expanded content
 +!! input
 +{{echo| }}a
 +
 +{{echo|
 + }}a
 +
 +{{echo|
 + b}}
 +
 +{{echo|a
 + }}b
 +
 +{{echo|a
 +}} b
 +!!result
 +<pre>a
 +</pre>
 +<p><br />
 +</p>
 +<pre>a
 +</pre>
 +<p><br />
 +</p>
 +<pre>b
 +</pre>
 +<p>a
 +</p>
 +<pre>b
 +</pre>
 +<p>a
 +</p>
 +<pre>b
 +</pre>
 +!!end
 +
 +!! test
 +Templates: Single-line variant of parameter whitespace stripping test
 +!! input
 +{{echo| a}}
 +
 +{{echo|1= a}}
 +
 +{{echo|{{echo| a}}}}
 +
 +{{echo|1={{echo| a}}}}
 +!! result
 +<pre>a
 +</pre>
 +<p>a
 +</p>
 +<pre>a
 +</pre>
 +<p>a
 +</p>
 +!! end
 +
 +!! test
 +Templates: Strip whitespace from named parameters, but not positional ones
 +!! input
 +{{echo|
 + foo}}
 +
 +{{echo|
 +* foo}}
 +
 +{{echo| 1 =
 + foo}}
 +
 +{{echo| 1 =
 +* foo}}
 +!! result
 +<pre>foo
 +</pre>
 +<p><br />
 +</p>
 +<ul><li> foo
 +</li></ul>
 +<p>foo
 +</p>
 +<ul><li> foo
 +</li></ul>
 +
 +!! end
 +
  ###
 -### Parsoid-centric tests for testing RT edge cases
 -### around comments and white-space inside pre blocks
 +### Parsoid-centric tests for testing RT edge cases for pre
  ###
  
  !!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
  
  </pre>
  !!end
  
 +!!test
 +2a. Indent-Pre and tables
 +!!input
 + {|
 + |-
 + !h1!!h2
 + |foo||bar
 + |}
 +!!result
 +<table>
 +
 +<tr>
 +<th>h1</th>
 +<th>h2
 +</th>
 +<td>foo</td>
 +<td>bar
 +</td></tr></table>
 +
 +!!end
 +
 +!!test
 +2b. Indent-Pre and tables
 +!!input
 +  {|
 + |-
 +|foo
 +|}
 +!!result
 +<table>
 +
 +<tr>
 +<td>foo
 +</td></tr></table>
 +
 +!!end
 +
 +!!test
 +3a. Indent-Pre and block tags (single-line html)
 +!!input
 + <p> foo </p>
 + <div> foo </div>
 + <span> foo </span>
 +!!result
 + <p> foo </p>
 + <div> foo </div>
 +<pre><span> foo </span>
 +</pre>
 +!!end
 +
 +!!test
 +3b. Indent-Pre and block tags (pre-content on separate line)
 +!!input
 +<p>
 + foo
 +</p>
 +
 +<div>
 + foo
 +</div>
 +
 +<center>
 + foo
 +</center>
 +
 +<blockquote>
 + foo
 +</blockquote>
 +
 +<table><tr><td>
 + foo
 +</td></tr></table>
 +
 +<ul><li>
 +  foo
 +</li></ul>
 +
 +!!result
 +<p>
 + foo
 +</p>
 +<div>
 +<pre>foo
 +</pre>
 +</div>
 +<center>
 +<pre>foo
 +</pre>
 +</center>
 +<blockquote>
 + foo
 +</blockquote>
 +<table><tr><td>
 +<pre>foo
 +</pre>
 +</td></tr></table>
 +<ul><li>
 +  foo
 +</li></ul>
 +
 +!!end
 +
 +!!test
 +4. Multiple spaces at start-of-line
 +!!input
 +    <p> foo </p>
 +    foo
 +      {|
 +|foo
 +|}
 +!!result
 +    <p> foo </p>
 +<pre>   foo
 +</pre>
 +<table>
 +<tr>
 +<td>foo
 +</td></tr></table>
 +
 +!!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
  ###
@@@ -1469,6 -1116,7 +1469,6 @@@ Definition lists: colon in HTML attribu
  
  !! end
  
 -
  !! test
  Definition lists: self-closed tag
  !! input
  
  !! test
  Bug 11748: Literal closing tags
 -!! options
 -disabled
  !! input
  <dl>
  <dt>test 1</dt>
  <dt>test 2</dt>
  <dd>test test test test test</dd>
  </dl>
 +
  !! end
  
  !! test
  Definition and unordered list using wiki syntax nested in unordered list using html tags.
  !! input
  <ul><li>
 -; term : description 
 +; term : description
  * unordered
  </li>
  </ul>
  !! result
  <ul><li>
 -<dl><dt> term&#160;</dt><dd> description 
 +<dl><dt> term&#160;</dt><dd> description
  </dd></dl>
  <ul><li> unordered
  </li></ul>
  !! end
  
  !! test
 +
  Definition list with empty definition and following paragraph
  !! input
  ; term:
@@@ -1531,26 -1179,9 +1531,26 @@@ Paragraph tex
  !! end
  
  !! test
 -Definition Lists: No nesting: Multiple dd's
 +Nested definition lists using html syntax
  !! input
 -;x
 +<dl><dd>
 +<dl>
 +<dd>Foo</dd>
 +</dl>
 +</dd></dl>
 +!! result
 +<dl><dd>
 +<dl>
 +<dd>Foo</dd>
 +</dl>
 +</dd></dl>
 +
 +!! end
 +
 +!! test
 +Definition Lists: No nesting: Multiple dd's
 +!! input
 +;x
  :a
  :b
  !! result
@@@ -1603,26 -1234,6 +1603,26 @@@ Definition Lists: Indentation: Multi-le
  
  !! end
  
 +!! test
 +Definition Lists: Hacky use to indent tables
 +!! input
 +::{|
 +|foo
 +|bar
 +|}
 +this text
 +should be left alone
 +!! result
 +<dl><dd><dl><dd><table>
 +<tr>
 +<td>foo
 +</td>
 +<td>bar
 +</td></tr></table></dd></dl></dd></dl>
 +<p>this text
 +should be left alone
 +</p>
 +!! end
  ## The PHP parser treats : items (dd) without a corresponding ; item (dt)
  ## as an empty dt item.  It also ignores all but the last ";" when followed
  ## by ":" later on.  So, ";" are not ignored in ";;;t3" but are ignored  in
  ## 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
@@@ -2432,15 -1983,6 +2432,15 @@@ http:/example.co
  </p>
  !! end
  
 +!! test
 +Bracketed external links with template-generated invalid target
 +!! input
 +[{{echo|http:/example.com}} title]
 +!! result
 +<p>[http:/example.com title]
 +</p>
 +!! end
 +
  !! test
  Bug 2702: Mismatched <i>, <b> and <a> tags are invalid
  !! input
@@@ -2612,33 -2154,6 +2612,33 @@@ http://[2404:130:0:1000::187:2]/index.p
  </p>
  !! end
  
 +!! test
 +Non-extlinks in brackets
 +!! input
 +[foo]
 +[foo bar]
 +[foo ''bar'']
 +[fool's] errand
 +[fool's errand]
 +[{{echo|foo}}]
 +[{{echo|foo}} bar]
 +[{{echo|foo}} ''bar'']
 +[{{echo|foo}}l's] errand
 +[{{echo|foo}}l's errand]
 +!! result
 +<p>[foo]
 +[foo bar]
 +[foo <i>bar</i>]
 +[fool's] errand
 +[fool's errand]
 +[foo]
 +[foo bar]
 +[foo <i>bar</i>]
 +[fool's] errand
 +[fool's errand]
 +</p>
 +!! end
 +
  ###
  ### Quotes
  ###
@@@ -2724,37 -2239,12 +2724,37 @@@ A table with nothing but a captio
  
  !! 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
 -{| 
 +{|
  | 1 || 2
 -|- 
 +|-
  | 3 || 4
  |}
  !! result
  
  !! end
  
 +!! test
 +Simple table but with multiple dashes for row wikitext
 +!! input
 +{|
 +| foo
 +|-----
 +| bar
 +|}
 +!! result
 +<table>
 +<tr>
 +<td> foo
 +</td></tr>
 +<tr>
 +<td> bar
 +</td></tr></table>
 +
 +!! end
  !! test
  Multiplication 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
 +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
 +| -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> -1
 +</td></tr></table>
 +
 +!!end
 +
  !! test
  Table rowspan
  !! input
  {| border=1
 -| Cell 1, row 1 
 -|rowspan=2| Cell 2, row 1 (and 2) 
 -| Cell 3, row 1 
 -|- 
 -| Cell 1, row 2 
 -| Cell 3, row 2 
 +| Cell 1, row 1
 +|rowspan=2| Cell 2, row 1 (and 2)
 +| Cell 3, row 1
 +|-
 +| Cell 1, row 2
 +| Cell 3, row 2
  |}
  !! result
  <table border="1">
@@@ -3075,78 -2445,6 +3075,78 @@@ Indented table markup mixed with indent
  
  !! end
  
 +!! test
 +Template-generated table cell attributes and cell content
 +!! input
 +{|
 +|{{table_attribs}}
 +|}
 +!! result
 +<table>
 +<tr>
 +<td style="color: red"> Foo
 +</td></tr></table>
 +
 +!! end
 +
 +!! test
 +Table with row followed by newlines and table heading
 +!! input
 +{|
 +|-
 +
 +! foo
 +|}
 +!! result
 +<table>
 +
 +
 +<tr>
 +<th> foo
 +</th></tr></table>
 +
 +!! end
 +
 +# FIXME: Preserve the attribute properly (with an empty string as value) in
 +# the PHP parser. Parsoid implements the behavior below.
 +!! test
 +Table attributes with empty value
 +!! options
 +disabled
 +!! input
 +{|
 +| style=| hello
 +|}
 +!! result
 +<table>
 +<tr>
 +<td style=""> hello
 +</td></tr></table>
 +
 +!! 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
@@@ -3232,15 -2530,6 +3232,15 @@@ Link with suffi
  </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
@@@ -3437,18 -2726,6 +3437,18 @@@ Plain link to protocol-relative URL wit
  </p>
  !! end
  
 +!! test
 +Plain link to page with question mark in title
 +!! input
 +[[A?b]]
 +
 +[[A?b|Baz]]
 +!! result
 +<p><a href="/wiki/A%3Fb" title="A?b">A?b</a>
 +</p><p><a href="/wiki/A%3Fb" title="A?b">Baz</a>
 +</p>
 +!! end
 +
  
  # I'm fairly sure the expected result here is wrong.
  # We want these to be URL links, not pseudo-pages with URLs for titles....
@@@ -3715,15 -2992,6 +3715,15 @@@ language=l
  </p>
  !! end
  
 +!! test
 +Broken br tag sanitization
 +!! input
 +</br>
 +!! result
 +<p>&lt;/br&gt;
 +</p>
 +!! end
 +
  !! test
  Incorrecly removing closing slashes from correctly formed XHTML
  !! input
@@@ -3839,15 -3107,6 +3839,15 @@@ Horizontal ruler -- <4 dashes render a
  </p>
  !! end
  
 +!! test
 +Horizontal ruler -- Supports content following dashes on same line
 +!! input
 +---- Foo
 +!! result
 +<hr /> Foo
 +
 +!! end
 +
  ###
  ### Block-level elements
  ###
@@@ -4038,72 -3297,13 +4038,72 @@@ Nested lists 8 (multiple nesting transi
  
  !! end
  
 -
  !! test
 -List items are not parsed correctly following a <pre> block (bug 785)
 +1. Lists with start-of-line-transparent tokens before bullets: Comments
  !! input
 -* <pre>foo</pre>
 -* <pre>bar</pre>
 -* zar
 +*foo
 +*<!--cmt-->bar
 +<!--cmt-->*baz
 +!! result
 +<ul><li>foo
 +</li><li>bar
 +</li><li>baz
 +</li></ul>
 +
 +!! end
 +
 +!! test
 +2. Lists with start-of-line-transparent tokens before bullets: Template close
 +!! input
 +*foo {{echo|bar
 +}}*baz
 +!! result
 +<ul><li>foo bar
 +</li><li>baz
 +</li></ul>
 +
 +!! 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
 +List items are not parsed correctly following a <pre> block (bug 785)
 +!! input
 +* <pre>foo</pre>
 +* <pre>bar</pre>
 +* zar
  !! result
  <ul><li> <pre>foo</pre>
  </li><li> <pre>bar</pre>
@@@ -4162,20 -3362,6 +4162,20 @@@ List interrupted by empty line or headi
  
  !!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
@@@ -4622,24 -3808,6 +4622,24 @@@ Nonexistent templat
  </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
@@@ -4843,7 -4011,7 +4843,7 @@@ Template with complex argument
  !! test
  BUG 553: link with two variables in a piped link
  !! input
 -{| 
 +{|
  |[[{{{1}}}|{{{2}}}]]
  |}
  !! result
@@@ -4878,14 -4046,6 +4878,14 @@@ Template parameter as link sourc
  </p>
  !! end
  
 +!!test
 +Template-generated attribute string (k='v')
 +!!input
 +<span {{attr_str|id|v1}}>bar</span>
 +!!result
 +<p><span id="v1">bar</span>
 +</p>
 +!!end
  
  !!article
  Template:paramtest2
@@@ -4951,9 -4111,9 +4951,9 @@@ Template from main namespac
  !! article
  Template:table
  !! text
 -{| 
 +{|
  | 1 || 2
 -|- 
 +|-
  | 3 || 4
  |}
  !! endarticle
@@@ -5006,20 -4166,6 +5006,20 @@@ BUG 41: Template parameters shown as br
  </p>
  !! end
  
 +!! test
 +Template with targets containing wikilinks
 +!! input
 +{{[[foo]]}}
 +
 +{{[[{{echo|foo}}]]}}
 +
 +{{{{echo|[[foo}}]]}}
 +!! result
 +<p>{{<a href="/index.php?title=Foo&amp;action=edit&amp;redlink=1" class="new" title="Foo (page does not exist)">foo</a>}}
 +</p><p>{{<a href="/index.php?title=Foo&amp;action=edit&amp;redlink=1" class="new" title="Foo (page does not exist)">foo</a>}}
 +</p><p>{{[[foo}}]]
 +</p>
 +!! end
  
  !! article
  Template:MSGNW test
@@@ -5109,13 -4255,6 +5109,13 @@@ Foo<noinclude>zar</noinclude><includeon
  </p>
  !! end
  
 +!! test
 +Un-closed <noinclude>
 +!! input
 +<noinclude>
 +!! result
 +!! end
 +
  !! test
  <onlyinclude> on a page
  !! input
  </p>
  !! end
  
 +!! test
 +Un-closed <onlyinclude>
 +!! input
 +<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
@@@ -5224,25 -4322,9 +5224,25 @@@ section=
  ==Section 1==
  !! end
  
 +!! test
 +Un-closed <includeonly>
 +!! input
 +<includeonly>
 +!! result
 +!! end
 +
  ###
  ### <includeonly> and <noinclude> in attributes
  ###
 +!!test
 +0. 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
  1. includeonly in html attr key
  !!input
@@@ -5514,7 -4596,7 +5514,7 @@@ Templates: HTML Tag: 6. Generation of e
  !!end
  
  !!test
 -Templates: Tables: 1. Generating start of a HTML table
 +Templates: HTML Tables: 1. Generating start of a HTML table
  !!input
  {{echo|<table><tr><td>foo</td>}}</tr></table>
  !!result
  !!end
  
  !!test
 -Templates: Tables: 2a. Generating middle of a HTML table
 +Templates: HTML Tables: 2a. Generating middle of a HTML table
  !!input
  <table><tr>{{echo|<td>foo</td>}}</tr></table>
  !!result
  !!end
  
  !!test
 -Templates: Tables: 2b. Generating middle of a HTML table
 +Templates: HTML Tables: 2b. Generating middle of a HTML table
  !!input
  <table>{{echo|<tr><td>foo</td></tr>}}</table>
  !!result
  !!end
  
  !!test
 -Templates: Tables: 3. Generating end of a HTML table
 +Templates: HTML Tables: 3. Generating end of a HTML table
  !!input
  <table><tr>{{echo|<td>foo</td></tr></table>}}
  !!result
  !!end
  
  !!test
 -Templates: Tables: 4a. Generating a single tag of a HTML table
 +Templates: HTML Tables: 4a. Generating a single tag of a HTML table
  !!input
  {{echo|<table>}}<tr><td>foo</td></tr></table>
  !!result
  !!end
  
  !!test
 -Templates: Tables: 4b. Generating a single tag of a HTML table
 +Templates: HTML Tables: 4b. Generating a single tag of a HTML table
  !!input
  <table>{{echo|<tr>}}<td>foo</td></tr></table>
  !!result
  !!end
  
  !!test
 -Templates: Tables: 4c. Generating a single tag of a HTML table
 +Templates: HTML Tables: 4c. Generating a single tag of a HTML table
  !!input
  <table><tr>{{echo|<td>}}foo</td></tr></table>
  !!result
  !!end
  
  !!test
 -Templates: Tables: 4d. Generating a single tag of a HTML table
 +Templates: HTML Tables: 4d. Generating a single tag of a HTML table
  !!input
  <table><tr><td>foo{{echo|</td>}}</tr></table>
  !!result
  !!end
  
  !!test
 -Templates: Tables: 4e. Generating a single tag of a HTML table
 +Templates: HTML Tables: 4e. Generating a single tag of a HTML table
  !!input
  <table><tr><td>foo</td>{{echo|</tr>}}</table>
  !!result
  !!end
  
  !!test
 -Templates: Tables: 4f. Generating a single tag of a HTML table
 +Templates: HTML Tables: 4f. Generating a single tag of a HTML table
  !!input
  <table><tr><td>foo</td></tr>{{echo|</table>}}
  !!result
  
  !!end
  
 +!!test
 +Templates: Wiki Tables: 1. Fostering of entire template content
 +!!input
 +{|
 +{{echo|a}}
 +|}
 +!!result
 +<table>
 +a
 +<tr><td></td></tr></table>
 +
 +!!end
 +
 +!!test
 +Templates: Wiki Tables: 2. Fostering of partial template content
 +!!input
 +{|
 +{{echo|a
 +<div>b</div>}}
 +|}
 +!!result
 +<table>
 +a
 +<div>b</div>
 +<tr><td></td></tr></table>
 +
 +!!end
 +
 +!!test
 +Templates: Wiki Tables: 3. td-content via multiple templates
 +!!input
 +{|
 +{{echo|{{pipe}}a}}{{echo|b}}
 +|}
 +!!result
 +<table>
 +<tr>
 +<td>ab
 +</td></tr></table>
 +
 +!!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
 +*{{echo|a {{nonexistent|
 +unused}}}}
 +*{{echo|b {{nonexistent|
 +unused}}}}
 +!!result
 +<ul><li>a <a href="/index.php?title=Template:Nonexistent&amp;action=edit&amp;redlink=1" class="new" title="Template:Nonexistent (page does not exist)">Template:Nonexistent</a>
 +</li><li>b <a href="/index.php?title=Template:Nonexistent&amp;action=edit&amp;redlink=1" class="new" title="Template:Nonexistent (page does not exist)">Template:Nonexistent</a>
 +</li></ul>
 +
 +!!end
 +
 +!!test
 +Templates: Ugly nesting: 1. Quotes opened/closed across templates (echo)
 +!!input
 +{{echo|''a}}{{echo|b''c''d}}{{echo|''e}}
 +!!result
 +<p><i>ab</i>c<i>d</i>e
 +</p>
 +!!end
 +
 +!!test
 +Templates: Ugly nesting: 2. Quotes opened/closed across templates (echo_with_span)
 +(PHP parser generates misnested html)
 +!! options
 +disabled
 +!!input
 +{{echo_with_span|''a}}{{echo_with_span|b''c''d}}{{echo_with_span|''e}}
 +!!result
 +<p><span><i>a</i></span><i><span>b</span></i><span>c</span><i>d</i><span>e</span></p>
 +!!end
 +
 +!!test
 +Templates: Ugly nesting: 3. Quotes opened/closed across templates (echo_with_div)
 +(PHP parser generates misnested html)
 +!! options
 +disabled
 +!!input
 +{{echo_with_div|''a}}{{echo_with_div|b''c''d}}{{echo_with_div|''e}}
 +!!result
 +<div><i>a</i></div>
 +<div><i>b</i>c<i>d</i></div>
 +<div>e</div>
 +!!end
 +
 +!!test
 +Templates: Ugly nesting: 4. Divs opened/closed across templates
 +!!input
 +a<div>b{{echo|c</div>d}}e
 +!!result
 +a<div>bc</div>de
 +
 +!!end
 +
 +!!test
 +Templates: Ugly templates: 1. Navbox template parses badly leading to table misnesting
 +(Parsoid-centric)
 +!! options
 +disabled
 +!!input
 +{|
 +|{{echo|foo</table>}}
 +|bar
 +|}
 +!!result
 +<table  about="#mwt1" typeof="mw:Object/Template ">
 +<tbody><tr><td>foo</td></tr></tbody></table><span about="#mwt1">
 +bar</span><span about="#mwt1">
 +</span>
 +!!end
 +
 +!!test
 +Templates: Ugly templates: 2. Navbox template parses badly leading to table misnesting
 +(Parsoid-centric)
 +!! options
 +disabled
 +!!input
 +<table>
 +  <tr>
 +    <td>
 +    <table>
 +      <tr>
 +        <td>1. {{echo|foo </table>}}</td>
 +        <td> bar </td>
 +        <td>2. {{echo|baz </table>}}</td>
 +      </tr>
 +      <tr>
 +        <td>abc</td>
 +      </tr>
 +    </table>
 +    </td>
 +  </tr>
 +  <tr>
 +    <td>xyz</td>
 +  </tr>
 +</table>
 +!!result
 +<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">
 +      </span><span about="#mwt1">
 +    </span><span about="#mwt1">
 +    </span><span about="#mwt1">
 +  </span><span about="#mwt1">
 +  
 +    xyz</span><span about="#mwt1">
 +  </span><span about="#mwt1">
 +</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
@@@ -6505,73 -5364,28 +6505,73 @@@ Image with captio
  !! end
  
  !! test
 -Image with link parameter, wiki target
 +Image with empty attribute
  !! input
 -[[Image:foobar.jpg|link=Target page]]
 +[[Image:foobar.jpg|right||Caption text]]
  !! result
 -<p><a href="/wiki/Target_page" title="Target page"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
 -</p>
 +<div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image" title="Caption text"><img alt="Caption text" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a></div>
 +
  !! end
  
  !! test
 -Image with link parameter, URL target
 +Image with link tails
  !! input
 -[[Image:foobar.jpg|link=http://example.com/]]
 +123[[Image:foobar.jpg]]456
 +123[[Image:foobar.jpg|right]]456
 +123[[Image:foobar.jpg|thumb]]456
  !! result
 -<p><a href="http://example.com/" rel="nofollow"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
 +<p>123<a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>456
  </p>
 +123<div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a></div>456
 +123<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a>  <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div></div></div></div>456
 +
  !! end
  
  !! test
 -Image with link parameter, wgExternalLinkTarget
 +Image with multiple captions -- only last one is accepted
  !! input
 -[[Image:foobar.jpg|link=http://example.com/]]
 -!! config
 +[[Image:foobar.jpg|right|Caption1 - ignored|[[Caption2]] - ignored|Caption3 - accepted]]
 +!! result
 +<div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image" title="Caption3 - accepted"><img alt="Caption3 - accepted" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a></div>
 +
 +!! 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
 +[[Image:foobar.jpg|link=Target page]]
 +!! result
 +<p><a href="/wiki/Target_page" title="Target page"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
 +</p>
 +!! end
 +
 +!! test
 +Image with link parameter, URL target
 +!! input
 +[[Image:foobar.jpg|link=http://example.com/]]
 +!! result
 +<p><a href="http://example.com/" rel="nofollow"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
 +</p>
 +!! end
 +
 +!! test
 +Image with link parameter, wgExternalLinkTarget
 +!! input
 +[[Image:foobar.jpg|link=http://example.com/]]
 +!! config
  wgExternalLinkTarget='foobar'
  !! result
  <p><a href="http://example.com/" target="foobar" rel="nofollow"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
@@@ -6643,7 -5457,7 +6643,7 @@@ Thumbnail image with link paramete
  !! input
  [[Image:foobar.jpg|thumb|link=http://example.com/|Title]]
  !! result
 -<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="http://example.com/"><img alt="" src="http://example.com/images/3/3a/Foobar.jpg" width="180" height="20" class="thumbimage" /></a>  <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>Title</div></div></div>
 +<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="http://example.com/"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a>  <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>Title</div></div></div>
  
  !! end
  
@@@ -6717,7 -5531,7 +6717,7 @@@ Thumbnail image caption with a free UR
  !! input
  [[Image:foobar.jpg|thumb|http://example.com]]
  !! result
 -<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/3/3a/Foobar.jpg" width="180" height="20" class="thumbimage" /></a>  <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a></div></div></div>
 +<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a>  <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a></div></div></div>
  
  !! end
  
@@@ -6726,7 -5540,7 +6726,7 @@@ Thumbnail image caption with a free UR
  !! input
  [[Image:foobar.jpg|thumb|http://example.com|alt=Alteration]]
  !! result
 -<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Alteration" src="http://example.com/images/3/3a/Foobar.jpg" width="180" height="20" class="thumbimage" /></a>  <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a></div></div></div>
 +<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Alteration" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a>  <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a></div></div></div>
  
  !! end
  
@@@ -6735,7 -5549,7 +6735,7 @@@ BUG 1887: A ISBN with a thumbnai
  !! input
  [[Image:foobar.jpg|thumb|ISBN 1235467890]]
  !! result
 -<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/3/3a/Foobar.jpg" width="180" height="20" class="thumbimage" /></a>  <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div><a href="/wiki/Special:BookSources/1235467890" class="internal mw-magiclink-isbn">ISBN 1235467890</a></div></div></div>
 +<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a>  <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div><a href="/wiki/Special:BookSources/1235467890" class="internal mw-magiclink-isbn">ISBN 1235467890</a></div></div></div>
  
  !! end
  
@@@ -6744,7 -5558,7 +6744,7 @@@ BUG 1887: A RFC with a thumbnai
  !! input
  [[Image:foobar.jpg|thumb|This is RFC 12354]]
  !! result
 -<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/3/3a/Foobar.jpg" width="180" height="20" class="thumbimage" /></a>  <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>This is <a class="external mw-magiclink-rfc" href="//tools.ietf.org/html/rfc12354">RFC 12354</a></div></div></div>
 +<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a>  <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>This is <a class="external mw-magiclink-rfc" href="//tools.ietf.org/html/rfc12354">RFC 12354</a></div></div></div>
  
  !! end
  
@@@ -6753,7 -5567,7 +6753,7 @@@ BUG 1887: A mailto link with a thumbnai
  !! input
  [[Image:foobar.jpg|thumb|Please mailto:nobody@example.com]]
  !! result
 -<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/3/3a/Foobar.jpg" width="180" height="20" class="thumbimage" /></a>  <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>Please <a rel="nofollow" class="external free" href="mailto:nobody@example.com">mailto:nobody@example.com</a></div></div></div>
 +<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a>  <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>Please <a rel="nofollow" class="external free" href="mailto:nobody@example.com">mailto:nobody@example.com</a></div></div></div>
  
  !! end
  
@@@ -6826,7 -5640,7 +6826,7 @@@ Image caption containing another imag
  !! input
  [[Image:Foobar.jpg|thumb|This is a caption with another [[Image:icon.png|image]] inside it!]]
  !! result
 -<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/3/3a/Foobar.jpg" width="180" height="20" class="thumbimage" /></a>  <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>This is a caption with another <a href="/index.php?title=Special:Upload&amp;wpDestFile=Icon.png" class="new" title="File:Icon.png">image</a> inside it!</div></div></div>
 +<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a>  <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>This is a caption with another <a href="/index.php?title=Special:Upload&amp;wpDestFile=Icon.png" class="new" title="File:Icon.png">image</a> inside it!</div></div></div>
  
  !! end
  
@@@ -6846,7 -5660,7 +6846,7 @@@ Bug 3090: External links other than htt
  !! input
  [[Image:Foobar.jpg|thumb|200px|This caption has [irc://example.net irc] and [https://example.com Secure] ext links in it.]]
  !! result
 -<div class="thumb tright"><div class="thumbinner" style="width:202px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/3/3a/Foobar.jpg" width="200" height="23" class="thumbimage" /></a>  <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>This caption has <a rel="nofollow" class="external text" href="irc://example.net">irc</a> and <a rel="nofollow" class="external text" href="https://example.com">Secure</a> ext links in it.</div></div></div>
 +<div class="thumb tright"><div class="thumbinner" style="width:202px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/200px-Foobar.jpg" width="200" height="23" class="thumbimage" 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 class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>This caption has <a rel="nofollow" class="external text" href="irc://example.net">irc</a> and <a rel="nofollow" class="external text" href="https://example.com">Secure</a> ext links in it.</div></div></div>
  
  !! end
  
  [[Category:Foo (bar)|Foo]]
  !! end
  
 +!! test
 +Category with link tail
 +!! options
 +cat
 +pst
 +!! input
 +123[[Category:Foo]]456
 +!! result
 +123[[Category:Foo]]456
 +!! end
 +
 +!! test
 +Category with template
 +!! options
 +cat
 +pst
 +!! input
 +[[Category:{{echo|Foo}}]]
 +!! result
 +[[Category:{{echo|Foo}}]]
 +!! end
 +
 +!! test
 +Category with template in sort key
 +!! options
 +cat
 +pst
 +!! input
 +[[Category:Foo|{{echo|Bar}}]]
 +!! result
 +[[Category:Foo|{{echo|Bar}}]]
 +!! end
 +
 +!! test
 +Category with template in sort key and title
 +!! options
 +cat
 +pst
 +!! input
 +[[Category:{{echo|Foo}}|{{echo|Bar}}]]
 +!! result
 +[[Category:{{echo|Foo}}|{{echo|Bar}}]]
 +!! end
 +
 +!! test
 +Category / paragraph interactions
 +!! input
 +Foo [[Category:Baz]] Bar
 +
 +Foo [[Category:Baz]]
 +Bar
 +
 +Foo
 +[[Category:Baz]]
 +Bar
 +
 +Foo
 +[[Category:Baz]] Bar
 +
 +Foo
 +[[Category:Baz]]
 + [[Category:Baz]]
 +[[Category:Baz]]
 +Bar
 +
 +[[Category:Baz]]
 + [[Category:Baz]]
 +[[Category:Baz]]
 +
 +[[Category:Baz]]
 + {{echo|[[Category:Baz]]}}
 +[[Category:Baz]]
 +!! result
 +<p>Foo Bar
 +</p><p>Foo
 +Bar
 +</p><p>Foo
 +Bar
 +</p><p>Foo Bar
 +</p><p>Foo
 +Bar
 +</p>
 +!! end
 +
  ###
  ### Inter-language links
  ###
@@@ -7584,10 -6314,6 +7584,10 @@@ Namespaced link must have a title (bad 
  !!end
  
  
 +###
 +### HTML tags and HTML attributes
 +###
 +
  !! test
  div with no attributes
  !! input
@@@ -7633,49 -6359,6 +7633,49 @@@ div with illegal double attribute
  
  !!end
  
 +# FIXME: produce empty string instead of "class" in the PHP parser, following
 +# the HTML5 spec.
 +!! test
 +div with empty attribute value, space before equals
 +!! options
 +disabled
 +!! input
 +<div class =>HTML rocks</div>
 +!! result
 +<div class="">HTML rocks</div>
 +
 +!! 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
 +# attribute completely if the space is missing. We hope that not much content
 +# depends on this, so are implementing the behavior below in Parsoid for
 +# consistencies' sake. Disabled for the PHP parser. 
 +# FIXME: fix this behavior in the PHP parser?
 +!! test
 +div with empty attribute value, no space before equals
 +!! options
 +disabled
 +!! input
 +<div class=>HTML rocks</div>
 +!! result
 +<div class="">HTML rocks</div>
 +
 +!! end
 +
  !! test
  HTML multiple attributes correction
  !! input
@@@ -7708,23 -6391,6 +7708,23 @@@ DIV IN UPPERCAS
  
  !!end
  
 +!! test
 +Non-ASCII pseudo-tags are rendered as text
 +!! input
 +<khyô>
 +!! result
 +<p>&lt;khyô&gt;
 +</p>
 +!! end
 +
 +!! test
 +Pseudo-tag with URL 'name' renders as url link
 +!! input
 +<http://example.com/>
 +!! result
 +<p>&lt;<a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a>&gt;
 +</p>
 +!! end
  
  !! test
  text with amp in the middle of nowhere
@@@ -8237,9 -6903,9 +8237,9 @@@ Parser hook: empty inpu
  <tag></tag>
  !! result
  <pre>
 -string(0) ""
 -array(0) {
 -}
 +''
 +array (
 +)
  </pre>
  
  !! end
@@@ -8251,8 -6917,8 +8251,8 @@@ Parser hook: empty input using terminat
  !! result
  <pre>
  NULL
 -array(0) {
 -}
 +array (
 +)
  </pre>
  
  !! end
@@@ -8264,8 -6930,8 +8264,8 @@@ Parser hook: empty input using terminat
  !! result
  <pre>
  NULL
 -array(0) {
 -}
 +array (
 +)
  </pre>
  
  !! end
@@@ -8276,9 -6942,9 +8276,9 @@@ Parser hook: basic inpu
  <tag>input</tag>
  !! result
  <pre>
 -string(5) "input"
 -array(0) {
 -}
 +'input'
 +array (
 +)
  </pre>
  
  !! end
@@@ -8290,9 -6956,9 +8290,9 @@@ Parser hook: case insensitiv
  <TAG>input</TAG>
  !! result
  <pre>
 -string(5) "input"
 -array(0) {
 -}
 +'input'
 +array (
 +)
  </pre>
  
  !! end
@@@ -8304,9 -6970,9 +8304,9 @@@ Parser hook: case insensitive, redu
  <TaG>input</TAg>
  !! result
  <pre>
 -string(5) "input"
 -array(0) {
 -}
 +'input'
 +array (
 +)
  </pre>
  
  !! end
@@@ -8319,9 -6985,9 +8319,9 @@@ noxm
  <tag><tag></tag></tag>
  !! result
  <pre>
 -string(5) "<tag>"
 -array(0) {
 -}
 +'<tag>'
 +array (
 +)
  </pre>&lt;/tag&gt;
  
  !! end
@@@ -8332,13 -6998,17 +8332,13 @@@ Parser hook: basic argument
  <tag width=200 height = "100" depth = '50' square></tag>
  !! result
  <pre>
 -string(0) ""
 -array(4) {
 -  ["width"]=>
 -  string(3) "200"
 -  ["height"]=>
 -  string(3) "100"
 -  ["depth"]=>
 -  string(2) "50"
 -  ["square"]=>
 -  string(6) "square"
 -}
 +''
 +array (
 +  'width' => '200',
 +  'height' => '100',
 +  'depth' => '50',
 +  'square' => 'square',
 +)
  </pre>
  
  !! end
@@@ -8349,10 -7019,11 +8349,10 @@@ Parser hook: argument containing a forw
  <tag filename='/tmp/bla'></tag>
  !! result
  <pre>
 -string(0) ""
 -array(1) {
 -  ["filename"]=>
 -  string(8) "/tmp/bla"
 -}
 +''
 +array (
 +  'filename' => '/tmp/bla',
 +)
  </pre>
  
  !! end
@@@ -8364,9 -7035,10 +8364,9 @@@ Parser hook: empty input using terminat
  !! result
  <pre>
  NULL
 -array(1) {
 -  ["foo"]=>
 -  string(3) "bar"
 -}
 +array (
 +  'foo' => 'bar',
 +)
  </pre>text
  
  !! end
@@@ -8381,12 -7053,16 +8381,12 @@@ other stuf
  !! result
  <pre>
  NULL
 -array(4) {
 -  ["width"]=>
 -  string(3) "200"
 -  ["height"]=>
 -  string(3) "100"
 -  ["depth"]=>
 -  string(2) "50"
 -  ["square"]=>
 -  string(6) "square"
 -}
 +array (
 +  'width' => '200',
 +  'height' => '100',
 +  'depth' => '50',
 +  'square' => 'square',
 +)
  </pre>
  <p>other stuff
  &lt;/tag&gt;
@@@ -8511,30 -7187,6 +8511,30 @@@ disable
  Something need to be done. foo-2 ? 
  !! end
  
 +!! test
 +Sanitizer: Validating that <meta> and <link> work, but only for Microdata
 +!! input
 +<div itemscope>
 +      <meta itemprop="hello" content="world">
 +      <meta http-equiv="refresh" content="5">
 +      <meta itemprop="hello" http-equiv="refresh" content="5">
 +      <link itemprop="hello" href="{{SERVER}}">
 +      <link rel="stylesheet" href="{{SERVER}}">
 +      <link rel="stylesheet" itemprop="hello" href="{{SERVER}}">
 +</div>
 +!! result
 +<div itemscope="itemscope">
 +<p>   <meta itemprop="hello" content="world" />
 +      &lt;meta http-equiv="refresh" content="5"&gt;
 +      <meta itemprop="hello" content="5" />
 +</p>
 +      <link itemprop="hello" href="http&#58;//Britney-Spears" />
 +      &lt;link rel="stylesheet" href="<a rel="nofollow" class="external free" href="http://Britney-Spears">http://Britney-Spears</a>"&gt;
 +      <link itemprop="hello" href="http&#58;//Britney-Spears" />
 +</div>
 +
 +!! end
 +
  !! test
  Language converter: output gets cut off unexpectedly (bug 5757)
  !! options
@@@ -10138,19 -8790,19 +10138,19 @@@ image:foobar.jpg|Blabla|alt=This is a f
                        </div>
                </div></li>
                <li class="gallerybox" style="width: 105px"><div style="width: 105px">
 -                      <div class="thumb" style="width: 100px;"><div style="margin:31px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/3/3a/Foobar.jpg" width="70" height="8" /></a></div></div>
 +                      <div class="thumb" style="width: 100px;"><div style="margin:31px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/70px-Foobar.jpg" width="70" height="8" /></a></div></div>
                        <div class="gallerytext">
  <p>some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
  </p>
                        </div>
                </div></li>
                <li class="gallerybox" style="width: 105px"><div style="width: 105px">
 -                      <div class="thumb" style="width: 100px;"><div style="margin:31px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="70" height="8" /></a></div></div>
 +                      <div class="thumb" style="width: 100px;"><div style="margin:31px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/70px-Foobar.jpg" width="70" height="8" /></a></div></div>
                        <div class="gallerytext">
                        </div>
                </div></li>
                <li class="gallerybox" style="width: 105px"><div style="width: 105px">
 -                      <div class="thumb" style="width: 100px;"><div style="margin:31px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="This is a foo-bar." src="http://example.com/images/3/3a/Foobar.jpg" width="70" height="8" /></a></div></div>
 +                      <div class="thumb" style="width: 100px;"><div style="margin:31px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="This is a foo-bar." src="http://example.com/images/thumb/3/3a/Foobar.jpg/70px-Foobar.jpg" width="70" height="8" /></a></div></div>
                        <div class="gallerytext">
  <p>Blabla|blabla.
  </p>
@@@ -10170,14 -8822,14 +10170,14 @@@ File:foobar.jpg|{{Test|unamedParam|alt=
  !! result
  <ul class="gallery">
                <li class="gallerybox" style="width: 155px"><div style="width: 155px">
 -                      <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="galleryalt" src="http://example.com/images/3/3a/Foobar.jpg" width="120" height="14" /></a></div></div>
 +                      <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="galleryalt" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" /></a></div></div>
                        <div class="gallerytext">
 -<p><a href="/wiki/File:Foobar.jpg" class="image" title="desc"><img alt="inneralt" src="http://example.com/images/3/3a/Foobar.jpg" width="20" height="2" /></a>
 +<p><a href="/wiki/File:Foobar.jpg" class="image" title="desc"><img alt="inneralt" src="http://example.com/images/thumb/3/3a/Foobar.jpg/20px-Foobar.jpg" width="20" height="2" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/30px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/40px-Foobar.jpg 2x" /></a>
  </p>
                        </div>
                </div></li>
                <li class="gallerybox" style="width: 155px"><div style="width: 155px">
 -                      <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="galleryalt" src="http://example.com/images/3/3a/Foobar.jpg" width="120" height="14" /></a></div></div>
 +                      <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="galleryalt" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" /></a></div></div>
                        <div class="gallerytext">
  <p>This is a test template
  </p>
@@@ -10214,7 -8866,7 +10214,7 @@@ captio
                        </div>
                </div></li>
                <li class="gallerybox" style="width: 155px"><div style="width: 155px">
 -                      <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/3/3a/Foobar.jpg" width="120" height="14" /></a></div></div>
 +                      <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" /></a></div></div>
                        <div class="gallerytext">
  <p><a href="/wiki/File:Foobar.jpg" title="File:Foobar.jpg">Foobar.jpg</a><br />
  some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
                        </div>
                </div></li>
                <li class="gallerybox" style="width: 155px"><div style="width: 155px">
 -                      <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="120" height="14" /></a></div></div>
 +                      <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" /></a></div></div>
                        <div class="gallerytext">
  <p><a href="/wiki/File:Foobar.jpg" title="File:Foobar.jpg">Foobar.jpg</a><br />
  </p>
@@@ -10254,12 -8906,12 +10254,12 @@@ foobar.jp
                        </div>
                </div></li>
                <li class="gallerybox" style="width: 155px"><div style="width: 155px">
 -                      <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="120" height="14" /></a></div></div>
 +                      <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" /></a></div></div>
                        <div class="gallerytext">
                        </div>
                </div></li>
                <li class="gallerybox" style="width: 155px"><div style="width: 155px">
 -                      <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="120" height="14" /></a></div></div>
 +                      <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" /></a></div></div>
                        <div class="gallerytext">
                        </div>
                </div></li>
@@@ -10390,7 -9042,7 +10390,7 @@@ Width + Height sized image (using px) (
  !! input
  [[Image:foobar.jpg|640x480px]]
  !! result
 -<p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="640" height="73" /></a>
 +<p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/640px-Foobar.jpg" width="640" height="73" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/960px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/1280px-Foobar.jpg 2x" /></a>
  </p>
  !!end
  
@@@ -10399,7 -9051,7 +10399,7 @@@ Width-sized image (using px, no followi
  !! input
  [[Image:foobar.jpg|640px]]
  !! result
 -<p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="640" height="73" /></a>
 +<p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/640px-Foobar.jpg" width="640" height="73" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/960px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/1280px-Foobar.jpg 2x" /></a>
  </p>
  !!end
  
@@@ -10408,7 -9060,7 +10408,7 @@@ Width-sized image (using px, with follo
  !! input
  [[Image:foobar.jpg|640px ]]
  !! result
 -<p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="640" height="73" /></a>
 +<p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/640px-Foobar.jpg" width="640" height="73" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/960px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/1280px-Foobar.jpg 2x" /></a>
  </p>
  !!end
  
@@@ -10417,7 -9069,7 +10417,7 @@@ Width-sized image (using px, with prece
  !! input
  [[Image:foobar.jpg| 640px]]
  !! result
 -<p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="640" height="73" /></a>
 +<p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/640px-Foobar.jpg" width="640" height="73" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/960px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/1280px-Foobar.jpg 2x" /></a>
  </p>
  !!end
  
@@@ -10457,7 -9109,7 +10457,7 @@@ Images with the "|" character in the co
  !! input
  [[image:Foobar.jpg|thumb|An [http://test/?param1=|left|&param2=|x external] URL]]
  !! result
 -<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/3/3a/Foobar.jpg" width="180" height="20" class="thumbimage" /></a>  <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>An <a rel="nofollow" class="external text" href="http://test/?param1=%7Cleft%7C&amp;param2=%7Cx">external</a> URL</div></div></div>
 +<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a>  <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>An <a rel="nofollow" class="external text" href="http://test/?param1=%7Cleft%7C&amp;param2=%7Cx">external</a> URL</div></div></div>
  
  !!end
  
@@@ -10967,6 -9619,20 +10967,20 @@@ language=zh variant=zh-t
  !! 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
  </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
@@@ -11071,29 -9723,6 +11085,29 @@@ Nested: -{zh-hans:Hi -{zh-cn:China;zh-s
  </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
@@@ -11144,29 -9773,6 +11158,29 @@@ Bug 529: Uncovered bulle
  
  !! end
  
 +# Plain MediaWiki does not remove empty lists, but tidy actually does.
 +# Templates in Wikipedia rely on this behavior, as tidy has always been
 +# enabled there. These tests are normally run *without* tidy, so specify the
 +# full output here. 
 +# To test realistic parsing behavior, apply a tidy-like transformation to both
 +# the expected output and your parser's output.
 +!! test
 +Bug 529: Uncovered bullet leaving empty list, normally removed by tidy
 +!! input
 +******* Foo {{bullet}}
 +!! result
 +<ul><li><ul><li><ul><li><ul><li><ul><li><ul><li><ul><li> Foo 
 +</li></ul>
 +</li></ul>
 +</li></ul>
 +</li></ul>
 +</li></ul>
 +</li></ul>
 +</li><li> Bar
 +</li></ul>
 +
 +!! end
 +
  !! test
  Bug 529: Uncovered table already at line-start
  !! input
@@@ -11511,7 -10117,7 +11525,7 @@@ Free external link invading image capti
  !! input
  [[Image:Foobar.jpg|thumb|http://x|hello]]
  !! result
 -<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/3/3a/Foobar.jpg" width="180" height="20" class="thumbimage" /></a>  <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>hello</div></div></div>
 +<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a>  <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>hello</div></div></div>
  
  !! end
  
@@@ -12062,6 -10668,22 +12076,6 @@@ Bug 31098 Template which includes syste
  </p>
  !! end
  
 -!! test
 -Deprecated presentational attributes are converted to css
 -!! input
 -{|
 -| valign=top align=left width=100 height=25% | Asdf
 -|}
 -<ul type="disc"></ul>
 -!! result
 -<table>
 -<tr>
 -<td style="text-align: left; height: 25%; vertical-align: top; width: 100px;"> Asdf
 -</td></tr></table>
 -<ul style="list-style-type: disc;"></ul>
 -
 -!! end
 -
  !! test
  Bug31490 Turkish: ucfirst 'blah'
  !! options
@@@ -12418,7 -11040,7 +12432,7 @@@ File:foobar.jpg|caption|alt=galleryalt|
  !! result
  <ul class="gallery">
                <li class="gallerybox" style="width: 155px"><div style="width: 155px">
 -                      <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/InterWikiLink"><img alt="galleryalt" src="http://example.com/images/3/3a/Foobar.jpg" width="120" height="14" /></a></div></div>
 +                      <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/InterWikiLink"><img alt="galleryalt" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" /></a></div></div>
                        <div class="gallerytext">
  <p>caption
  </p>
@@@ -12437,7 -11059,7 +12451,7 @@@ File:foobar.jpg|caption|alt=galleryalt|
  !! result
  <ul class="gallery">
                <li class="gallerybox" style="width: 155px"><div style="width: 155px">
 -                      <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="http://www.example.org"><img alt="galleryalt" src="http://example.com/images/3/3a/Foobar.jpg" width="120" height="14" /></a></div></div>
 +                      <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="http://www.example.org"><img alt="galleryalt" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" /></a></div></div>
                        <div class="gallerytext">
  <p>caption
  </p>
@@@ -12456,7 -11078,7 +12470,7 @@@ File:foobar.jpg|caption|alt=galleryalt|
  !! result
  <ul class="gallery">
                <li class="gallerybox" style="width: 155px"><div style="width: 155px">
 -                      <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/%22_onclick%3D%22alert(%27malicious_javascript_code!%27);"><img alt="galleryalt" src="http://example.com/images/3/3a/Foobar.jpg" width="120" height="14" /></a></div></div>
 +                      <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/%22_onclick%3D%22alert(%27malicious_javascript_code!%27);"><img alt="galleryalt" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" /></a></div></div>
                        <div class="gallerytext">
  <p>caption
  </p>
@@@ -12517,797 -11139,44 +12531,797 @@@ HttP://MediaWiki.Org
  ### Parsoids-specific tests
  ### Parsoid-PHP parser incompatibilities
  ###
 -
  !!test
 -1. includeonly around the entire attribute
 +1. SOL-sensitive wikitext tokens as template-args
  !!options
  disabled
  !!input
 -<span <includeonly>id="v1"</includeonly><noinclude>id="v2"</noinclude>>bar</span>
 +{{echo|*a}}
 +{{echo|#a}}
 +{{echo|:a}}
  !!result
 -<p><span>bar</span>
 +<p>*a
 +#a
 +:a
  </p>
  !!end
  
 -!!test
 -2. template around the entire attribute
 -!!options
 -disabled
 -!!input
 -<span {{echo|id="v1"}}>bar</span>
 -!!result
 -<p><span>bar</span>
 +#### The following section of tests are primarily to test
 +#### wikitext escaping capabilities of Parsoid.
 +#### A lot of the tests are disabled for the PHP parser either
 +#### because of minor newline diffs or other reasons.
 +#### As Parsoid serializer can handle newlines and other HTML
 +#### more robustly, some of these tests might get reenabled
 +#### for the PHP parser.
 +
 +#### --------------- Headings ---------------
 +#### 0. Unnested
 +#### 1. Nested inside html <h1>=foo=</h1>
 +#### 2. Outside heading nest on a single line <h1>foo</h1>*bar
 +#### 3. Nested inside html with wikitext split by html tags
 +#### 4. No escape needed
 +#### 5. Empty headings <h1></h1>
 +#### 6. Heading chars in SOL context
 +#### ----------------------------------------
 +!! test
 +Headings: 0. Unnested
 +!! input
 +<nowiki>=foo=</nowiki>
 +
 +<nowiki>=foo</nowiki>''a''=
 +!! result
 +<p>=foo=
 +</p><p>=foo<i>a</i>=
  </p>
  !!end
  
 -!!test
 -3. SOL-sensitive wikitext tokens as template-args
 -!!options
 +!! test
 +Headings: 1. Nested inside html
 +!! options
  disabled
 -!!input
 -{{echo|*a}}
 -{{echo|#a}}
 -{{echo|:a}}
 -!!result
 -<p>*a
 -#a
 -:a
 +!! input
 +=<nowiki>=foo=</nowiki>=
 +==<nowiki>=foo=</nowiki>==
 +===<nowiki>=foo=</nowiki>===
 +====<nowiki>=foo=</nowiki>====
 +=====<nowiki>=foo=</nowiki>=====
 +======<nowiki>=foo=</nowiki>======
 +!! result
 +<h1>=foo=</h1>
 +<h2>=foo=</h2>
 +<h3>=foo=</h3>
 +<h4>=foo=</h4>
 +<h5>=foo=</h5>
 +<h6>=foo=</h6>
 +!!end
 +
 +!! test
 +Headings: 2. Outside heading nest on a single line <h1>foo</h1>*bar
 +!! options
 +disabled
 +!! input
 +=foo=
 +<nowiki>*bar</nowiki>
 +=foo=
 +=bar
 +=foo=
 +<nowiki>=bar=</nowiki>
 +!! result
 +<h1>foo</h1>*bar
 +<h1>foo</h1>=bar
 +<h1>foo</h1>=bar=
 +!!end
 +
 +!! test
 +Headings: 3. Nested inside html with wikitext split by html tags
 +!! options
 +disabled
 +!! input
 +=<nowiki>=</nowiki>'''bold'''foo==
 +!! result
 +<h1>=<b>bold</b>foo=</h1>
 +!!end
 +
 +!! test
 +Headings: 4. No escaping needed (testing just h1 and h2)
 +!! options
 +disabled
 +!! input
 +==foo=
 +=foo==
 +===foo==
 +==foo===
 +=''=''foo==
 +===
 +!! result
 +<h1>=foo</h1>
 +<h1>foo=</h1>
 +<h2>=foo</h2>
 +<h2>foo=</h2>
 +<h1><i>=</i>foo=</h1>
 +<h1>=</h1>
 +!!end
 +
 +!! test
 +Headings: 5. Empty headings
 +!! options
 +disabled
 +!! input
 +=<nowiki></nowiki>=
 +==<nowiki></nowiki>==
 +===<nowiki></nowiki>===
 +====<nowiki></nowiki>====
 +=====<nowiki></nowiki>=====
 +======<nowiki></nowiki>======
 +!! result
 +<h1></h1>
 +<h2></h2>
 +<h3></h3>
 +<h4></h4>
 +<h5></h5>
 +<h6></h6>
 +!!end
 +
 +!! test
 +Headings: 6. Heading chars in SOL context
 +!! options
 +disabled
 +!! input
 +<!--cmt--><nowiki>=h1=</nowiki>
 +!! result
 +<p><!--cmt-->=h1=
 +</p>
 +!!end
 +
 +#### --------------- Lists ---------------
 +#### 0. Outside nests (*foo, etc.)
 +#### 1. Nested inside html <ul><li>*foo</li></ul>
 +#### 2. Inside definition lists
 +#### 3. Only bullets at start should be escaped
 +#### 4. No escapes needed
 +#### 5. No unnecessary escapes
 +#### 6. Escape bullets in SOL position
 +#### 7. Escape bullets in a multi-line context
 +#### ----------------------------------------
 +
 +!! test
 +Lists: 0. Outside nests
 +!! input
 +<nowiki>*foo</nowiki>
 +
 +<nowiki>#foo</nowiki>
 +!! result
 +<p>*foo
 +</p><p>#foo
  </p>
  !!end
  
 +!! test
 +Lists: 1. Nested inside html
 +!! input
 +*<nowiki>*foo</nowiki>
 +
 +*<nowiki>#foo</nowiki>
 +
 +*<nowiki>:foo</nowiki>
 +
 +*<nowiki>;foo</nowiki>
 +
 +#<nowiki>*foo</nowiki>
 +
 +#<nowiki>#foo</nowiki>
 +
 +#<nowiki>:foo</nowiki>
 +
 +#<nowiki>;foo</nowiki>
 +!! result
 +<ul><li>*foo
 +</li></ul>
 +<ul><li>#foo
 +</li></ul>
 +<ul><li>:foo
 +</li></ul>
 +<ul><li>;foo
 +</li></ul>
 +<ol><li>*foo
 +</li></ol>
 +<ol><li>#foo
 +</li></ol>
 +<ol><li>:foo
 +</li></ol>
 +<ol><li>;foo
 +</li></ol>
 +
 +!!end
 +
 +!! test
 +Lists: 2. Inside definition lists
 +!! input
 +;<nowiki>;foo</nowiki>
 +
 +;<nowiki>:foo</nowiki>
 +
 +;<nowiki>:foo</nowiki>
 +:bar
 +
 +:<nowiki>:foo</nowiki>
 +!! result
 +<dl><dt>;foo
 +</dt></dl>
 +<dl><dt>:foo
 +</dt></dl>
 +<dl><dt>:foo
 +</dt><dd>bar
 +</dd></dl>
 +<dl><dd>:foo
 +</dd></dl>
 +
 +!!end
 +
 +!! test
 +Lists: 3. Only bullets at start of text should be escaped
 +!! input
 +*<nowiki>*foo*bar</nowiki>
 +
 +*<nowiki>*foo</nowiki>''it''*bar
 +!! result
 +<ul><li>*foo*bar
 +</li></ul>
 +<ul><li>*foo<i>it</i>*bar
 +</li></ul>
 +
 +!!end
 +
 +!! test
 +Lists: 4. No escapes needed
 +!! options
 +disabled
 +!! input
 +*foo*bar
 +
 +*''foo''*bar
 +
 +*[[Foo]]: bar
 +!! result
 +<ul><li>foo*bar
 +</li></ul>
 +<ul><li><i>foo</i>*bar
 +</li></ul>
 +<ul><li><a href="Foo" rel="mw:WikiLink">Foo</a>: bar
 +</li></ul>
 +!!end
 +
 +!! test
 +Lists: 5. No unnecessary escapes
 +!! input
 +* bar <span><nowiki>[[foo]]</nowiki></span>
 +
 +*=bar <span><nowiki>[[foo]]</nowiki></span>
 +
 +*[[bar <span><nowiki>[[foo]]</nowiki></span>
 +
 +*<nowiki>]]bar </nowiki><span><nowiki>[[foo]]</nowiki></span>
 +
 +*=bar <span>foo]]</span>=
 +!! result
 +<ul><li> bar <span>[[foo]]</span>
 +</li></ul>
 +<ul><li>=bar <span>[[foo]]</span>
 +</li></ul>
 +<ul><li>[[bar <span>[[foo]]</span>
 +</li></ul>
 +<ul><li>]]bar <span>[[foo]]</span>
 +</li></ul>
 +<ul><li>=bar <span>foo]]</span>=
 +</li></ul>
 +
 +!!end
 +
 +!! test
 +Lists: 6. Escape bullets in SOL position
 +!! options
 +disabled
 +!! input
 +<!--cmt--><nowiki>*foo</nowiki>
 +!! result
 +<p><!--cmt-->*foo
 +</p>
 +!!end
 +
 +!! test
 +Lists: 7. Escape bullets in a multi-line context
 +!! input
 +<nowiki>a
 +*b</nowiki>
 +!! result
 +<p>a
 +*b
 +</p>
 +!!end
 +
 +#### --------------- HRs ---------------
 +#### 1. Single line
 +#### -----------------------------------
 +
 +!! test
 +HRs: 1. Single line
 +!! options
 +disabled
 +!! input
 +----
 +<nowiki>----</nowiki>
 +----
 +<nowiki>=foo=</nowiki>
 +----
 +<nowiki>*foo</nowiki>
 +!! result
 +<hr/>----
 +<hr/>=foo=
 +<hr/>*foo
 +!! end
 +
 +#### --------------- Tables ---------------
 +#### 1a. Simple example
 +#### 1b. No escaping needed (!foo)
 +#### 1c. No escaping needed (|foo)
 +#### 1d. No escaping needed (|}foo)
 +####
 +#### 2a. Nested in td (<td>foo|bar</td>)
 +#### 2b. Nested in td (<td>foo||bar</td>)
 +#### 2c. Nested in td -- no escaping needed(<td>foo!!bar</td>)
 +####
 +#### 3a. Nested in th (<th>foo!bar</th>)
 +#### 3b. Nested in th (<th>foo!!bar</th>)
 +#### 3c. Nested in th -- no escaping needed(<th>foo||bar</th>)
 +####
 +#### 4a. Escape -
 +#### 4b. Escape +
 +#### 4c. No escaping needed
 +#### --------------------------------------
 +
 +!! test
 +Tables: 1a. Simple example
 +!! input
 +<nowiki>{|
 +|}</nowiki>
 +!! result
 +<p>{|
 +|}
 +</p>
 +!! end
 +
 +!! test
 +Tables: 1b. No escaping needed
 +!! input
 +!foo
 +!! result
 +<p>!foo
 +</p>
 +!! end
 +
 +!! test
 +Tables: 1c. No escaping needed
 +!! input
 +|foo
 +!! result
 +<p>|foo
 +</p>
 +!! end
 +
 +!! test
 +Tables: 1d. No escaping needed
 +!! input
 +|}foo
 +!! result
 +<p>|}foo
 +</p>
 +!! end
 +
 +!! test
 +Tables: 2a. Nested in td
 +!! options
 +disabled
 +!! input
 +{|
 +|<nowiki>foo|bar</nowiki>
 +|}
 +!! result
 +<table>
 +<tr><td>foo|bar
 +</td></tr></table>
 +
 +!! end
 +
 +!! test
 +Tables: 2b. Nested in td
 +!! options
 +disabled
 +!! input
 +{|
 +|<nowiki>foo||bar</nowiki>
 +|''it''<nowiki>foo||bar</nowiki>
 +|}
 +!! result
 +<table>
 +<tr><td>foo||bar
 +</td><td><i>it</i>foo||bar
 +</td></tr></table>
 +
 +!! end
 +
 +!! test
 +Tables: 2c. Nested in td -- no escaping needed
 +!! options
 +disabled
 +!! input
 +{|
 +|foo!!bar
 +|}
 +!! result
 +<table>
 +<tr><td>foo!!bar
 +</td></tr></table>
 +
 +!! end
 +
 +!! test
 +Tables: 3a. Nested in th
 +!! options
 +disabled
 +!! input
 +{|
 +!foo!bar
 +|}
 +!! result
 +<table>
 +<tr><th>foo!bar
 +</th></tr></table>
 +
 +!! end
 +
 +!! test
 +Tables: 3b. Nested in th
 +!! options
 +disabled
 +!! input
 +{|
 +!<nowiki>foo!!bar</nowiki>
 +|}
 +!! result
 +<table>
 +<tr><th>foo!!bar
 +</th></tr></table>
 +
 +!! end
 +
 +!! test
 +Tables: 3c. Nested in th -- no escaping needed
 +!! options
 +disabled
 +!! input
 +{|
 +!foo||bar
 +|}
 +!! result
 +<table>
 +<tr><th>foo||bar
 +</th></tr></table>
 +
 +!! end
 +
 +!! test
 +Tables: 4a. Escape -
 +!! options
 +disabled
 +!! input
 +{|
 +|-
 +!-bar
 +|-
 +|<nowiki>-bar</nowiki>
 +|}
 +!! result
 +<table><tbody>
 +<tr><th>-bar</th></tr>
 +<tr><td>-bar</td></tr>
 +</tbody></table>
 +!! end
 +
 +!! test
 +Tables: 4b. Escape +
 +!! options
 +disabled
 +!! input
 +{|
 +|-
 +!+bar
 +|-
 +|<nowiki>+bar</nowiki>
 +|}
 +!! result
 +<table><tbody>
 +<tr><th>+bar</th></tr>
 +<tr><td>+bar</td></tr>
 +</tbody></table>
 +!! end
 +
 +!! test
 +Tables: 4c. No escaping needed
 +!! options
 +disabled
 +!! input
 +{|
 +|-
 +|foo-bar
 +|foo+bar
 +|-
 +|''foo''-bar
 +|''foo''+bar
 +|}
 +!! result
 +<table><tbody>
 +<tr><td>foo-bar</td><td>foo+bar</td></tr>
 +<tr><td><i>foo</i>-bar</td><td><i>foo</i>+bar</td></tr>
 +</tbody></table>
 +!! end
 +
 +#### --------------- Links ---------------
 +#### 1. Quote marks in link text
 +#### 2. Wikilinks: Escapes needed
 +#### 3. Wikilinks: No escapes needed
 +#### 4. Extlinks: Escapes needed
 +#### 5. Extlinks: No escapes needed
 +#### --------------------------------------
 +!! test
 +Links 1. Quote marks in link text
 +!! options
 +disabled
 +!! input
 +[[Foo|<nowiki>Foo''boo''</nowiki>]]
 +!! result
 +<a rel="mw:WikiLink" href="Foo">Foo''boo''</a>
 +!! end
 +
 +!! test
 +Links 2. WikiLinks: Escapes needed
 +!! options
 +disabled
 +!! input
 +[[Foo|<nowiki>[Foobar]</nowiki>]]
 +[[Foo|<nowiki>Foobar]</nowiki>]]
 +[[Foo|<nowiki>x [Foobar] x</nowiki>]]
 +[[Foo|<nowiki>x [http://google.com g] x</nowiki>]]
 +[[Foo|<nowiki>[[Bar]]</nowiki>]]
 +[[Foo|<nowiki>x [[Bar]] x</nowiki>]]
 +[[Foo|<nowiki>|Bar</nowiki>]]
 +!! result
 +<a href="Foo" rel="mw:WikiLink">[Foobar]</a>
 +<a href="Foo" rel="mw:WikiLink">Foobar]</a>
 +<a href="Foo" rel="mw:WikiLink">x [Foobar] x</a>
 +<a href="Foo" rel="mw:WikiLink">x [http://google.com g] x</a>
 +<a href="Foo" rel="mw:WikiLink">[[Bar]]</a>
 +<a href="Foo" rel="mw:WikiLink">x [[Bar]] x</a>
 +<a href="Foo" rel="mw:WikiLink">|Bar</a>
 +!! end
 +
 +!! test
 +Links 3. WikiLinks: No escapes needed
 +!! options
 +disabled
 +!! input
 +[[Foo|[Foobar]]
 +[[Foo|foo|bar]]
 +!! result
 +<a href="Foo" rel="mw:WikiLink">[Foobar</a>
 +<a href="Foo" rel="mw:WikiLink">foo|bar</a>
 +!! end
 +
 +!! test
 +Links 4. ExtLinks: Escapes needed
 +!! options
 +disabled
 +!! input
 +[http://google.com <nowiki>[google]</nowiki>]
 +[http://google.com <nowiki>google]</nowiki>]
 +!! result
 +<a href="http://google.com" rel="mw:ExtLink">[google]</a>
 +<a href="http://google.com" rel="mw:ExtLink">google]</a>
 +!! end
 +
 +!! test
 +Links 5. ExtLinks: No escapes needed
 +!! options
 +disabled
 +!! input
 +[http://google.com [google]
 +!! result
 +<a href="http://google.com" rel="mw:ExtLink">[google</a>
 +!! end
 +
 +#### --------------- Quotes ---------------
 +#### 1. Quotes inside <b> and <i>
 +#### 2. Link fragments separated by <i> and <b> tags
 +#### 3. Link fragments inside <i> and <b>
 +#### --------------------------------------
 +!! test
 +1. Quotes inside <b> and <i>
 +!! input
 +''<nowiki>'foo'</nowiki>''
 +''<nowiki>''foo''</nowiki>''
 +''<nowiki>'''foo'''</nowiki>''
 +'''<nowiki>'foo'</nowiki>'''
 +'''<nowiki>''foo''</nowiki>'''
 +'''<nowiki>'''foo'''</nowiki>'''
 +'''<nowiki>foo'</nowiki>''<nowiki>bar'</nowiki>''baz'''
 +!! result
 +<p><i>'foo'</i>
 +<i>''foo''</i>
 +<i>'''foo'''</i>
 +<b>'foo'</b>
 +<b>''foo''</b>
 +<b>'''foo'''</b>
 +<b>foo'<i>bar'</i>baz</b>
 +</p>
 +!! end
 +
 +!! test
 +2. Link fragments separated by <i> and <b> tags
 +!! input
 +[[''foo''<nowiki>hello]]</nowiki>
 +
 +[['''foo'''<nowiki>hello]]</nowiki>
 +!! result
 +<p>[[<i>foo</i>hello]]
 +</p><p>[[<b>foo</b>hello]]
 +</p>
 +!! end
 +
 +!! test
 +2. Link fragments inside <i> and <b>
 +(FIXME: Escaping one or both of [[ and ]] is also acceptable --
 + this is one of the shortcomings of this format)
 +!! input
 +''[[foo''<nowiki>]]</nowiki>
 +
 +'''[[foo'''<nowiki>]]</nowiki>
 +!! result
 +<p><i>[[foo</i>]]
 +</p><p><b>[[foo</b>]]
 +</p>
 +!! end
 +
 +#### --------------- Paragraphs ---------------
 +#### 1. No unnecessary escapes
 +#### --------------------------------------
 +
 +!! test
 +1. No unnecessary escapes
 +!! input
 +bar <span><nowiki>[[foo]]</nowiki></span>
 +
 +=bar <span><nowiki>[[foo]]</nowiki></span>
 +
 +[[bar <span><nowiki>[[foo]]</nowiki></span>
 +
 +<nowiki>]]bar </nowiki><span><nowiki>[[foo]]</nowiki></span>
 +
 +<nowiki>=bar </nowiki><span>foo]]</span>=
 +!! result
 +<p>bar <span>[[foo]]</span>
 +</p><p>=bar <span>[[foo]]</span>
 +</p><p>[[bar <span>[[foo]]</span>
 +</p><p>]]bar <span>[[foo]]</span>
 +</p><p>=bar <span>foo]]</span>=
 +</p>
 +!!end
 +
 +#### --------------- PRE ------------------
 +#### 1. Leading space in SOL context should be escaped
 +#### --------------------------------------
 +!! test
 +1. Leading space in SOL context should be escaped
 +!! options
 +disabled
 +!! input
 +<nowiki> foo</nowiki>
 +<!--cmt--><nowiki> foo</nowiki>
 +!! result
 +<p> foo
 +<!--cmt--> foo
 +</p>
 +!! end
 +
 +#### --------------- HTML tags ---------------
 +#### 1. a tags
 +#### 2. other tags
 +#### 3. multi-line html tag
 +#### --------------------------------------
 +!! test
 +1. a tags
 +!! options
 +disabled
 +!! input
 +<a href="http://google.com">google</a>
 +!! result
 +&lt;a href=&quot;http://google.com&quot;&gt;google&lt;/a&gt;
 +!! end
 +
 +!! test
 +2. other tags
 +!! input
 +<nowiki><div>foo</div>
 +<div style="color:red">foo</div></nowiki>
 +!! result
 +<p>&lt;div&gt;foo&lt;/div&gt;
 +&lt;div style=&quot;color:red&quot;&gt;foo&lt;/div&gt;
 +</p>
 +!! end
 +
 +!! test
 +3. multi-line html tag
 +!! input
 +<nowiki><div
 +>foo</div
 +></nowiki>
 +!! result
 +<p>&lt;div
 +&gt;foo&lt;/div
 +&gt;
 +</p>
 +!! end
 +
 +#### --------------- Others ---------------
 +!! test
 +Escaping nowikis
 +!! input
 +&lt;nowiki&gt;foo&lt;/nowiki&gt;
 +!! result
 +<p>&lt;nowiki&gt;foo&lt;/nowiki&gt;
 +</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>&lt;x y&gt;
 +</p><p>&lt;x.y&gt;
 +</p><p>&lt;x-y&gt;
 +</p><p>1&gt;2
 +</p><p>x&lt;y
 +</p><p>a&gt;b
 +</p><p>1&lt;d e&gt;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>&lt;s.ome&gt text
 +</p>
 +!! end
 +
 +
  TODO:
  more images
  more tables