</tbody></table>
!!end
+!! test
+Tables: Digest broken attributes on table and tr tag
+!! options
+parsoid=wt2html
+!! wikitext
+{| || |} ++
+|- || || ++ --
+|- > [
+|}
+!! html
+<table>
+<tbody>
+<tr></tr>
+<tr></tr>
+</tbody></table>
+!! end
+
!! test
Strip unsupported table tags
!! options
bar</p>
!! end
-## Edge case bug in Parsoid
+## Edge case bugs in Parsoid from T93580
!! test
-T93580: Templated <ref> inside images
+T93580: 1. Templated <ref> inside block images
!! wikitext
[[File:Foobar.jpg|thumb|Caption with templated ref: {{echo|<ref>foo</ref>}}]]
<ol class="mw-references" typeof="mw:Extension/references" about="#mwt6" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><a href="#cite_ref-1" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-1" class="mw-reference-text" data-parsoid="{}">foo</span></li></ol>
!! end
+!! test
+T93580: 2. <ref> inside inline images
+!! wikitext
+[[File:Foobar.jpg|Undisplayed caption in inline image with ref: <ref>foo</ref>]]
+
+<references />
+!! html/parsoid
+<p><span class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"caption","ak":"Undisplayed caption in inline image with ref: <ref>foo</ref>"}]}' data-mw='{"caption":"Undisplayed caption in inline image with ref: <span about=\"#mwt2\" class=\"mw-ref\" id=\"cite_ref-1\" rel=\"dc:references\" typeof=\"mw:Extension/ref\" data-parsoid=\"{&quot;dsr&quot;:[64,78,5,6]}\" data-mw=\"{&quot;name&quot;:&quot;ref&quot;,&quot;body&quot;:{&quot;id&quot;:&quot;mw-reference-text-cite_note-1&quot;},&quot;attrs&quot;:{}}\"><a href=\"#cite_note-1\" style=\"counter-reset: mw-Ref 1;\"><span class=\"mw-reflink-text\">[1]</span></a></span><meta typeof=\"mw:Extension/ref/Marker\" about=\"#mwt2\" data-parsoid=\"{&quot;group&quot;:&quot;&quot;,&quot;name&quot;:&quot;&quot;,&quot;content&quot;:&quot;foo&quot;,&quot;hasRefInRef&quot;:false,&quot;dsr&quot;:[64,78,5,6],&quot;tmp&quot;:{}}\" data-mw=\"{}\">"}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{}}'><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></span></p>
+
+<ol class="mw-references" typeof="mw:Extension/references" about="#mwt4" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><a href="#cite_ref-1" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-1" class="mw-reference-text" data-parsoid="{}">foo</span></li></ol>
+!! end
+
+!! test
+T93580: 3. Templated <ref> inside inline images
+!! wikitext
+[[File:Foobar.jpg|Undisplayed caption in inline image with ref: {{echo|<ref>{{echo|foo}}</ref>}}]]
+
+<references />
+!! html/parsoid
+<p><span class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"caption","ak":"Undisplayed caption in inline image with ref: {{echo|<ref>{{echo|foo}}</ref>}}"}]}' data-mw='{"caption":"Undisplayed caption in inline image with ref: <span about=\"#mwt2\" class=\"mw-ref\" id=\"cite_ref-1\" rel=\"dc:references\" typeof=\"mw:Transclusion mw:Extension/ref\" data-parsoid=\"{&quot;dsr&quot;:[64,96,null,null],&quot;pi&quot;:[[{&quot;k&quot;:&quot;1&quot;,&quot;spc&quot;:[&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;]}]]}\" data-mw=\"{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;<ref>{{echo|foo}}</ref>&quot;}},&quot;i&quot;:0}}]}\"><a href=\"#cite_note-1\" style=\"counter-reset: mw-Ref 1;\"><span class=\"mw-reflink-text\">[1]</span></a></span><meta typeof=\"mw:Transclusion mw:Extension/ref/Marker\" about=\"#mwt2\" data-parsoid=\"{&quot;group&quot;:&quot;&quot;,&quot;name&quot;:&quot;&quot;,&quot;content&quot;:&quot;foo&quot;,&quot;hasRefInRef&quot;:false,&quot;dsr&quot;:[64,96,null,null],&quot;pi&quot;:[[{&quot;k&quot;:&quot;1&quot;,&quot;spc&quot;:[&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;]}]],&quot;tmp&quot;:{}}\" data-mw=\"{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;<ref>{{echo|foo}}</ref>&quot;}},&quot;i&quot;:0}}]}\">"}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{}}'><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></span></p>
+
+<ol class="mw-references" typeof="mw:Extension/references" about="#mwt6" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><a href="#cite_ref-1" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-1" class="mw-reference-text" data-parsoid="{}">foo</span></li></ol>
+!! end
+
###
### Subpages
###
!! test
Headings: 0. Unnested
!! options
-parsoid
+parsoid=html2wt
+!! html/parsoid
+<p>=foo=</p>
+
+<p> =foo=
+<!--cmt-->
+=foo=</p>
+
+<p>=foo<i>a</i>=</p>
!! wikitext
<nowiki>=foo=</nowiki>
-<nowiki> =foo= </nowiki>
+<nowiki> </nowiki>=foo=
<!--cmt-->
<nowiki>=foo=</nowiki>
=foo''a''<nowiki>=</nowiki>
-!! html
-<p><span typeof="mw:Nowiki">=foo=</span></p>
-
-<p><span typeof="mw:Nowiki"> =foo= </span>
-<!--cmt-->
-<span typeof="mw:Nowiki">=foo=</span></p>
-
-<p>=foo<i>a</i><span typeof="mw:Nowiki">=</span></p>
!!end
# New headings and existing headings are handled differently
!! test
Headings: 3. Nested inside html with wikitext split by html tags
!! options
-parsoid=html2wt,wt2wt
-!! wikitext
-= ='''bold'''<nowiki>foo=</nowiki> =
+parsoid=html2wt
!! html/parsoid
<h1>=<b>bold</b>foo=</h1>
+!! wikitext
+= ='''bold'''<nowiki>foo=</nowiki> =
!!end
!! test
Headings: 4a. No escaping needed (testing just h1 and h2)
+!! options
+parsoid=html2wt
+!! html/parsoid
+<h1>=foo</h1>
+<h1>foo=</h1>
+<h1> =foo= </h1>
+<h1>=foo= bar</h1>
+<h2>=foo</h2>
+<h2>foo=</h2>
+<h1>=</h1>
+<h1><i>=</i>foo=</h1>
!! wikitext
= =foo =
= = =
= ''=''foo= =
-!! html/parsoid
-<h1>=foo</h1>
-<h1>foo=</h1>
-<h1> =foo= </h1>
-<h1>=foo= bar</h1>
-<h2>=foo</h2>
-<h2>foo=</h2>
-<h1>=</h1>
-<h1><i>=</i>foo=</h1>
!!end
!! test
!! test
Headings: 5. Empty headings
+!! options
+parsoid=html2wt
+!! html/parsoid
+<h1 data-parsoid='{}'></h1>
+
+<h2 data-parsoid='{}'></h2>
+
+<h3 data-parsoid='{}'></h3>
+
+<h4 data-parsoid='{}'></h4>
+
+<h5 data-parsoid='{}'></h5>
+
+<h6 data-parsoid='{}'></h6>
!! wikitext
=<nowiki/>=
=====<nowiki/>=====
======<nowiki/>======
-!! html/parsoid
-<h1 data-parsoid='{}'><meta typeof="mw:Placeholder" data-parsoid='{"src":"<nowiki/>"}'/></h1>
-
-<h2 data-parsoid='{}'><meta typeof="mw:Placeholder" data-parsoid='{"src":"<nowiki/>"}'/></h2>
-
-<h3 data-parsoid='{}'><meta typeof="mw:Placeholder" data-parsoid='{"src":"<nowiki/>"}'/></h3>
-
-<h4 data-parsoid='{}'><meta typeof="mw:Placeholder" data-parsoid='{"src":"<nowiki/>"}'/></h4>
-
-<h5 data-parsoid='{}'><meta typeof="mw:Placeholder" data-parsoid='{"src":"<nowiki/>"}'/></h5>
-
-<h6 data-parsoid='{}'><meta typeof="mw:Placeholder" data-parsoid='{"src":"<nowiki/>"}'/></h6>
!!end
!! test
Headings: 6a. Heading chars in SOL context (with trailing spaces)
+!! options
+parsoid=html2wt
+!! html/parsoid
+<p>=a=</p>
+
+<p>=a=</p>
+
+<p>=a=</p>
!! wikitext
<nowiki>=a=</nowiki>
<nowiki>=a=</nowiki>
<nowiki>=a=</nowiki>
-
-<nowiki>=a=</nowiki>
-!! html/php
-<p>=a=
-</p><p>=a=
-</p><p>=a=
-</p><p>=a=
-</p>
-!! html/parsoid
-<p><span typeof="mw:Nowiki">=a=</span></p>
-
-<p><span typeof="mw:Nowiki">=a=</span></p>
-
-<p><span typeof="mw:Nowiki">=a=</span></p>
-
-<p><span typeof="mw:Nowiki">=a=</span></p>
!!end
!! test
Headings: 6b. Heading chars in SOL context (with trailing newlines)
-!! wikitext
-<nowiki>=a=
-b</nowiki>
-
-<nowiki>=a=
-b</nowiki>
+!! options
+parsoid=html2wt
+!! html/parsoid
+<p>=a=
+b</p>
-<nowiki>=a=
-b</nowiki>
+<p>=a=
+b</p>
-<nowiki>=a=
-b</nowiki>
-!! html/php
-<p>=a=
-b
-</p><p>=a=
-b
-</p><p>=a=
-b
-</p><p>=a=
+<p>=a=
+b</p>
+!! wikitext
+<nowiki>=a=</nowiki>
b
-</p>
-!! html/parsoid
-<p><span typeof="mw:Nowiki">=a=
-b</span></p>
-<p><span typeof="mw:Nowiki">=a=
-b</span></p>
-
-<p><span typeof="mw:Nowiki">=a=
-b</span></p>
+<nowiki>=a=</nowiki>
+b
-<p><span typeof="mw:Nowiki">=a=
-b</span></p>
+<nowiki>=a=</nowiki>
+b
!!end
!! test
Headings: 6c. Heading chars in SOL context (leading newline break)
+!! options
+parsoid=html2wt
+!! html/parsoid
+<p>a
+=b=</p>
!! wikitext
a
<nowiki>=b=</nowiki>
-!! html/php
-<p>a
-=b=
-</p>
-!! html/parsoid
-<p>a
-<span typeof="mw:Nowiki">=b=</span>
!!end
!! test
Headings: 6d. Heading chars in SOL context (with interspersed comments)
+!! options
+parsoid=html2wt
+!! html/parsoid
+<!--c0--><p>=a=</p>
+
+<!--c1--><p>=a=</p> <!--c2--> <!--c3-->
!! wikitext
<!--c0--><nowiki>=a=</nowiki>
<!--c1--><nowiki>=a=</nowiki> <!--c2--> <!--c3-->
-!! html/php
-<p>=a=
-</p><p>=a=
-</p>
-!! html/parsoid
-<!--c0--><p><span typeof="mw:Nowiki">=a=</span></p>
-
-<!--c1--><p><span typeof="mw:Nowiki">=a=</span></p> <!--c2--> <!--c3-->
!!end
!! test
!! test
Lists: 0. Outside nests
+!! options
+parsoid=html2wt
+!! html/parsoid
+<p>*foo</p>
+
+<p>#foo</p>
+
+<p>;Foo:bar</p>
!! wikitext
<nowiki>*</nowiki>foo
<nowiki>#</nowiki>foo
-<nowiki>;Foo:</nowiki>bar
-!! html/php
-<p>*foo
-</p><p>#foo
-</p><p>;Foo:bar
-</p>
-!! html/parsoid
-<p><span typeof="mw:Nowiki">*</span>foo</p>
-
-<p><span typeof="mw:Nowiki">#</span>foo</p>
-
-<p><span typeof="mw:Nowiki">;Foo:</span>bar</p>
+<nowiki>;</nowiki>Foo<nowiki>:</nowiki>bar
!!end
!! test
Lists: 1. Nested inside html
+!! options
+parsoid=html2wt
+!! html/parsoid
+<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>
+
!! wikitext
*<nowiki>*foo</nowiki>
#<nowiki>:foo</nowiki>
#<nowiki>;foo</nowiki>
-!! html
-<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
+!! options
+parsoid=html2wt
+!! html/parsoid
+<dl><dt>;foo</dt></dl>
+<dl><dt>:foo</dt></dl>
+<dl><dt>:foo</dt>
+<dd>bar</dd></dl>
+<dl><dd>:foo</dd></dl>
+
!! wikitext
;<nowiki>;foo</nowiki>
:bar
:<nowiki>:foo</nowiki>
-!! html
-<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
+!! options
+parsoid=html2wt
+!! html/parsoid
+<ul><li>*foo*bar</li></ul>
+<ul><li>*foo<i>it</i>*bar</li></ul>
+
!! wikitext
*<nowiki>*foo*bar</nowiki>
*<nowiki>*foo</nowiki>''it''*bar
-!! html
-<ul><li>*foo*bar</li></ul>
-<ul><li>*foo<i>it</i>*bar</li></ul>
-
!!end
!! test
Lists: 4. No escapes needed
!! options
-parsoid
-!! wikitext
-*foo*bar
-
-*''foo''*bar
-
-*[[Foo]]: bar
-
-*[[Foo]]*bar
-!! html
+parsoid=html2wt
+!! html/parsoid
<ul>
<li>foo*bar
</li>
<li><a rel="mw:WikiLink" href="Foo" title="Foo">Foo</a>*bar
</li>
</ul>
+!! wikitext
+*foo*bar
+
+*''foo''*bar
+
+*[[Foo]]: bar
+
+*[[Foo]]*bar
!!end
!! test
Lists: 5. No unnecessary escapes
+!! options
+parsoid=html2wt
+!! html/parsoid
+<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>
+<ul><li> <s></s>: a</li></ul>
+<ul><li> <i>* foo</i></li></ul>
+
!! wikitext
* bar <span><nowiki>[[foo]]</nowiki></span>
* <s></s>: a
* ''* foo''
-!! html
-<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>
-<ul><li> <s></s>: a</li></ul>
-<ul><li> <i>* foo</i></li></ul>
-
!!end
!! test
!! test
Lists: 7. Escape bullets in a multi-line context
-!! wikitext
-a
-<nowiki>*</nowiki>b
-!! html
+!! options
+parsoid=html2wt
+!! html/parsoid
<p>a
*b
</p>
+!! wikitext
+a
+<nowiki>*</nowiki>b
!!end
!! test
!! test
HRs: 1. Single line
+!! options
+parsoid=html2wt
+!! html/parsoid
+<hr />----
+<hr />=foo=
+<hr />*foo
!! wikitext
----<nowiki>----</nowiki>
----=foo=
----*foo
-!! html+tidy
-<hr />
-<p>----</p>
-<hr />
-<p>=foo=</p>
-<hr />
-<p>*foo</p>
!! end
#### --------------- Tables ---------------
!! test
Tables: 1a. Simple example
-!! wikitext
-<nowiki>{|
-|}</nowiki>
-!! html
+!! options
+parsoid=html2wt
+!! html/parsoid
<p>{|
|}
</p>
+!! wikitext
+<nowiki>{|
+|}</nowiki>
!! end
!! test
Tables: 1b. No escaping needed
-!! wikitext
-!foo
-!! html
+!! options
+parsoid=html2wt
+!! html/parsoid
<p>!foo
</p>
+!! wikitext
+!foo
!! end
!! test
Tables: 1c. No escaping needed
-!! wikitext
-|foo
-!! html
+!! options
+parsoid=html2wt
+!! html/parsoid
<p>|foo
</p>
+!! wikitext
+|foo
!! end
!! test
Tables: 1d. No escaping needed
-!! wikitext
-|}foo
-!! html
+!! options
+parsoid=html2wt
+!! html/parsoid
<p>|}foo
</p>
+!! wikitext
+|}foo
!! end
!! test
!! test
Tables: 2c. Nested in td -- no escaping needed
-!! wikitext
-{|
-
-|foo!!bar
-|}
+!! options
+parsoid=html2wt
!! html/*
<table>
<td>foo!!bar
</td></tr></table>
-!! end
-
-!! test
-Tables: 3a. Nested in th
!! wikitext
{|
-!foo!bar
+|foo!!bar
|}
+!! end
+
+!! test
+Tables: 3a. Nested in th
+!! options
+parsoid=html2wt
!! html/*
<table>
<th>foo!bar
</th></tr></table>
+!! wikitext
+{|
+
+!foo!bar
+|}
!! end
!! test
!! test
Tables: 4c. No escaping needed
+!! options
+parsoid=html2wt
+!! html/parsoid
+<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>
+<tr><td>foo
+<p>bar|baz
++bar
+-bar</p></td></tr>
+<tr><td>x
+<div>a|b</div></td>
+</tbody></table>
!! wikitext
{|
|foo-bar
<div>a|b</div>
</td></tr></table>
-!! html/parsoid
-<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>
-<tr><td>foo
-<p>bar|baz
-+bar
--bar</p></td></tr>
-<tr><td>x
-<div>a|b</div></td>
-</tbody></table>
!! end
!! test
Tables: 4d. No escaping needed
+!! options
+parsoid=html2wt
+!! html/parsoid
+<table>
+<tbody><tr><td><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a>-bar</td>
+<td data-parsoid='{"startTagSrc":"|","attrSepSrc":"|"}'>+1</td>
+<td data-parsoid='{"startTagSrc":"|","attrSepSrc":"|"}'>-2</td></tr>
+</tbody></table>
!! wikitext
{|
|[[Foo]]-bar
<td>-2
</td></tr></table>
-!! html/parsoid
-<table>
-<tbody><tr><td><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a>-bar</td>
-<td data-parsoid='{"startTagSrc":"|","attrSepSrc":"|"}'>+1</td>
-<td data-parsoid='{"startTagSrc":"|","attrSepSrc":"|"}'>-2</td></tr>
-</tbody></table>
-!! end
-
-!! test
-Tables: Digest broken attributes on table and tr tag
-!! options
-parsoid=wt2html
-!! wikitext
-{| || |} ++
-|- || || ++ --
-|- > [
-|}
-!! html
-<table>
-<tbody>
-<tr></tr>
-<tr></tr>
-</tbody></table>
!! end
!! test
!! test
Unclosed xmlish element in table line shouldn't eat end delimiters
+!! options
+parsoid=html2wt
+!! html/parsoid
+<table>
+<tbody><tr><td> <foo</td>
+<td> bar></td></tr>
+</tbody></table>
!! wikitext
{|
| <foo
<td> bar>
</td></tr></table>
-!! html/parsoid
-<table>
-<tbody><tr><td> <foo</td>
-<td> bar></td></tr>
-</tbody></table>
!! end
#### --------------- Links ----------------
#### --------------------------------------
!! test
Links 1. WikiLinks: No escapes needed
+!! options
+parsoid=html2wt
+!! html/parsoid
+<p><a rel="mw:WikiLink" href="Foo" title="Foo">Foo<i>boo</i></a>
+<a rel="mw:WikiLink" href="Foo" title="Foo">[Foobar]</a>
+<a rel="mw:WikiLink" href="Foo" title="Foo">x [Foobar] x</a></p>
!! wikitext
[[Foo|Foo''boo'']]
[[Foo|[Foobar]]]
<a href="/wiki/Foo" title="Foo">[Foobar]</a>
<a href="/wiki/Foo" title="Foo">x [Foobar] x</a>
</p>
-!! html/parsoid
-<p><a rel="mw:WikiLink" href="Foo" title="Foo">Foo<i>boo</i></a>
-<a rel="mw:WikiLink" href="Foo" title="Foo">[Foobar]</a>
-<a rel="mw:WikiLink" href="Foo" title="Foo">x [Foobar] x</a></p>
!! end
!! test
!! test
Links 3. WikiLinks: No escapes needed
+!! options
+parsoid=html2wt
+!! html/parsoid
+<p><a rel="mw:WikiLink" href="Foo">[Foobar</a>
+<a rel="mw:WikiLink" href="Foo" title="Foo">foo|bar</a></p>
!! wikitext
[[Foo|[Foobar]]
[[Foo|foo|bar]]
<p><a href="/wiki/Foo" title="Foo">[Foobar</a>
<a href="/wiki/Foo" title="Foo">foo|bar</a>
</p>
-!! html/parsoid
-<p><a rel="mw:WikiLink" href="Foo">[Foobar</a>
-<a rel="mw:WikiLink" href="Foo" title="Foo">foo|bar</a></p>
!! end
!! test
!! test
Links 5. ExtLinks: No escapes needed
+!! options
+parsoid=html2wt
+!! html/parsoid
+<p><a rel="mw:ExtLink" href="http://google.com">[google</a></p>
!! wikitext
[http://google.com [google]
!! html/php
<p><a rel="nofollow" class="external text" href="http://google.com">[google</a>
</p>
-!! html/parsoid
-<p><a rel="mw:ExtLink" href="http://google.com">[google</a></p>
!! end
!! test
Links 6. Add <nowiki/>s between text-nodes and url-links when required (bug 64300)
+!! options
+parsoid=html2wt
!! html/parsoid
<p>x<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>y
<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>?x
!! test
Links 7a. Don't add spurious <nowiki/>s between text-nodes and url-links (bug 64300)
+!! options
+parsoid=html2wt
!! html/parsoid
<p>x
<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>
!! test
Links 7b. Don't add spurious <nowiki/>s between text-nodes and url-links (bug 64300)
+!! options
+parsoid=html2wt
!! html/parsoid
<p><a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>.,;:!?\
-<a rel="mw:ExtLink" href="http://example.com">http://example.com</a>:</p>
!! test
Links 8. Add <nowiki/>s between text-nodes and RFC-links when required (bug 64300)
+!! options
+parsoid=html2wt
!! html/parsoid
<p><a href="//tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>4
<a href="//tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>y
!! test
Links 9. Don't add spurious <nowiki/>s between text-nodes and RFC-links (bug 64300)
+!! options
+parsoid=html2wt
!! html/parsoid
<p><a href="//tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>?foo
<a href="//tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>&foo
!! test
Links 10. Add <nowiki/>s between text-nodes and PMID-links when required (bug 64300)
+!! options
+parsoid=html2wt
!! html/parsoid
<p><a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>4
<a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>y
!! test
Links 11. Don't add spurious <nowiki/>s between text-nodes and PMID-links (bug 64300)
+!! options
+parsoid=html2wt
!! html/parsoid
<p><a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>?foo
<a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>&foo
!! test
Links 12. Add <nowiki/>s between text-nodes and ISBN-links when required (bug 64300)
+!! options
+parsoid=html2wt
!! html/parsoid
<p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>1
<a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>x
!! test
Links 13. Don't add spurious <nowiki/>s between text-nodes and ISBN-links (bug 64300)
+!! options
+parsoid=html2wt
!! html/parsoid
<p>-<a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>'s
!! wikitext
Links 15. Link trails can't become link prefixes.
!! options
language=is
+parsoid=html2wt
+!! html/parsoid
+<p><a rel="mw:WikiLink" href="Söfnuður" title="Söfnuður" data-parsoid='{"stx":"simple","tail":"-"}'>Söfnuður-</a><a rel="mw:WikiLink" href="00" title="00">00</a></p>
!! wikitext
[[Söfnuður]]-[[00]]
!! html/php
<p><a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">Söfnuður-</a><a href="/wiki/00" title="00">00</a>
</p>
-!! html/parsoid
-<p><a rel="mw:WikiLink" href="Söfnuður" title="Söfnuður" data-parsoid='{"stx":"simple","tail":"-"}'>Söfnuður-</a><a rel="mw:WikiLink" href="00" title="00">00</a></p>
!! end
#### --------------- Quotes ---------------
!! test
1a. Quotes inside <b> and <i>
!! options
-parsoid=html2wt,wt2wt
-!! wikitext
-''<nowiki/>'foo'''
-''<nowiki>''foo''</nowiki>''
-''<nowiki>'''foo'''</nowiki>''
-''foo''<nowiki/>'s
-'''<nowiki/>'foo''''
-'''<nowiki>''foo''</nowiki>'''
-'''<nowiki>'''foo'''</nowiki>'''
-'''foo'<nowiki/>''bar'<nowiki/>''baz'''
-'''foo'''<nowiki/>'s
-'''foo''
-''foo''<nowiki/>'
-''foo'''<nowiki/>'
-'''foo''<nowiki/>'
-''''foo'''
-'''foo'''<nowiki/>'
-''''foo'''<nowiki/>'
-''fools'<span> errand</span>''
-''<span>fool</span>'s errand''
-'<nowiki/>''foo'' bar '''baz''
-a|!*#-:;+-~[]{}b'''x''
+parsoid=html2wt
!! html/*
<p><i>'foo'</i>
<i>''foo''</i>
'<i>foo</i> bar '<i>baz</i>
a|!*#-:;+-~[]{}b'<i>x</i>
</p>
+!! wikitext
+''<nowiki/>'foo'''
+''<nowiki>''foo''</nowiki>''
+''<nowiki>'''foo'''</nowiki>''
+''foo''<nowiki/>'s
+'''<nowiki/>'foo''''
+'''<nowiki>''foo''</nowiki>'''
+'''<nowiki>'''foo'''</nowiki>'''
+'''foo'<nowiki/>''bar'<nowiki/>''baz'''
+'''foo'''<nowiki/>'s
+'''foo''
+''foo''<nowiki/>'
+''foo'''<nowiki/>'
+'''foo''<nowiki/>'
+''''foo'''
+'''foo'''<nowiki/>'
+''''foo'''<nowiki/>'
+''fools'<span> errand</span>''
+''<span>fool</span>'s errand''
+'<nowiki/>''foo'' bar '''baz''
+a|!*#-:;+-~[]{}b'''x''
!! end
!! test
1b. Quotes inside <b> and <i> with other tags on same line
!! options
-parsoid=html2wt,wt2wt
-!! wikitext
-'''a'' foo ''[[bar]]''
-''a''' foo ''[[bar]]''
-''a''' foo '''{{echo|[[bar]]}}'''
-[[foo]] x'''[[bar]]''
-'''foo'' <ref>test</ref>
-'''foo'' <div title="name">test</div>
-'''foo'' and <br> bar
-<references />
-!! html
+parsoid=html2wt
+!! html/parsoid
'<i>a</i> foo <i><a rel="mw:WikiLink" href="Bar" title="Bar">bar</a></i>
<i>a'</i> foo <i><a rel="mw:WikiLink" href="Bar" title="Bar">bar</a></i>
<i>a'</i> foo <b><a rel="mw:WikiLink" href="Bar" title="Bar" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[[bar]]"}},"i":0}}]}'>bar</a></b>
<ol class="mw-references" typeof="mw:Extension/references" about="#mwt5" data-mw='{"name":"references","attrs":{}}'>
<li about="#cite_note-1" id="cite_note-1"><span rel="mw:referencedBy"><a href="#cite_ref-1">↑</a></span> <span id="mw-reference-text-cite_note-1" class="mw-reference-text" data-parsoid="{}">test</span></li>
</ol>
+!! wikitext
+'''a'' foo ''[[bar]]''
+''a''' foo ''[[bar]]''
+''a''' foo '''{{echo|[[bar]]}}'''
+[[foo]] x'''[[bar]]''
+'''foo'' <ref>test</ref>
+'''foo'' <div title="name">test</div>
+'''foo'' and <br> bar
+<references />
!! end
!! test
2. Link fragments separated by <i> and <b> tags
+!! options
+parsoid=html2wt
+!! html/parsoid
+<p>[[<i>foo</i>hello]]</p>
+<p>[[<b>foo</b>hello]]</p>
!! wikitext
[[''foo''<nowiki>hello]]</nowiki>
[['''foo'''<nowiki>hello]]</nowiki>
-!! html
-<p>[[<i>foo</i>hello]]
-</p><p>[[<b>foo</b>hello]]
-</p>
!! end
# FIXME: Escaping one or both of [[ and ]] is also acceptable --
# this is one of the shortcomings of this format
!! test
3. Link fragments inside <i> and <b>
+!! options
+parsoid=html2wt
+!! html/parsoid
+<p><i>[[foo</i>]]</p>
+<p><b>[[foo</b>]]</p>
!! wikitext
''[[foo''<nowiki>]]</nowiki>
'''[[foo'''<nowiki>]]</nowiki>
-!! html
-<p><i>[[foo</i>]]
-</p><p><b>[[foo</b>]]
-</p>
!! end
!! test
4. No escaping needed
-!! wikitext
-'<span>''bar''</span>'
-'<span>'''bar'''</span>'
-'a:b'foo
-!! html
+!! options
+options=html2wt
+!! html/parsoid
<p>'<span><i>bar</i></span>'
'<span><b>bar</b></span>'
'a:b'foo
</p>
+!! wikitext
+'<span>''bar''</span>'
+'<span>'''bar'''</span>'
+'a:b'foo
!! end
#### ----------- Paragraphs ---------------
!! test
1. No unnecessary escapes
+!! options
+parsoid=html2wt
+!! html/parsoid
+<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>
!! wikitext
bar <span><nowiki>[[foo]]</nowiki></span>
]]bar <span><nowiki>[[foo]]</nowiki></span>
=bar <span>foo]]</span><nowiki>=</nowiki>
-!! html
-<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 --------------------------
!! test
1. Leading whitespace in SOL context should be escaped
!! options
-parsoid=html2wt,wt2wt
-!! html/php
-<p> a
-</p><p> a
-</p><p> a(tab)
-</p><p> a
- a
-</p><p>a
- b
-</p><p>a
- b
-</p><p>a
- b
-</p>
+parsoid=html2wt
!! html/parsoid
<p> a</p>
a
b
+!! html/php
+<p> a
+</p><p> a
+</p><p> a(tab)
+</p><p> a
+ a
+</p><p>a
+ b
+</p><p>a
+ b
+</p><p>a
+ b
+</p>
!! end
!! test
2. Leading whitespace in non-indent-pre contexts should not be escaped
!! options
-parsoid
-!! wikitext
-foo <ref>''a''
- b</ref>
-<references />
-!! html
+parsoid=htm2wt
+!! html/parsoid
<p>foo <span about="#mwt2" class="mw-ref" id="cite_ref-1" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","body":{"id":"mw-reference-text-cite_note-1"},"attrs":{}}'><a href="#cite_note-1"><span class="mw-reflink-text">[1]</span></a></span></p>
<ol class="mw-references" typeof="mw:Extension/references" about="#mwt4" data-mw='{"name":"references","attrs":{}}'>
<li about="#cite_note-1" id="cite_note-1"><a href="#cite_ref-1" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-1" class="mw-reference-text"><i data-parsoid='{"dsr":[9,14,2,2]}'>a</i>
b</span></li>
</ol>
+!! wikitext
+foo <ref>''a''
+ b</ref>
+<references />
!! end
!! test
3. Leading whitespace in indent-pre suppressing contexts should not be escaped
!! options
-parsoid
-!! wikitext
+parsoid=html2wt
+!! html/parsoid
<blockquote>
+<p>
a
<span>b</span>
- c
+ c</p>
</blockquote>
-!! html
+!! wikitext
<blockquote>
-<p>
a
<span>b</span>
- c</p>
+ c
</blockquote>
!! end
!! test
4. Leading whitespace in indent-pre suppressing contexts should not be escaped
!! options
-parsoid
-!! wikitext
- [[File:Foobar.jpg|thumb|caption]]
+options=html2wt
!! html/parsoid
<figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption>caption</figcaption></figure>
+!! wikitext
+ [[File:Foobar.jpg|thumb|caption]]
!! end
!! test
!!test
T95794: nowiki escaping should account for leading space at start-of-line in an indent-pre block
!! options
-parsoid
-!! wikitext
- * foo
- * bar
-!! html
+parsoid=html2wt
+!! html/parsoid
<pre>
* foo
* bar
</pre>
+!! wikitext
+ * foo
+ * bar
!! end
#### --------------- Behavior Switches --------------------
# We use indent-pre as an indirect way to test for sol-transparent behavior.
!! test
Behavior switches should be SOL-transparent
-!! wikitext
- __TOC__
-
- <!-- this one's bogus -->
- __TOO__
-
- __TOC__ foo
-
-__TOC__ bar
+!! options
+parsoid=html2wt
!! html/parsoid
<meta property="mw:PageProp/toc" />
<pre data-parsoid='{}'><meta property="mw:PageProp/toc" data-parsoid='{"src":"__TOC__","magicSrc":"__TOC__"}'/> foo</pre>
<meta property="mw:PageProp/toc" data-parsoid='{"src":"__TOC__","magicSrc":"__TOC__"}'/><pre data-parsoid='{}'>bar</pre>
+!! wikitext
+ __TOC__
+
+ <!-- this one's bogus -->
+ __TOO__
+
+ __TOC__ foo
+
+__TOC__ bar
!! end
#### --------------- HTML tags ---------------
!! test
1. a tags
!! options
-parsoid
+parsoid=html2wt
+!! html/parsoid
+<a href="http://google.com">google</a>
!! wikitext
<a href="http://google.com">google</a>
-!! html
-<a href="http://google.com">google</a>
!! end
!! test
2. other tags
-!! wikitext
-* <nowiki><div>foo</div></nowiki>
-* <nowiki><div style="color:red">foo</div></nowiki>
-* <nowiki><td></nowiki>
-!! html
+!! options
+parsoid=html2wt
+!! html/parsoid
<ul><li> <div>foo</div></li>
<li> <div style="color:red">foo</div></li>
<li> <td></li></ul>
+!! wikitext
+* <nowiki><div>foo</div></nowiki>
+* <nowiki><div style="color:red">foo</div></nowiki>
+* <nowiki><td></nowiki>
!! end
!! test
3. multi-line html tag
-!! wikitext
-<nowiki><div
->foo</div
-></nowiki>
-!! html
+!! options
+parsoid=html2wt
+!! html/parsoid
<p><div
>foo</div
>
</p>
+!! wikitext
+<nowiki><div
+>foo</div
+></nowiki>
!! end
!! test
4. extension tags
+!! options
+parsoid=html2wt
+!! html/parsoid
+<p><ref>foo</ref>
+</p><p><ref>bar
+</p><p>baz</ref>
+</p>
!! wikitext
<nowiki><ref>foo</ref></nowiki>
<nowiki><ref>bar</nowiki>
baz<nowiki></ref></nowiki>
-!! html
-<p><ref>foo</ref>
-</p><p><ref>bar
-</p><p>baz</ref>
-</p>
!! end
#### --------------- Others ---------------
!! test
Escaping nowikis
-!! wikitext
-<nowiki>foo</nowiki>
-!! html
+!! options
+parsoid=html2wt
+!! html/parsoid
<p><nowiki>foo</nowiki>
</p>
+!! wikitext
+<nowiki>foo</nowiki>
!! end
## The quote-char in the input is necessary for triggering the bug
!! test
(Bug 52035) Nowiki-escaping should not get tripped by " :" in text
!! options
-parsoid=wt2wt,html2wt
+parsoid=html2wt
+!! html/parsoid
+<p>foo's bar :</p>
!! wikitext
foo's bar :
-!! html
-<p>foo's bar :</p>
!! end
+#----------- End of wikitext escaping tests --------------
+
!! test
Tag-like HTML structures are passed through as text