Add a test for indent pres with content wrapped in inline element
[lhc/web/wiklou.git] / tests / parser / parserTests.txt
index 27843a3..d18da66 100644 (file)
@@ -48,7 +48,7 @@ Template:Blank
 !! endarticle
 
 !! article
-Template:!
+Template:pipe
 !! text
 |
 !! endarticle
@@ -65,6 +65,12 @@ Template:inner list
 * item 1
 !! endarticle
 
+!! article
+Template:!
+!! text
+|
+!! endarticle
+
 !! article
 Template:echo
 !! text
@@ -89,6 +95,13 @@ Template:attr_str
 {{{1}}}="{{{2}}}"
 !! endarticle
 
+!! article
+Template:table_attribs
+!! text
+<noinclude>
+|</noinclude>style="color: red"| Foo
+!! endarticle
+
 ###
 ### Basic tests
 ###
@@ -774,6 +787,17 @@ And a <a href="/wiki/Main_Page" title="Main Page">link</a>
 </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
@@ -908,6 +932,15 @@ 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>
 !!input
@@ -964,6 +997,8 @@ Templates: Pre: 1e. Wrapping should be based on expanded content
 !!input
 {{echo| foo}}
 
+{{echo| foo}}{{echo| bar}}
+
 {{echo| foo}}
 {{echo| bar}}
 
@@ -975,6 +1010,8 @@ Templates: Pre: 1e. Wrapping should be based on expanded content
 !!result
 <pre>foo
 </pre>
+<pre>foo bar
+</pre>
 <pre>foo
 bar
 </pre>
@@ -986,6 +1023,92 @@ bar
 </pre>
 !!end
 
+!! test
+Templates: 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 for pre
 ###
@@ -1067,7 +1190,7 @@ c
 !!end
 
 !!test
-3. Pre and block tags
+3a. Pre and block tags (single-line html)
 !!input
  <p> foo </p>
  <div> foo </div>
@@ -1079,6 +1202,58 @@ c
 </pre>
 !!end
 
+!!test
+3b. 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
@@ -1235,13 +1410,13 @@ Bug 11748: Literal closing tags
 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>
@@ -2105,6 +2280,15 @@ http:/example.com
 </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
@@ -2364,9 +2548,9 @@ A table with nothing but a caption
 !! test
 Simple table
 !! input
-{| 
+{|
 | 1 || 2
-|- 
+|-
 | 3 || 4
 |}
 !! result
@@ -2385,7 +2569,7 @@ Simple table
 !! test
 Simple table but with multiple dashes for row wikitext
 !! input
-{| 
+{|
 | foo
 |-----
 | bar
@@ -2498,12 +2682,12 @@ Allow +/- in 2nd and later cells in a row
 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">
@@ -2608,6 +2792,19 @@ Indented table markup mixed with indented pre content (proposed in bug 6200)
 
 !! 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
 
 ###
 ### Internal links
@@ -3155,6 +3352,15 @@ language=ln
 </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
@@ -4199,7 +4405,7 @@ Template with complex arguments
 !! test
 BUG 553: link with two variables in a piped link
 !! input
-{| 
+{|
 |[[{{{1}}}|{{{2}}}]]
 |}
 !! result
@@ -4307,9 +4513,9 @@ Template from main namespace
 !! article
 Template:table
 !! text
-{| 
+{|
 | 1 || 2
-|- 
+|-
 | 3 || 4
 |}
 !! endarticle
@@ -4362,6 +4568,20 @@ BUG 41: Template parameters shown as broken links
 </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
@@ -4801,7 +5021,7 @@ Templates: HTML Tag: 6. Generation of end piece of HTML attr value
 !!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
@@ -4810,7 +5030,7 @@ Templates: Tables: 1. Generating start of a HTML table
 !!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
@@ -4819,7 +5039,7 @@ Templates: Tables: 2a. Generating middle of a HTML table
 !!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
@@ -4828,7 +5048,7 @@ Templates: Tables: 2b. Generating middle of a HTML table
 !!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
@@ -4837,7 +5057,7 @@ Templates: Tables: 3. Generating end of a HTML table
 !!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
@@ -4846,7 +5066,7 @@ Templates: Tables: 4a. Generating a single tag of a HTML table
 !!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
@@ -4855,7 +5075,7 @@ Templates: Tables: 4b. Generating a single tag of a HTML table
 !!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
@@ -4864,7 +5084,7 @@ Templates: Tables: 4c. Generating a single tag of a HTML table
 !!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
@@ -4873,7 +5093,7 @@ Templates: Tables: 4d. Generating a single tag of a HTML table
 !!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
@@ -4882,7 +5102,7 @@ Templates: Tables: 4e. Generating a single tag of a HTML table
 !!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
@@ -4890,6 +5110,62 @@ Templates: Tables: 4f. Generating a single tag of a HTML table
 
 !!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: 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
@@ -6217,6 +6493,46 @@ pst
 [[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
 ###
@@ -10136,6 +10452,29 @@ Bug 529: Uncovered bullet
 
 !! 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
@@ -11517,6 +11856,740 @@ disabled
 </p>
 !!end
 
+#### 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
+Headings: 1. Nested inside html
+!! options
+disabled
+!! 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" data-parsoid="{&quot;tsr&quot;:[0,7],&quot;contentPos&quot;:[5,5],&quot;src&quot;:&quot;[[Foo]]&quot;,&quot;bsp&quot;:[0,7],&quot;stx&quot;:&quot;simple&quot;}">Foo''boo''</a>
+!! 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
+
 TODO:
 more images
 more tables