Terminate free external link on &nbsp; (and numeric versions of <>)
[lhc/web/wiklou.git] / tests / parser / parserTests.txt
index 266b2b0..4c6c9a5 100644 (file)
@@ -2057,13 +2057,28 @@ Tabs don't trigger preformatted text
         preformatted text.
  This is preformatted text.
        So is this.
         preformatted text.
  This is preformatted text.
        So is this.
-!! html
+!! html/php
 <p>    This is not
         preformatted text.
 </p>
 <pre>This is preformatted text.
        So is this.
 </pre>
 <p>    This is not
         preformatted text.
 </p>
 <pre>This is preformatted text.
        So is this.
 </pre>
+!! html/parsoid
+<p>    This is not
+        preformatted text.</p>
+<pre>This is preformatted text.
+       So is this.</pre>
+!! end
+
+!! test
+Space before tab needs nowiki pre protection
+!! options
+parsoid=html2wt
+!! html/parsoid
+<p>    a</p>
+!! wikitext
+<nowiki> </nowiki>     a
 !! end
 
 !! test
 !! end
 
 !! test
@@ -4631,6 +4646,9 @@ http://example.com?
 http://example.com)
 http://example.com/url_with_(brackets)
 (http://example.com/url_without_brackets)
 http://example.com)
 http://example.com/url_with_(brackets)
 (http://example.com/url_without_brackets)
+http://example.com/url_with_entity&amp;
+http://example.com/url_with_entity&#x26;
+http://example.com/url_with_entity&#038;
 http://example.com/url_with_entity&nbsp;
 http://example.com/url_with_entity&#xA0;
 http://example.com/url_with_entity&#160;
 http://example.com/url_with_entity&nbsp;
 http://example.com/url_with_entity&#xA0;
 http://example.com/url_with_entity&#160;
@@ -4648,12 +4666,15 @@ http://example.com/url_with_entity&#60;
 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
 <a rel="nofollow" class="external free" href="http://example.com/url_with_(brackets)">http://example.com/url_with_(brackets)</a>
 (<a rel="nofollow" class="external free" href="http://example.com/url_without_brackets">http://example.com/url_without_brackets</a>)
 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
 <a rel="nofollow" class="external free" href="http://example.com/url_with_(brackets)">http://example.com/url_with_(brackets)</a>
 (<a rel="nofollow" class="external free" href="http://example.com/url_without_brackets">http://example.com/url_without_brackets</a>)
-<a rel="nofollow" class="external free" href="http://example.com/url_with_entity ">http://example.com/url_with_entity </a>
-<a rel="nofollow" class="external free" href="http://example.com/url_with_entity ">http://example.com/url_with_entity </a>
-<a rel="nofollow" class="external free" href="http://example.com/url_with_entity ">http://example.com/url_with_entity </a>
+<a rel="nofollow" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
+<a rel="nofollow" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
+<a rel="nofollow" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
+<a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#160;
+<a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#xa0;
+<a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#160;
 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&lt;
 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&lt;
-<a rel="nofollow" class="external free" href="http://example.com/url_with_entity%3C">http://example.com/url_with_entity%3C</a>
-<a rel="nofollow" class="external free" href="http://example.com/url_with_entity%3C">http://example.com/url_with_entity%3C</a>
+<a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#x3c;
+<a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#60;
 </p>
 !! html/parsoid
 <p><a rel="mw:ExtLink" href="http://example.com">http://example.com</a>,
 </p>
 !! html/parsoid
 <p><a rel="mw:ExtLink" href="http://example.com">http://example.com</a>,
@@ -5234,38 +5255,6 @@ External link containing a single quote. (bug 63947)
 <p><a rel="mw:ExtLink" href="//foo.org/bar'baz">bang</a></p>
 !! end
 
 <p><a rel="mw:ExtLink" href="//foo.org/bar'baz">bang</a></p>
 !! end
 
-
-!! test
-External link containing a period in the anchor. (bug 63947)
-!! wikitext
-[//foo.org/bar#baz. bang]
-
-[//foo.org/bar. bang]
-!! html/php
-<p><a rel="nofollow" class="external text" href="//foo.org/bar#baz.">bang</a>
-</p><p><a rel="nofollow" class="external text" href="//foo.org/bar.">bang</a>
-</p>
-!! html/parsoid
-<p><a rel="mw:ExtLink" href="//foo.org/bar#baz.">bang</a></p>
-<p><a rel="mw:ExtLink" href="//foo.org/bar.">bang</a></p>
-!! end
-
-!! test
-External link containing a single quote. (bug 63947)
-!! wikitext
-[//foo.org/bar'baz]
-
-[//foo.org/bar'baz bang]
-!! html/php
-<p><a rel="nofollow" class="external autonumber" href="//foo.org/bar'baz">[1]</a>
-</p><p><a rel="nofollow" class="external text" href="//foo.org/bar'baz">bang</a>
-</p>
-!! html/parsoid
-<p><a rel="mw:ExtLink" href="//foo.org/bar'baz"></a></p>
-<p><a rel="mw:ExtLink" href="//foo.org/bar'baz">bang</a></p>
-!! end
-
-
 !! test
 External link containing double-single-quotes in text '' (bug 4598 sanity check)
 !! wikitext
 !! test
 External link containing double-single-quotes in text '' (bug 4598 sanity check)
 !! wikitext
@@ -5301,9 +5290,22 @@ External link containing double-single-quotes with no space separating the url f
 External link with comments in link text
 !! wikitext
 [http://www.google.com Google <!-- comment -->]
 External link with comments in link text
 !! wikitext
 [http://www.google.com Google <!-- comment -->]
-!! html
+!! html/php
 <p><a rel="nofollow" class="external text" href="http://www.google.com">Google </a>
 </p>
 <p><a rel="nofollow" class="external text" href="http://www.google.com">Google </a>
 </p>
+!! html/parsoid
+<p><a rel="mw:ExtLink" href="http://www.google.com">Google <!-- comment --></a></p>
+!! end
+
+!! test
+External link to bare IPv4 address
+!! wikitext
+[http://192.168.0.1 Link]
+!! html/php
+<p><a rel="nofollow" class="external text" href="http://192.168.0.1">Link</a>
+</p>
+!! html/parsoid
+<p><a rel="mw:ExtLink" href="http://192.168.0.1">Link</a></p>
 !! end
 
 !! test
 !! end
 
 !! test
@@ -5345,7 +5347,7 @@ IPv6 urls, autolink format (T23261)
 !! wikitext
 http://[2404:130:0:1000::187:2]/index.php
 
 !! wikitext
 http://[2404:130:0:1000::187:2]/index.php
 
-Examples from RFC2373, section 2.2:
+Examples from RFC 2373, section 2.2:
 * http://[1080::8:800:200C:417A]/unicast
 * http://[FF01::101]/multicast
 * http://[::1]/loopback
 * http://[1080::8:800:200C:417A]/unicast
 * http://[FF01::101]/multicast
 * http://[::1]/loopback
@@ -5362,9 +5364,9 @@ Examples from RFC 2732, section 2:
 * http://[::FFFF:129.144.52.38]:80/index.html
 * http://[2010:836B:4179::836B:4179]
 
 * http://[::FFFF:129.144.52.38]:80/index.html
 * http://[2010:836B:4179::836B:4179]
 
-!! html
+!! html/php
 <p><a rel="nofollow" class="external free" href="http://[2404:130:0:1000::187:2]/index.php">http://[2404:130:0:1000::187:2]/index.php</a>
 <p><a rel="nofollow" class="external free" href="http://[2404:130:0:1000::187:2]/index.php">http://[2404:130:0:1000::187:2]/index.php</a>
-</p><p>Examples from RFC2373, section 2.2:
+</p><p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc2373">RFC 2373</a>, section 2.2:
 </p>
 <ul><li> <a rel="nofollow" class="external free" href="http://[1080::8:800:200C:417A]/unicast">http://[1080::8:800:200C:417A]/unicast</a></li>
 <li> <a rel="nofollow" class="external free" href="http://[FF01::101]/multicast">http://[FF01::101]/multicast</a></li>
 </p>
 <ul><li> <a rel="nofollow" class="external free" href="http://[1080::8:800:200C:417A]/unicast">http://[1080::8:800:200C:417A]/unicast</a></li>
 <li> <a rel="nofollow" class="external free" href="http://[FF01::101]/multicast">http://[FF01::101]/multicast</a></li>
@@ -5382,6 +5384,25 @@ Examples from RFC 2732, section 2:
 <li> <a rel="nofollow" class="external free" href="http://[::FFFF:129.144.52.38]:80/index.html">http://[::FFFF:129.144.52.38]:80/index.html</a></li>
 <li> <a rel="nofollow" class="external free" href="http://[2010:836B:4179::836B:4179]">http://[2010:836B:4179::836B:4179]</a></li></ul>
 
 <li> <a rel="nofollow" class="external free" href="http://[::FFFF:129.144.52.38]:80/index.html">http://[::FFFF:129.144.52.38]:80/index.html</a></li>
 <li> <a rel="nofollow" class="external free" href="http://[2010:836B:4179::836B:4179]">http://[2010:836B:4179::836B:4179]</a></li></ul>
 
+!! html/parsoid
+<p><a rel="mw:ExtLink" href="http://[2404:130:0:1000::187:2]/index.php">http://[2404:130:0:1000::187:2]/index.php</a></p>
+
+<p>Examples from <a href="//tools.ietf.org/html/rfc2373" rel="mw:ExtLink">RFC 2373</a>, section 2.2:</p>
+<ul><li> <a rel="mw:ExtLink" href="http://[1080::8:800:200C:417A]/unicast">http://[1080::8:800:200C:417A]/unicast</a></li>
+<li> <a rel="mw:ExtLink" href="http://[FF01::101]/multicast">http://[FF01::101]/multicast</a></li>
+<li> <a rel="mw:ExtLink" href="http://[::1]/loopback">http://[::1]/loopback</a></li>
+<li> <a rel="mw:ExtLink" href="http://[::]/unspecified">http://[::]/unspecified</a></li>
+<li> <a rel="mw:ExtLink" href="http://[::13.1.68.3]/ipv4compat">http://[::13.1.68.3]/ipv4compat</a></li>
+<li> <a rel="mw:ExtLink" href="http://[::FFFF:129.144.52.38]/ipv4compat">http://[::FFFF:129.144.52.38]/ipv4compat</a></li></ul>
+
+<p>Examples from <a href="//tools.ietf.org/html/rfc2732" rel="mw:ExtLink">RFC 2732</a>, section 2:</p>
+<ul><li> <a rel="mw:ExtLink" href="http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html">http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html</a></li>
+<li> <a rel="mw:ExtLink" href="http://[1080:0:0:0:8:800:200C:417A]/index.html">http://[1080:0:0:0:8:800:200C:417A]/index.html</a></li>
+<li> <a rel="mw:ExtLink" href="http://[3ffe:2a00:100:7031::1]">http://[3ffe:2a00:100:7031::1]</a></li>
+<li> <a rel="mw:ExtLink" href="http://[1080::8:800:200C:417A]/foo">http://[1080::8:800:200C:417A]/foo</a></li>
+<li> <a rel="mw:ExtLink" href="http://[::192.9.5.5]/ipng">http://[::192.9.5.5]/ipng</a></li>
+<li> <a rel="mw:ExtLink" href="http://[::FFFF:129.144.52.38]:80/index.html">http://[::FFFF:129.144.52.38]:80/index.html</a></li>
+<li> <a rel="mw:ExtLink" href="http://[2010:836B:4179::836B:4179]">http://[2010:836B:4179::836B:4179]</a></li></ul>
 !! end
 
 !! test
 !! end
 
 !! test
@@ -5389,7 +5410,7 @@ IPv6 urls, bracketed format (T23261)
 !! wikitext
 [http://[2404:130:0:1000::187:2]/index.php test]
 
 !! wikitext
 [http://[2404:130:0:1000::187:2]/index.php test]
 
-Examples from RFC2373, section 2.2:
+Examples from RFC 2373, section 2.2:
 * [http://[1080::8:800:200C:417A] unicast]
 * [http://[FF01::101] multicast]
 * [http://[::1]/ loopback]
 * [http://[1080::8:800:200C:417A] unicast]
 * [http://[FF01::101] multicast]
 * [http://[::1]/ loopback]
@@ -5406,9 +5427,9 @@ Examples from RFC 2732, section 2:
 * [http://[::FFFF:129.144.52.38]:80/index.html 6]
 * [http://[2010:836B:4179::836B:4179] 7]
 
 * [http://[::FFFF:129.144.52.38]:80/index.html 6]
 * [http://[2010:836B:4179::836B:4179] 7]
 
-!! html
+!! html/php
 <p><a rel="nofollow" class="external text" href="http://[2404:130:0:1000::187:2]/index.php">test</a>
 <p><a rel="nofollow" class="external text" href="http://[2404:130:0:1000::187:2]/index.php">test</a>
-</p><p>Examples from RFC2373, section 2.2:
+</p><p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc2373">RFC 2373</a>, section 2.2:
 </p>
 <ul><li> <a rel="nofollow" class="external text" href="http://[1080::8:800:200C:417A]">unicast</a></li>
 <li> <a rel="nofollow" class="external text" href="http://[FF01::101]">multicast</a></li>
 </p>
 <ul><li> <a rel="nofollow" class="external text" href="http://[1080::8:800:200C:417A]">unicast</a></li>
 <li> <a rel="nofollow" class="external text" href="http://[FF01::101]">multicast</a></li>
@@ -5426,6 +5447,25 @@ Examples from RFC 2732, section 2:
 <li> <a rel="nofollow" class="external text" href="http://[::FFFF:129.144.52.38]:80/index.html">6</a></li>
 <li> <a rel="nofollow" class="external text" href="http://[2010:836B:4179::836B:4179]">7</a></li></ul>
 
 <li> <a rel="nofollow" class="external text" href="http://[::FFFF:129.144.52.38]:80/index.html">6</a></li>
 <li> <a rel="nofollow" class="external text" href="http://[2010:836B:4179::836B:4179]">7</a></li></ul>
 
+!! html/parsoid
+<p><a rel="mw:ExtLink" href="http://[2404:130:0:1000::187:2]/index.php">test</a></p>
+
+<p>Examples from <a href="//tools.ietf.org/html/rfc2373" rel="mw:ExtLink">RFC 2373</a>, section 2.2:</p>
+<ul><li> <a rel="mw:ExtLink" href="http://[1080::8:800:200C:417A]">unicast</a></li>
+<li> <a rel="mw:ExtLink" href="http://[FF01::101]">multicast</a></li>
+<li> <a rel="mw:ExtLink" href="http://[::1]/">loopback</a></li>
+<li> <a rel="mw:ExtLink" href="http://[::]">unspecified</a></li>
+<li> <a rel="mw:ExtLink" href="http://[::13.1.68.3]">ipv4compat</a></li>
+<li> <a rel="mw:ExtLink" href="http://[::FFFF:129.144.52.38]">ipv4compat</a></li></ul>
+
+<p>Examples from <a href="//tools.ietf.org/html/rfc2732" rel="mw:ExtLink">RFC 2732</a>, section 2:</p>
+<ul><li> <a rel="mw:ExtLink" href="http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html">1</a></li>
+<li> <a rel="mw:ExtLink" href="http://[1080:0:0:0:8:800:200C:417A]/index.html">2</a></li>
+<li> <a rel="mw:ExtLink" href="http://[3ffe:2a00:100:7031::1]">3</a></li>
+<li> <a rel="mw:ExtLink" href="http://[1080::8:800:200C:417A]/foo">4</a></li>
+<li> <a rel="mw:ExtLink" href="http://[::192.9.5.5]/ipng">5</a></li>
+<li> <a rel="mw:ExtLink" href="http://[::FFFF:129.144.52.38]:80/index.html">6</a></li>
+<li> <a rel="mw:ExtLink" href="http://[2010:836B:4179::836B:4179]">7</a></li></ul>
 !! end
 
 !! test
 !! end
 
 !! test
@@ -5443,7 +5483,8 @@ Non-extlinks in brackets
 [{{echo|foo}}l's errand]
 [url={{echo|foo}}]
 [url=http://example.com]
 [{{echo|foo}}l's errand]
 [url={{echo|foo}}]
 [url=http://example.com]
-!! html
+[http:// bare protocols don't count]
+!! html/php
 <p>[foo]
 [foo bar]
 [foo <i>bar</i>]
 <p>[foo]
 [foo bar]
 [foo <i>bar</i>]
@@ -5456,7 +5497,22 @@ Non-extlinks in brackets
 [fool's errand]
 [url=foo]
 [url=<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>]
 [fool's errand]
 [url=foo]
 [url=<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>]
+[http:// bare protocols don't count]
 </p>
 </p>
+!! html/parsoid
+<p>[foo]
+[foo bar]
+[foo <i>bar</i>]
+[fool's] errand
+[fool's errand]
+[<span typeof="mw:Placeholder" data-parsoid='{"src":"{{echo|foo}}"}'>foo</span>]
+[<span typeof="mw:Placeholder" data-parsoid='{"src":"{{echo|foo}}"}'>foo</span> bar]
+[<span typeof="mw:Placeholder" data-parsoid='{"src":"{{echo|foo}}"}'>foo</span> <i>bar</i>]
+[<span typeof="mw:Placeholder" data-parsoid='{"src":"{{echo|foo}}l&#39;s"}'>fool's</span>] errand
+[<span typeof="mw:Placeholder" data-parsoid='{"src":"{{echo|foo}}l&#39;s"}'>fool's</span> errand]
+[<span typeof="mw:Placeholder" data-parsoid='{"src":"url={{echo|foo}}"}'>url=foo</span>]
+[url=<a rel="mw:ExtLink" href="http://example.com">http://example.com</a>]
+[http:// bare protocols don't count]</p>
 !! end
 
 !! test
 !! end
 
 !! test
@@ -6190,7 +6246,7 @@ Table cell attributes: Pipes protected by nowikis should be treated as a plain c
 | title="foo<nowiki>|</nowiki>" |bar
 | title="foo<nowiki>|</nowiki>" bar
 |}
 | title="foo<nowiki>|</nowiki>" |bar
 | title="foo<nowiki>|</nowiki>" bar
 |}
-!! html
+!! html/php
 <table>
 <tr>
 <td title="foo">bar
 <table>
 <tr>
 <td title="foo">bar
@@ -6200,12 +6256,19 @@ Table cell attributes: Pipes protected by nowikis should be treated as a plain c
 <td> title="foo|" bar
 </td></tr></table>
 
 <td> title="foo|" bar
 </td></tr></table>
 
+!! html/parsoid
+<table>
+<tbody><tr><td title="foo">bar</td>
+<td title="foo|" data-parsoid='{"a":{"title":"foo|"},"sa":{"title":"foo&lt;nowiki>|&lt;/nowiki>"},"autoInsertedEnd":true}'>bar</td>
+<td> title="foo<span typeof="mw:Nowiki">|</span>" bar</td></tr>
+</tbody></table>
 !! end
 
 !! end
 
-# The "|}" to close the table is missing from the input, so parsoid's
-# *2wt modes will fail.
+# See: http://lists.wikimedia.org/mailman/htdig/wikitech-l/2006-April/022293.html
+# N.B. The "|}" to close the table is missing from the input, so parsoid's
+#      *2wt modes will fail.
 !! test
 !! test
-Table security: embedded pipes (http://lists.wikimedia.org/mailman/htdig/wikitech-l/2006-April/022293.html)
+Table security: embedded pipes
 !! options
 parsoid=wt2html,html2html
 !! wikitext
 !! options
 parsoid=wt2html,html2html
 !! wikitext
@@ -6223,12 +6286,14 @@ parsoid=wt2html,html2html
 !! html/parsoid
 <table><tbody>
 <tr>
 !! html/parsoid
 <table><tbody>
 <tr>
-<td><a rel="mw:ExtLink" href="ftp://|x||"></a>" onmouseover="alert(document.cookie)">test</td></tr></tbody></table>
+<td data-parsoid='{"startTagSrc":"| ","attrSepSrc":"|","autoInsertedEnd":true}'><a rel="mw:ExtLink" href="ftp://|x||"></a>" onmouseover="alert(document.cookie)">test</td></tr></tbody></table>
 !! end
 
 !! end
 
-# FIXME: The php output is broken.
+# FIXME: The output seems broken. Filed as T110268.
 !! test
 ! and || in td attributes should not be parsed as <th>/<td>
 !! test
 ! and || in td attributes should not be parsed as <th>/<td>
+!! options
+parsoid=wt2html
 !! wikitext
 {|
 | style="color: red !important;" data-contrived="put this here ||" | foo
 !! wikitext
 {|
 | style="color: red !important;" data-contrived="put this here ||" | foo
@@ -6242,7 +6307,7 @@ parsoid=wt2html,html2html
 
 !! html/parsoid
 <table>
 
 !! html/parsoid
 <table>
-<tbody><tr><td style="color: red !important;" data-contrived="put this here ||" data-parsoid='{"autoInsertedEnd":true}'> foo</td></tr>
+<tbody><tr><td> style="color: red !important;" data-contrived="put this here </td><td data-parsoid='{"stx_v":"row","a":{"\"":null},"sa":{"\"":""},"autoInsertedEnd":true}'> foo</td></tr>
 </tbody></table>
 !! end
 
 </tbody></table>
 !! end
 
@@ -6859,9 +6924,6 @@ parsoid=wt2html,wt2wt
 </tbody></table>
 !! end
 
 </tbody></table>
 !! end
 
-
-# PHP throws away the (semi-broken) "foo" class here; Parsoid
-# preserves it.
 !!test
 Parsoid: Recover better from broken table attributes
 !!options
 !!test
 Parsoid: Recover better from broken table attributes
 !!options
@@ -6872,7 +6934,7 @@ parsoid=wt2html
 foo
 |}
 !!html/php+tidy
 foo
 |}
 !!html/php+tidy
-<table>
+<table class="foo">
 <tr>
 <td class="bar">
 <p>foo</p>
 <tr>
 <td class="bar">
 <p>foo</p>
@@ -6887,6 +6949,23 @@ foo
 </tbody></table>
 !!end
 
 </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
 !! test
 Strip unsupported table tags
 !! options
@@ -7097,8 +7176,10 @@ Link with HTML entity in suffix / tail
 Link with 3 brackets
 !! wikitext
 [[[Main Page]]]
 Link with 3 brackets
 !! wikitext
 [[[Main Page]]]
+Foo [[[Main Page]]]
 !! html
 <p>[[[Main Page]]]
 !! html
 <p>[[[Main Page]]]
+Foo [[[Main Page]]]
 </p>
 !! end
 
 </p>
 !! end
 
@@ -9877,27 +9958,33 @@ __proto__
 Magic links: internal link to RFC (bug 479)
 !! wikitext
 [[RFC 123]]
 Magic links: internal link to RFC (bug 479)
 !! wikitext
 [[RFC 123]]
-!! html
+!! html/php
 <p><a href="/index.php?title=RFC_123&amp;action=edit&amp;redlink=1" class="new" title="RFC 123 (page does not exist)">RFC 123</a>
 </p>
 <p><a href="/index.php?title=RFC_123&amp;action=edit&amp;redlink=1" class="new" title="RFC 123 (page does not exist)">RFC 123</a>
 </p>
+!! html/parsoid
+<p><a rel="mw:WikiLink" href="./RFC_123" title="RFC 123">RFC 123</a></p>
 !! end
 
 !! test
 Magic links: RFC (bug 479)
 !! wikitext
 RFC 822
 !! end
 
 !! test
 Magic links: RFC (bug 479)
 !! wikitext
 RFC 822
-!! html
+!! html/php
 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc822">RFC 822</a>
 </p>
 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc822">RFC 822</a>
 </p>
+!! html/parsoid
+<p><a href="//tools.ietf.org/html/rfc822" rel="mw:ExtLink">RFC 822</a></p>
 !! end
 
 !! test
 Magic links: RFC (bug 65278)
 !! wikitext
 This is RFC 822 but thisRFC 822 is not RFC 822linked.
 !! end
 
 !! test
 Magic links: RFC (bug 65278)
 !! wikitext
 This is RFC 822 but thisRFC 822 is not RFC 822linked.
-!! html
+!! html/php
 <p>This is <a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc822">RFC 822</a> but thisRFC 822 is not RFC 822linked.
 </p>
 <p>This is <a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc822">RFC 822</a> but thisRFC 822 is not RFC 822linked.
 </p>
+!! html/parsoid
+<p>This is <a href="//tools.ietf.org/html/rfc822" rel="mw:ExtLink">RFC 822</a> but thisRFC 822 is not RFC 822linked.</p>
 !! end
 
 !! test
 !! end
 
 !! test
@@ -9906,20 +9993,26 @@ Magic links: RFC (w/ non-newline whitespace, bug 28950/29025)
 RFC &nbsp;&#160;&#0160;&#xA0;&#Xa0; 822
 RFC
 822
 RFC &nbsp;&#160;&#0160;&#xA0;&#Xa0; 822
 RFC
 822
-!! html
+!! html/php
 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc822">RFC 822</a>
 RFC
 822
 </p>
 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc822">RFC 822</a>
 RFC
 822
 </p>
+!! html/parsoid
+<p><a href="//tools.ietf.org/html/rfc822" rel="mw:ExtLink">RFC <span typeof="mw:Entity" data-parsoid='{"src":"&amp;nbsp;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#160;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#0160;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#xA0;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#Xa0;","srcContent":" "}'> </span> 822</a>
+RFC
+822</p>
 !! end
 
 !! test
 Magic links: ISBN (bug 1937)
 !! wikitext
 ISBN 0-306-40615-2
 !! end
 
 !! test
 Magic links: ISBN (bug 1937)
 !! wikitext
 ISBN 0-306-40615-2
-!! html
+!! html/php
 <p><a href="/wiki/Special:BookSources/0306406152" class="internal mw-magiclink-isbn">ISBN 0-306-40615-2</a>
 </p>
 <p><a href="/wiki/Special:BookSources/0306406152" class="internal mw-magiclink-isbn">ISBN 0-306-40615-2</a>
 </p>
+!! html/parsoid
+<p><a href="./Special:BookSources/0306406152" rel="mw:WikiLink">ISBN 0-306-40615-2</a></p>
 !! end
 
 !! test
 !! end
 
 !! test
@@ -9930,7 +10023,7 @@ This is ISBN 978-0-316-09811-3 but thisISBN 978-0-316-09811-3 is not ISBN 978-0-
 <p>This is <a href="/wiki/Special:BookSources/9780316098113" class="internal mw-magiclink-isbn">ISBN 978-0-316-09811-3</a> but thisISBN 978-0-316-09811-3 is not ISBN 978-0-316-09811-3linked.
 </p>
 !! html/parsoid
 <p>This is <a href="/wiki/Special:BookSources/9780316098113" class="internal mw-magiclink-isbn">ISBN 978-0-316-09811-3</a> but thisISBN 978-0-316-09811-3 is not ISBN 978-0-316-09811-3linked.
 </p>
 !! html/parsoid
-<p>This is <a href="./Special:BookSources/9780316098113" rel="mw:ExtLink">ISBN 978-0-316-09811-3</a> but thisISBN 978-0-316-09811-3 is not ISBN 978-0-316-09811-3linked.</p>
+<p>This is <a href="./Special:BookSources/9780316098113" rel="mw:WikiLink">ISBN 978-0-316-09811-3</a> but thisISBN 978-0-316-09811-3 is not ISBN 978-0-316-09811-3linked.</p>
 !! end
 
 !! test
 !! end
 
 !! test
@@ -9941,31 +10034,41 @@ ISBN
 9780316098113
 ISBN 978
 0316098113
 9780316098113
 ISBN 978
 0316098113
-!! html
+!! html/php
 <p><a href="/wiki/Special:BookSources/9780316098113" class="internal mw-magiclink-isbn">ISBN 978 0 316 09811 3</a>
 ISBN
 9780316098113
 ISBN 978
 0316098113
 </p>
 <p><a href="/wiki/Special:BookSources/9780316098113" class="internal mw-magiclink-isbn">ISBN 978 0 316 09811 3</a>
 ISBN
 9780316098113
 ISBN 978
 0316098113
 </p>
+!! html/parsoid
+<p><a href="./Special:BookSources/9780316098113" rel="mw:WikiLink">ISBN <span typeof="mw:Entity" data-parsoid='{"src":"&amp;nbsp;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#160;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#0160;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#xA0;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#Xa0;","srcContent":" "}'> </span> 978<span typeof="mw:Entity" data-parsoid='{"src":"&amp;nbsp;","srcContent":" "}'> </span>0<span typeof="mw:Entity" data-parsoid='{"src":"&amp;#160;","srcContent":" "}'> </span>316<span typeof="mw:Entity" data-parsoid='{"src":"&amp;#0160;","srcContent":" "}'> </span>09811<span typeof="mw:Entity" data-parsoid='{"src":"&amp;#xA0;","srcContent":" "}'> </span>3</a>
+ISBN
+9780316098113
+ISBN 978
+0316098113</p>
 !! end
 
 !! test
 Magic links: PMID incorrectly converts space to underscore
 !! wikitext
 PMID 1234
 !! end
 
 !! test
 Magic links: PMID incorrectly converts space to underscore
 !! wikitext
 PMID 1234
-!! html
+!! html/php
 <p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract">PMID 1234</a>
 </p>
 <p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract">PMID 1234</a>
 </p>
+!! html/parsoid
+<p><a href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract" rel="mw:ExtLink">PMID 1234</a></p>
 !! end
 
 !! test
 Magic links: PMID (bug 65278)
 !! wikitext
 This is PMID 1234 but thisPMID 1234 is not PMID 1234linked.
 !! end
 
 !! test
 Magic links: PMID (bug 65278)
 !! wikitext
 This is PMID 1234 but thisPMID 1234 is not PMID 1234linked.
-!! html
+!! html/php
 <p>This is <a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract">PMID 1234</a> but thisPMID 1234 is not PMID 1234linked.
 </p>
 <p>This is <a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract">PMID 1234</a> but thisPMID 1234 is not PMID 1234linked.
 </p>
+!! html/parsoid
+<p>This is <a href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract" rel="mw:ExtLink">PMID 1234</a> but thisPMID 1234 is not PMID 1234linked.</p>
 !! end
 
 !! test
 !! end
 
 !! test
@@ -9974,11 +10077,15 @@ Magic links: PMID (w/ non-newline whitespace, bug 28950/29025)
 PMID &nbsp;&#160;&#0160;&#xA0;&#Xa0; 1234
 PMID
 1234
 PMID &nbsp;&#160;&#0160;&#xA0;&#Xa0; 1234
 PMID
 1234
-!! html
+!! html/php
 <p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract">PMID 1234</a>
 PMID
 1234
 </p>
 <p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract">PMID 1234</a>
 PMID
 1234
 </p>
+!! html/parsoid
+<p><a href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract" rel="mw:ExtLink">PMID <span typeof="mw:Entity" data-parsoid='{"src":"&amp;nbsp;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#160;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#0160;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#xA0;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#Xa0;","srcContent":" "}'> </span> 1234</a>
+PMID
+1234</p>
 !! end
 
 ###
 !! end
 
 ###
@@ -10476,6 +10583,15 @@ int keyword
 </p>
 !! end
 
 </p>
 !! end
 
+!! test
+int keyword - non-existing message
+!! wikitext
+{{int:var}}
+!! html
+<p>&lt;var&gt;
+</p>
+!! end
+
 !! article
 Template:Includes
 !! text
 !! article
 Template:Includes
 !! text
@@ -13258,7 +13374,7 @@ BUG 1887: A ISBN with a thumbnail
 <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"></a></div><a href="/wiki/Special:BookSources/1235467890" class="internal mw-magiclink-isbn">ISBN 1235467890</a></div></div></div>
 
 !! html/parsoid
 <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"></a></div><a href="/wiki/Special:BookSources/1235467890" class="internal mw-magiclink-isbn">ISBN 1235467890</a></div></div></div>
 
 !! 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><a href="./Special:BookSources/1235467890" rel="mw:ExtLink">ISBN 1235467890</a></figcaption></figure>
+<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><a href="./Special:BookSources/1235467890" rel="mw:WikiLink">ISBN 1235467890</a></figcaption></figure>
 !! end
 
 !! test
 !! end
 
 !! test
@@ -13333,7 +13449,7 @@ T107474: Frameless image caption with <nowiki>
 !! wikitext
 [[File:Foobar.jpg|<nowiki>text with a [[MeatBall:Link|link]] in it</nowiki>]]
 !! html/parsoid
 !! wikitext
 [[File:Foobar.jpg|<nowiki>text with a [[MeatBall:Link|link]] in it</nowiki>]]
 !! html/parsoid
-<p><span class="mw-default-size" typeof="mw:Image mw:Placeholder" data-mw='{"caption":"&lt;span typeof=\"mw:Nowiki\">text with a [[MeatBall:Link|link]] in it&lt;/span>"}'><a href="./File:Foobar.jpg"><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"/></a></span></p>
+<p><span class="mw-default-size" typeof="mw:Image" data-mw='{"caption":"&lt;span typeof=\"mw:Nowiki\" data-parsoid=\"{&amp;quot;dsr&amp;quot;:[18,75,8,9]}\">text with a [[MeatBall:Link|link]] in it&lt;/span>"}'><a href="./File:Foobar.jpg"><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"/></a></span></p>
 !! end
 
 !! test
 !! end
 
 !! test
@@ -13756,6 +13872,42 @@ bar
 bar</p>
 !! end
 
 bar</p>
 !! end
 
+## Edge case bugs in Parsoid from T93580
+!! test
+T93580: 1. Templated <ref> inside block images
+!! wikitext
+[[File:Foobar.jpg|thumb|Caption with templated ref: {{echo|<ref>foo</ref>}}]]
+
+<references />
+!! html/parsoid
+<figure class="mw-default-size" typeof="mw:Image/Thumb" data-parsoid='{"optList":[{"ck":"thumbnail","ak":"thumb"},{"ck":"caption","ak":"Caption with templated ref: {{echo|&lt;ref>foo&lt;/ref>}}"}]}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{}}'><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" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"25","width":"220"},"sa":{"resource":"File:Foobar.jpg"}}'/></a><figcaption>Caption with templated ref: <span about="#mwt5" class="mw-ref" id="cite_ref-1" rel="dc:references" typeof="mw:Transclusion  mw:Extension/ref" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;ref>foo&lt;/ref>"}},"i":0}}]}'><a href="#cite_note-1" style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a></span></figcaption></figure>
+
+<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: &lt;ref>foo&lt;/ref>"}]}' data-mw='{"caption":"Undisplayed caption in inline image with ref: &lt;span about=\"#mwt2\" class=\"mw-ref\" id=\"cite_ref-1\" rel=\"dc:references\" typeof=\"mw:Extension/ref\" data-parsoid=\"{&amp;quot;dsr&amp;quot;:[64,78,5,6]}\" data-mw=\"{&amp;quot;name&amp;quot;:&amp;quot;ref&amp;quot;,&amp;quot;body&amp;quot;:{&amp;quot;id&amp;quot;:&amp;quot;mw-reference-text-cite_note-1&amp;quot;},&amp;quot;attrs&amp;quot;:{}}\">&lt;a href=\"#cite_note-1\" style=\"counter-reset: mw-Ref 1;\">&lt;span class=\"mw-reflink-text\">[1]&lt;/span>&lt;/a>&lt;/span>&lt;meta typeof=\"mw:Extension/ref/Marker\" about=\"#mwt2\" data-parsoid=\"{&amp;quot;group&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;content&amp;quot;:&amp;quot;foo&amp;quot;,&amp;quot;hasRefInRef&amp;quot;:false,&amp;quot;dsr&amp;quot;:[64,78,5,6],&amp;quot;tmp&amp;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|&lt;ref>{{echo|foo}}&lt;/ref>}}"}]}' data-mw='{"caption":"Undisplayed caption in inline image with ref: &lt;span about=\"#mwt2\" class=\"mw-ref\" id=\"cite_ref-1\" rel=\"dc:references\" typeof=\"mw:Transclusion  mw:Extension/ref\" data-parsoid=\"{&amp;quot;dsr&amp;quot;:[64,96,null,null],&amp;quot;pi&amp;quot;:[[{&amp;quot;k&amp;quot;:&amp;quot;1&amp;quot;,&amp;quot;spc&amp;quot;:[&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,&amp;quot;&amp;quot;]}]]}\" data-mw=\"{&amp;quot;parts&amp;quot;:[{&amp;quot;template&amp;quot;:{&amp;quot;target&amp;quot;:{&amp;quot;wt&amp;quot;:&amp;quot;echo&amp;quot;,&amp;quot;href&amp;quot;:&amp;quot;./Template:Echo&amp;quot;},&amp;quot;params&amp;quot;:{&amp;quot;1&amp;quot;:{&amp;quot;wt&amp;quot;:&amp;quot;&lt;ref>{{echo|foo}}&lt;/ref>&amp;quot;}},&amp;quot;i&amp;quot;:0}}]}\">&lt;a href=\"#cite_note-1\" style=\"counter-reset: mw-Ref 1;\">&lt;span class=\"mw-reflink-text\">[1]&lt;/span>&lt;/a>&lt;/span>&lt;meta typeof=\"mw:Transclusion mw:Extension/ref/Marker\" about=\"#mwt2\" data-parsoid=\"{&amp;quot;group&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;content&amp;quot;:&amp;quot;foo&amp;quot;,&amp;quot;hasRefInRef&amp;quot;:false,&amp;quot;dsr&amp;quot;:[64,96,null,null],&amp;quot;pi&amp;quot;:[[{&amp;quot;k&amp;quot;:&amp;quot;1&amp;quot;,&amp;quot;spc&amp;quot;:[&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,&amp;quot;&amp;quot;]}]],&amp;quot;tmp&amp;quot;:{}}\" data-mw=\"{&amp;quot;parts&amp;quot;:[{&amp;quot;template&amp;quot;:{&amp;quot;target&amp;quot;:{&amp;quot;wt&amp;quot;:&amp;quot;echo&amp;quot;,&amp;quot;href&amp;quot;:&amp;quot;./Template:Echo&amp;quot;},&amp;quot;params&amp;quot;:{&amp;quot;1&amp;quot;:{&amp;quot;wt&amp;quot;:&amp;quot;&lt;ref>{{echo|foo}}&lt;/ref>&amp;quot;}},&amp;quot;i&amp;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
 
 ###
 ### Subpages
@@ -15757,6 +15909,7 @@ MSIE 6 CSS safety test: sup/sub script (bug 55332)
 
 !! end
 
 
 !! end
 
+# FIXME: Parsoid fails to sanitize this! See T58846.
 !! test
 Opera -o-link CSS
 !! wikitext
 !! test
 Opera -o-link CSS
 !! wikitext
@@ -18216,7 +18369,7 @@ ISBN  978-0-1234-56&#x20;789
 !! html+tidy
 <p><a href="/wiki/Special:BookSources/9780123456" class="internal mw-magiclink-isbn">ISBN 978-0-1234-56</a> 789</p>
 !! html/parsoid
 !! html+tidy
 <p><a href="/wiki/Special:BookSources/9780123456" class="internal mw-magiclink-isbn">ISBN 978-0-1234-56</a> 789</p>
 !! html/parsoid
-<p><a href="./Special:BookSources/9780123456" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>ISBN 978-0-1234-56</a><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#x20;","srcContent":" "}'> </span>789</p>
+<p><a href="./Special:BookSources/9780123456" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 978-0-1234-56</a><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#x20;","srcContent":" "}'> </span>789</p>
 !! end
 
 !! test
 !! end
 
 !! test
@@ -18236,7 +18389,7 @@ ISBN ISBN 1234567890
 <p>ISBN <a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
 </p>
 !! html/parsoid
 <p>ISBN <a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
 </p>
 !! html/parsoid
-<p>ISBN <a href="./Special:BookSources/1234567890" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a></p>
+<p>ISBN <a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a></p>
 !! end
 
 # Uppercase X and lowercase x as well
 !! end
 
 # Uppercase X and lowercase x as well
@@ -18258,12 +18411,12 @@ ISBN 978080442957x
 <a href="/wiki/Special:BookSources/978080442957X" class="internal mw-magiclink-isbn">ISBN 978080442957x</a>
 </p>
 !! html/parsoid
 <a href="/wiki/Special:BookSources/978080442957X" class="internal mw-magiclink-isbn">ISBN 978080442957x</a>
 </p>
 !! html/parsoid
-<p><a href="./Special:BookSources/346204561X" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>ISBN 3-462-04561-X</a>
-<a href="./Special:BookSources/346204561X" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>ISBN 3-462-04561-x</a>
-<a href="./Special:BookSources/080442957X" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>ISBN 080442957X</a>
-<a href="./Special:BookSources/080442957X" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>ISBN 080442957x</a>
-<a href="./Special:BookSources/978080442957X" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>ISBN 978080442957X</a>
-<a href="./Special:BookSources/978080442957X" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>ISBN 978080442957x</a></p>
+<p><a href="./Special:BookSources/346204561X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 3-462-04561-X</a>
+<a href="./Special:BookSources/346204561X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 3-462-04561-x</a>
+<a href="./Special:BookSources/080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 080442957X</a>
+<a href="./Special:BookSources/080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 080442957x</a>
+<a href="./Special:BookSources/978080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 978080442957X</a>
+<a href="./Special:BookSources/978080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 978080442957x</a></p>
 !! end
 
 !! test
 !! end
 
 !! test
@@ -18274,7 +18427,7 @@ ISBN 1234567890
 <p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
 </p>
 !! html/parsoid
 <p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
 </p>
 !! html/parsoid
-<p><a href="./Special:BookSources/1234567890" rel="mw:ExtLink">ISBN 1234567890</a></p>
+<p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink">ISBN 1234567890</a></p>
 !! end
 
 !! test
 !! end
 
 !! test
@@ -18285,7 +18438,7 @@ Bug 22905: <abbr> followed by ISBN followed by </a>
 <p><abbr>(fr)</abbr> <a href="/wiki/Special:BookSources/2753300917" class="internal mw-magiclink-isbn">ISBN 2753300917</a> <a rel="nofollow" class="external text" href="http://www.example.com">example.com</a>
 </p>
 !! html/parsoid
 <p><abbr>(fr)</abbr> <a href="/wiki/Special:BookSources/2753300917" class="internal mw-magiclink-isbn">ISBN 2753300917</a> <a rel="nofollow" class="external text" href="http://www.example.com">example.com</a>
 </p>
 !! html/parsoid
-<p><abbr data-parsoid='{"stx":"html"}'>(fr)</abbr> <a href="./Special:BookSources/2753300917" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>ISBN 2753300917</a> <a rel="mw:ExtLink" href="http://www.example.com">example.com</a></p>
+<p><abbr data-parsoid='{"stx":"html"}'>(fr)</abbr> <a href="./Special:BookSources/2753300917" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 2753300917</a> <a rel="mw:ExtLink" href="http://www.example.com">example.com</a></p>
 !! end
 
 !! test
 !! end
 
 !! test
@@ -20579,14 +20732,18 @@ __TOC__
 <p><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Edit section: Foo Bar">edit</a><span class="mw-editsection-bracket">]</span></span></p>
 !! end
 
 <p><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Edit section: Foo Bar">edit</a><span class="mw-editsection-bracket">]</span></span></p>
 !! end
 
+# Don't expect Parsoid to roundtrip this until the php parser comes closer to
+# html5 tag parsing.
 !! test
 Tags with parameters in TOC
 !! test
 Tags with parameters in TOC
+!! options
+parsoid=wt2html
 !! wikitext
 __TOC__
 == <sup class="in-h2">Hello</sup> ==
 
 == <sup class="a > b">Evilbye</sup> ==
 !! wikitext
 __TOC__
 == <sup class="in-h2">Hello</sup> ==
 
 == <sup class="a > b">Evilbye</sup> ==
-!! html
+!! html/php
 <div id="toc" class="toc"><div id="toctitle"><h2>Contents</h2></div>
 <ul>
 <li class="toclevel-1 tocsection-1"><a href="#Hello"><span class="tocnumber">1</span> <span class="toctext"><sup>Hello</sup></span></a></li>
 <div id="toc" class="toc"><div id="toctitle"><h2>Contents</h2></div>
 <ul>
 <li class="toclevel-1 tocsection-1"><a href="#Hello"><span class="tocnumber">1</span> <span class="toctext"><sup>Hello</sup></span></a></li>
@@ -20595,8 +20752,13 @@ __TOC__
 </div>
 
 <h2><span class="mw-headline" id="Hello"><sup class="in-h2">Hello</sup></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: Hello">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
 </div>
 
 <h2><span class="mw-headline" id="Hello"><sup class="in-h2">Hello</sup></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: Hello">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
-<h2><span class="mw-headline" id="b.22.3EEvilbye"><sup> b"&gt;Evilbye</sup></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Edit section: b&quot;&gt;Evilbye">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
+<h2><span class="mw-headline" id="b.22.3EEvilbye"><sup class="a"> b"&gt;Evilbye</sup></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Edit section: b&quot;&gt;Evilbye">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
+
+!! html/parsoid
+<meta property="mw:PageProp/toc" />
+<h2> <sup class="in-h2" data-parsoid='{"stx":"html"}'>Hello</sup> </h2>
 
 
+<h2> <sup class="a " data-parsoid='{"stx":"html"}'> b">Evilbye</sup> </h2>
 !! end
 
 !! test
 !! end
 
 !! test
@@ -21795,23 +21957,23 @@ Empty TR nodes should not be stripped if they have any attributes set
 !! test
 Headings: 0. Unnested
 !! options
 !! 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>
 
 !! wikitext
 <nowiki>=foo=</nowiki>
 
-<nowiki> =foo= </nowiki>
+<nowiki> </nowiki>=foo=
 <!--cmt-->
 <nowiki>=foo=</nowiki>
 
 =foo''a''<nowiki>=</nowiki>
 <!--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
 !!end
 
 # New headings and existing headings are handled differently
@@ -21868,15 +22030,26 @@ parsoid=html2wt
 !! test
 Headings: 3. Nested inside html with wikitext split by html tags
 !! options
 !! 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>
 !! 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)
 !!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 =
 
 !! wikitext
 = =foo =
 
@@ -21893,15 +22066,6 @@ Headings: 4a. No escaping needed (testing just h1 and h2)
 = = =
 
 = ''=''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
 !!end
 
 !! test
@@ -21921,6 +22085,20 @@ parsoid=html2wt
 
 !! test
 Headings: 5. Empty headings
 
 !! 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/>=
 
 !! wikitext
 =<nowiki/>=
 
@@ -21933,112 +22111,74 @@ Headings: 5. Empty headings
 =====<nowiki/>=====
 
 ======<nowiki/>======
 =====<nowiki/>=====
 
 ======<nowiki/>======
-!! html/parsoid
-<h1 data-parsoid='{}'><meta typeof="mw:Placeholder" data-parsoid='{"src":"&lt;nowiki/>"}'/></h1>
-
-<h2 data-parsoid='{}'><meta typeof="mw:Placeholder" data-parsoid='{"src":"&lt;nowiki/>"}'/></h2>
-
-<h3 data-parsoid='{}'><meta typeof="mw:Placeholder" data-parsoid='{"src":"&lt;nowiki/>"}'/></h3>
-
-<h4 data-parsoid='{}'><meta typeof="mw:Placeholder" data-parsoid='{"src":"&lt;nowiki/>"}'/></h4>
-
-<h5 data-parsoid='{}'><meta typeof="mw:Placeholder" data-parsoid='{"src":"&lt;nowiki/>"}'/></h5>
-
-<h6 data-parsoid='{}'><meta typeof="mw:Placeholder" data-parsoid='{"src":"&lt;nowiki/>"}'/></h6>
 !!end
 
 !! test
 Headings: 6a. Heading chars in SOL context (with trailing spaces)
 !!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>   
 !! 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)
 !!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
 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)
 !!end
 
 !! test
 Headings: 6c. Heading chars in SOL context (leading newline break)
-!! wikitext
-a
-<nowiki>=b=</nowiki>
-!! html/php
-<p>a
-=b=
-</p>
+!! options
+parsoid=html2wt
 !! html/parsoid
 <p>a
 !! html/parsoid
 <p>a
-<span typeof="mw:Nowiki">=b=</span>
+=b=</p>
+!! wikitext
+a
+<nowiki>=b=</nowiki>
 !!end
 
 !! test
 Headings: 6d. Heading chars in SOL context (with interspersed comments)
 !!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-->
 !! 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
 !!end
 
 !! test
 
 !! test
 Lists: 0. Outside nests
 
 !! 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
 
 !! 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
 !!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>
 
 !! wikitext
 *<nowiki>*foo</nowiki>
 
@@ -22119,20 +22268,19 @@ Lists: 1. Nested inside html
 #<nowiki>:foo</nowiki>
 
 #<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
 !!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>
 
 !! wikitext
 ;<nowiki>;foo</nowiki>
 
@@ -22142,40 +22290,27 @@ Lists: 2. Inside definition lists
 :bar
 
 :<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
 !!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
 !! 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
 !!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>
 <ul>
 <li>foo*bar
 </li>
@@ -22192,10 +22327,29 @@ parsoid
 <li><a rel="mw:WikiLink" href="Foo" title="Foo">Foo</a>*bar
 </li>
 </ul>
 <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
 !!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>
 
 !! wikitext
 * bar <span><nowiki>[[foo]]</nowiki></span>
 
@@ -22210,15 +22364,6 @@ Lists: 5. No unnecessary escapes
 * <s></s>: a
 
 * ''* foo''
 * <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
 !!end
 
 !! test
@@ -22233,13 +22378,15 @@ parsoid=html2wt
 
 !! test
 Lists: 7. Escape bullets in a multi-line context
 
 !! 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>
 <p>a
 *b
 </p>
+!! wikitext
+a
+<nowiki>*</nowiki>b
 !!end
 
 !! test
 !!end
 
 !! test
@@ -22258,17 +22405,16 @@ parsoid=html2wt
 
 !! test
 HRs: 1. Single line
 
 !! test
 HRs: 1. Single line
+!! options
+parsoid=html2wt
+!! html/parsoid
+<hr />----
+<hr />=foo=
+<hr />*foo
 !! wikitext
 ----<nowiki>----</nowiki>
 ----=foo=
 ----*foo
 !! wikitext
 ----<nowiki>----</nowiki>
 ----=foo=
 ----*foo
-!! html+tidy
-<hr />
-<p>----</p>
-<hr />
-<p>=foo=</p>
-<hr />
-<p>*foo</p>
 !! end
 
 #### --------------- Tables ---------------
 !! end
 
 #### --------------- Tables ---------------
@@ -22292,40 +22438,48 @@ HRs: 1. Single line
 
 !! test
 Tables: 1a. Simple example
 
 !! test
 Tables: 1a. Simple example
-!! wikitext
-<nowiki>{|
-|}</nowiki>
-!! html
+!! options
+parsoid=html2wt
+!! html/parsoid
 <p>{|
 |}
 </p>
 <p>{|
 |}
 </p>
+!! wikitext
+<nowiki>{|</nowiki>
+|}
 !! end
 
 !! test
 Tables: 1b. No escaping needed
 !! end
 
 !! test
 Tables: 1b. No escaping needed
-!! wikitext
-!foo
-!! html
+!! options
+parsoid=html2wt
+!! html/parsoid
 <p>!foo
 </p>
 <p>!foo
 </p>
+!! wikitext
+!foo
 !! end
 
 !! test
 Tables: 1c. No escaping needed
 !! end
 
 !! test
 Tables: 1c. No escaping needed
-!! wikitext
-|foo
-!! html
+!! options
+parsoid=html2wt
+!! html/parsoid
 <p>|foo
 </p>
 <p>|foo
 </p>
+!! wikitext
+|foo
 !! end
 
 !! test
 Tables: 1d. No escaping needed
 !! end
 
 !! test
 Tables: 1d. No escaping needed
-!! wikitext
-|}foo
-!! html
+!! options
+parsoid=html2wt
+!! html/parsoid
 <p>|}foo
 </p>
 <p>|}foo
 </p>
+!! wikitext
+|}foo
 !! end
 
 !! test
 !! end
 
 !! test
@@ -22386,11 +22540,8 @@ parsoid=html2wt
 
 !! test
 Tables: 2c. Nested in td -- no escaping needed
 
 !! test
 Tables: 2c. Nested in td -- no escaping needed
-!! wikitext
-{|
-
-|foo!!bar
-|}
+!! options
+parsoid=html2wt
 !! html/*
 <table>
 
 !! html/*
 <table>
 
@@ -22398,15 +22549,17 @@ Tables: 2c. Nested in td -- no escaping needed
 <td>foo!!bar
 </td></tr></table>
 
 <td>foo!!bar
 </td></tr></table>
 
-!! end
-
-!! test
-Tables: 3a. Nested in th
 !! wikitext
 {|
 
 !! wikitext
 {|
 
-!foo!bar
+|foo!!bar
 |}
 |}
+!! end
+
+!! test
+Tables: 3a. Nested in th
+!! options
+parsoid=html2wt
 !! html/*
 <table>
 
 !! html/*
 <table>
 
@@ -22414,6 +22567,11 @@ Tables: 3a. Nested in th
 <th>foo!bar
 </th></tr></table>
 
 <th>foo!bar
 </th></tr></table>
 
+!! wikitext
+{|
+
+!foo!bar
+|}
 !! end
 
 !! test
 !! end
 
 !! test
@@ -22522,6 +22680,19 @@ parsoid=html2wt
 
 !! test
 Tables: 4c. No escaping needed
 
 !! 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
 !! wikitext
 {|
 |foo-bar
@@ -22562,21 +22733,18 @@ bar|baz
 <div>a|b</div>
 </td></tr></table>
 
 <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
 !! 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
 !! wikitext
 {|
 |[[Foo]]-bar
@@ -22593,29 +22761,6 @@ Tables: 4d. No escaping needed
 <td>-2
 </td></tr></table>
 
 <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
 !! end
 
 !! test
@@ -22627,11 +22772,18 @@ parsoid=html2wt
 |** Make this another long long long sentence forcing the nowiki algo to split up the nowikis.</p>
 !! wikitext
 <nowiki>*</nowiki>This is a long sentence here that will make the nowiki algo split up the nowikis into multiple pairs
 |** Make this another long long long sentence forcing the nowiki algo to split up the nowikis.</p>
 !! wikitext
 <nowiki>*</nowiki>This is a long sentence here that will make the nowiki algo split up the nowikis into multiple pairs
-<nowiki>|</nowiki>** Make this another long long long sentence forcing the nowiki algo to split up the nowikis.
+|** Make this another long long long sentence forcing the nowiki algo to split up the nowikis.
 !! end
 
 !! test
 Unclosed xmlish element in table line shouldn't eat end delimiters
 !! end
 
 !! test
 Unclosed xmlish element in table line shouldn't eat end delimiters
+!! options
+parsoid=html2wt
+!! html/parsoid
+<table>
+<tbody><tr><td> &lt;foo</td>
+<td> bar></td></tr>
+</tbody></table>
 !! wikitext
 {|
 | <foo
 !! wikitext
 {|
 | <foo
@@ -22645,11 +22797,6 @@ Unclosed xmlish element in table line shouldn't eat end delimiters
 <td> bar&gt;
 </td></tr></table>
 
 <td> bar&gt;
 </td></tr></table>
 
-!! html/parsoid
-<table>
-<tbody><tr><td> &lt;foo</td>
-<td> bar></td></tr>
-</tbody></table>
 !! end
 
 #### --------------- Links ----------------
 !! end
 
 #### --------------- Links ----------------
@@ -22661,6 +22808,12 @@ Unclosed xmlish element in table line shouldn't eat end delimiters
 #### --------------------------------------
 !! test
 Links 1. WikiLinks: No escapes needed
 #### --------------------------------------
 !! 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]]]
 !! wikitext
 [[Foo|Foo''boo'']]
 [[Foo|[Foobar]]]
@@ -22670,10 +22823,6 @@ Links 1. WikiLinks: No escapes needed
 <a href="/wiki/Foo" title="Foo">[Foobar]</a>
 <a href="/wiki/Foo" title="Foo">x [Foobar] x</a>
 </p>
 <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
 !! end
 
 !! test
@@ -22718,6 +22867,11 @@ parsoid=html2wt
 
 !! test
 Links 3. WikiLinks: No escapes needed
 
 !! 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]]
 !! wikitext
 [[Foo|[Foobar]]
 [[Foo|foo|bar]]
@@ -22725,9 +22879,6 @@ Links 3. WikiLinks: No escapes needed
 <p><a href="/wiki/Foo" title="Foo">[Foobar</a>
 <a href="/wiki/Foo" title="Foo">foo|bar</a>
 </p>
 <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
 !! end
 
 !! test
@@ -22757,17 +22908,21 @@ parsoid=html2wt
 
 !! test
 Links 5. ExtLinks: No escapes needed
 
 !! 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>
 !! 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)
 !! 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
 !! 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
@@ -22801,6 +22956,8 @@ http://example.com(x<nowiki/>)
 
 !! test
 Links 7a. Don't add spurious <nowiki/>s between text-nodes and url-links (bug 64300)
 
 !! 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>
 !! 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)
 
 !! 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>
 !! 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>
@@ -22848,6 +23007,8 @@ http://example.com.,;:!?\
 
 !! test
 Links 8. Add <nowiki/>s between text-nodes and RFC-links when required (bug 64300)
 
 !! 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
 !! 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
@@ -22860,6 +23021,8 @@ X<nowiki/>RFC 123<nowiki/>y
 
 !! test
 Links 9. Don't add spurious <nowiki/>s between text-nodes and RFC-links (bug 64300)
 
 !! 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>&amp;foo
 !! 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>&amp;foo
@@ -22878,6 +23041,8 @@ RFC 123&foo
 
 !! test
 Links 10. Add <nowiki/>s between text-nodes and PMID-links when required (bug 64300)
 
 !! 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
 !! 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
@@ -22890,6 +23055,8 @@ X<nowiki/>PMID 123<nowiki/>y
 
 !! test
 Links 11. Don't add spurious <nowiki/>s between text-nodes and PMID-links (bug 64300)
 
 !! 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
 !! 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
@@ -22908,10 +23075,12 @@ PMID 123&foo
 
 !! test
 Links 12. Add <nowiki/>s between text-nodes and ISBN-links when required (bug 64300)
 
 !! test
 Links 12. Add <nowiki/>s between text-nodes and ISBN-links when required (bug 64300)
+!! options
+parsoid=html2wt
 !! html/parsoid
 !! html/parsoid
-<p><a href="./Special:BookSources/1234567890" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>1
-<a href="./Special:BookSources/1234567890" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>x
-a<a href="./Special:BookSources/1234567890" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>b
+<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
+a<a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>b
 </p>
 !! wikitext
 ISBN 1234567890<nowiki/>1
 </p>
 !! wikitext
 ISBN 1234567890<nowiki/>1
@@ -22921,8 +23090,10 @@ a<nowiki/>ISBN 1234567890<nowiki/>b
 
 !! test
 Links 13. Don't add spurious <nowiki/>s between text-nodes and ISBN-links (bug 64300)
 
 !! test
 Links 13. Don't add spurious <nowiki/>s between text-nodes and ISBN-links (bug 64300)
+!! options
+parsoid=html2wt
 !! html/parsoid
 !! html/parsoid
-<p>-<a href="./Special:BookSources/1234567890" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>'s
+<p>-<a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>'s
 !! wikitext
 -ISBN 1234567890's
 !! html/php
 !! wikitext
 -ISBN 1234567890's
 !! html/php
@@ -22945,13 +23116,14 @@ parsoid=html2wt
 Links 15. Link trails can't become link prefixes.
 !! options
 language=is
 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>
 !! 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 ---------------
 !! end
 
 #### --------------- Quotes ---------------
@@ -22963,28 +23135,7 @@ language=is
 !! test
 1a. Quotes inside <b> and <i>
 !! options
 !! 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>
 !! html/*
 <p><i>'foo'</i>
 <i>''foo''</i>
@@ -23007,22 +23158,34 @@ a|!*#-:;+-~[]{}b'''x''
 '<i>foo</i> bar '<i>baz</i>
 a|!*#-:;+-~[]{}b'<i>x</i>
 </p>
 '<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
 !! 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>
 '<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>
@@ -23033,45 +23196,58 @@ parsoid=html2wt,wt2wt
 <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>
 <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
 !! 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>
 !! 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>
 !! 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>
 !! wikitext
 ''[[foo''<nowiki>]]</nowiki>
 
 '''[[foo'''<nowiki>]]</nowiki>
-!! html
-<p><i>[[foo</i>]]
-</p><p><b>[[foo</b>]]
-</p>
 !! end
 
 !! test
 4. No escaping needed
 !! 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>
 <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 ---------------
 !! end
 
 #### ----------- Paragraphs ---------------
@@ -23080,6 +23256,15 @@ parsoid=html2wt,wt2wt
 
 !! test
 1. No unnecessary escapes
 
 !! 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>
 
 !! wikitext
 bar <span><nowiki>[[foo]]</nowiki></span>
 
@@ -23090,13 +23275,6 @@ bar <span><nowiki>[[foo]]</nowiki></span>
 ]]bar <span><nowiki>[[foo]]</nowiki></span>
 
 =bar <span>foo]]</span><nowiki>=</nowiki>
 ]]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 --------------------------
 !!end
 
 #### ----------------------- PRE --------------------------
@@ -23105,83 +23283,103 @@ bar <span><nowiki>[[foo]]</nowiki></span>
 !! test
 1. Leading whitespace in SOL context should be escaped
 !! options
 !! test
 1. Leading whitespace in SOL context should be escaped
 !! options
-parsoid
+parsoid=html2wt
+!! html/parsoid
+<p> a</p>
+
+<p>  a</p>
+
+<p>    a(tab)</p>
+
+<p>    a
+<!--cmt-->
+  a</p>
+
+<p>a
+ b</p>
+
+<p>a
+       b</p>
+
+<p>a
+        b</p>
 !! wikitext
 <nowiki> </nowiki>a
 
 <nowiki> </nowiki> a
 
 !! wikitext
 <nowiki> </nowiki>a
 
 <nowiki> </nowiki> a
 
-<nowiki>       </nowiki>a(tab)
+       a(tab)
 
 <nowiki> </nowiki>     a
 <!--cmt-->
 
 <nowiki> </nowiki>     a
 <!--cmt-->
-<nowiki> </nowiki> a
+<nowiki>  </nowiki>a
 
 a
 <nowiki> </nowiki>b
 
 a
 
 a
 <nowiki> </nowiki>b
 
 a
-<nowiki>       </nowiki>b
+       b
 
 a
 
 a
-<nowiki>       </nowiki> b
-!! html
-<p> a</p>
-<p>  a</p>
-<p>    a(tab)</p>
-<p>    a</p>
-<p><!--cmt-->  a</p>
-<p>a
- b</p>
-<p>a
-       b</p>
-<p>a
-        b</p>
+        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
 !! 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>
 <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
 !! end
 
 !! test
 3. Leading whitespace in indent-pre suppressing contexts should not be escaped
 !! options
-parsoid
-!! wikitext
+parsoid=html2wt
+!! html/parsoid
 <blockquote>
 <blockquote>
+<p>
  a
  <span>b</span>
  a
  <span>b</span>
- c
+ c</p>
 </blockquote>
 </blockquote>
-!! html
+!! wikitext
 <blockquote>
 <blockquote>
-<p>
  a
  <span>b</span>
  a
  <span>b</span>
- c</p>
+ c
 </blockquote>
 !! end
 
 !! test
 4. Leading whitespace in indent-pre suppressing contexts should not be escaped
 !! options
 </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>
 !! 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
 !! end
 
 !! test
@@ -23197,15 +23395,15 @@ parsoid=html2wt
 !!test
 T95794: nowiki escaping should account for leading space at start-of-line in an indent-pre block
 !! options
 !!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>
 <pre>
 * foo
 * bar
 </pre>
+!! wikitext
+ * foo
+ * bar
 !! end
 
 #### --------------- Behavior Switches --------------------
 !! end
 
 #### --------------- Behavior Switches --------------------
@@ -23237,15 +23435,8 @@ __|__
 # We use indent-pre as an indirect way to test for sol-transparent behavior.
 !! test
 Behavior switches should be SOL-transparent
 # 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" />
 
 !! html/parsoid
  <meta property="mw:PageProp/toc" />
 
@@ -23255,6 +23446,15 @@ __TOC__ bar
 <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>
 <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 ---------------
 !! end
 
 #### --------------- HTML tags ---------------
@@ -23266,75 +23466,85 @@ __TOC__ bar
 !! test
 1. a tags
 !! options
 !! test
 1. a tags
 !! options
-parsoid
+parsoid=html2wt
+!! html/parsoid
+&lt;a href=&quot;http://google.com&quot;&gt;google&lt;/a&gt;
 !! wikitext
 <a href="http://google.com">google</a>
 !! wikitext
 <a href="http://google.com">google</a>
-!! html
-&lt;a href=&quot;http://google.com&quot;&gt;google&lt;/a&gt;
 !! end
 
 !! test
 2. other tags
 !! 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> &lt;div&gt;foo&lt;/div&gt;</li>
 <li> &lt;div style=&quot;color:red&quot;&gt;foo&lt;/div&gt;</li>
 <li> &lt;td&gt;</li></ul>
 
 <ul><li> &lt;div&gt;foo&lt;/div&gt;</li>
 <li> &lt;div style=&quot;color:red&quot;&gt;foo&lt;/div&gt;</li>
 <li> &lt;td&gt;</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
 !! end
 
 !! test
 3. multi-line html tag
-!! wikitext
-<nowiki><div
->foo</div
-></nowiki>
-!! html
+!! options
+parsoid=html2wt
+!! html/parsoid
 <p>&lt;div
 &gt;foo&lt;/div
 &gt;
 </p>
 <p>&lt;div
 &gt;foo&lt;/div
 &gt;
 </p>
+!! wikitext
+<nowiki><div
+>foo</div
+></nowiki>
 !! end
 
 !! test
 4. extension tags
 !! end
 
 !! test
 4. extension tags
+!! options
+parsoid=html2wt
+!! html/parsoid
+<p>&lt;ref&gt;foo&lt;/ref&gt;
+</p><p>&lt;ref&gt;bar
+</p><p>baz&lt;/ref&gt;
+</p>
 !! wikitext
 <nowiki><ref>foo</ref></nowiki>
 
 <nowiki><ref>bar</nowiki>
 
 baz<nowiki></ref></nowiki>
 !! wikitext
 <nowiki><ref>foo</ref></nowiki>
 
 <nowiki><ref>bar</nowiki>
 
 baz<nowiki></ref></nowiki>
-!! html
-<p>&lt;ref&gt;foo&lt;/ref&gt;
-</p><p>&lt;ref&gt;bar
-</p><p>baz&lt;/ref&gt;
-</p>
 !! end
 
 #### --------------- Others ---------------
 !! test
 Escaping nowikis
 !! end
 
 #### --------------- Others ---------------
 !! test
 Escaping nowikis
-!! wikitext
-&lt;nowiki&gt;foo&lt;/nowiki&gt;
-!! html
+!! options
+parsoid=html2wt
+!! html/parsoid
 <p>&lt;nowiki&gt;foo&lt;/nowiki&gt;
 </p>
 <p>&lt;nowiki&gt;foo&lt;/nowiki&gt;
 </p>
+!! wikitext
+&lt;nowiki&gt;foo&lt;/nowiki&gt;
 !! 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
 !! 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 :
 !! wikitext
 foo's bar :
-!! html
-<p>foo's bar :</p>
 !! end
 
 !! end
 
+#----------- End of wikitext escaping tests --------------
+
 !! test
 
 Tag-like HTML structures are passed through as text
 !! test
 
 Tag-like HTML structures are passed through as text
@@ -23386,20 +23596,9 @@ HTML tag with broken attribute value quoting
 !! wikitext
 <span title="Hello world>Foo</span>
 !! html/php
 !! wikitext
 <span title="Hello world>Foo</span>
 !! html/php
-<p><span>Foo</span>
-</p>
-!! html/parsoid
 <p><span title="Hello world">Foo</span>
 </p>
 <p><span title="Hello world">Foo</span>
 </p>
-!! end
-
-!! test
-Parsoid-only: HTML tag with broken attribute value quoting
-!! options
-parsoid
-!! wikitext
-<span title="Hello world>Foo</span>
-!! html
+!! html/parsoid
 <p><span title="Hello world">Foo</span>
 </p>
 !! end
 <p><span title="Hello world">Foo</span>
 </p>
 !! end
@@ -23413,7 +23612,7 @@ Table with broken attribute value quoting
 !! html/php
 <table>
 <tr>
 !! html/php
 <table>
 <tr>
-<td>Foo
+<td title="Hello world">Foo
 </td></tr></table>
 
 !! html/parsoid
 </td></tr></table>
 
 !! html/parsoid
@@ -23434,9 +23633,9 @@ Table with broken attribute value quoting on consecutive lines
 !! html/php
 <table>
 <tr>
 !! html/php
 <table>
 <tr>
-<td>Foo
+<td title="Hello world">Foo
 </td>
 </td>
-<td>Bar
+<td style="color:red">Bar
 </td></tr></table>
 
 !! html/parsoid
 </td></tr></table>
 
 !! html/parsoid
@@ -23449,7 +23648,7 @@ Table with broken attribute value quoting on consecutive lines
 !! end
 
 !! test
 !! end
 
 !! test
-Parsoid-only: Don't wrap broken template tags in <nowiki> on wt2wt (Bug 42353)
+2. Parsoid-only: Don't wrap broken template tags in <nowiki> on wt2wt (Bug 42353)
 !! options
 parsoid
 !! wikitext
 !! options
 parsoid
 !! wikitext
@@ -23459,7 +23658,7 @@ parsoid
 !! end
 
 !! test
 !! end
 
 !! test
-Parsoid-only: Don't wrap broken template tags in <nowiki> on wt2wt (Bug 42353)
+1. Parsoid-only: Don't wrap broken template tags in <nowiki> on wt2wt (Bug 42353)
 !! options
 parsoid
 !! wikitext
 !! options
 parsoid
 !! wikitext
@@ -24508,7 +24707,7 @@ parsoid={
 
 ==  [[Category:A2]] hi pal ==
 
 
 ==  [[Category:A2]] hi pal ==
 
-== <!--foo-->   [[Category:A3]]    how goes it ==
+==  <!--foo-->  [[Category:A3]]    how goes it ==
 
 == it goes well    [[Category:A4]]  <!--bar-->  ==
 
 
 == it goes well    [[Category:A4]]  <!--bar-->  ==
 
@@ -24572,7 +24771,7 @@ parsoid={
   "scrubWikitext": true
 }
 !! html/parsoid
   "scrubWikitext": true
 }
 !! html/parsoid
-<h2> foo <span about="#mwt2" class="reference" 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">[1]</a></span> </h2>
+<h2> 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> </h2>
 
 <ol class="references" typeof="mw:Extension/references" about="#mwt3" 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">bar <link rel="mw:PageProp/Category" href="./Category:Baz" /> </span></li></ol>
 !! wikitext
 
 <ol class="references" typeof="mw:Extension/references" about="#mwt3" 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">bar <link rel="mw:PageProp/Category" href="./Category:Baz" /> </span></li></ol>
 !! wikitext
@@ -24662,7 +24861,7 @@ parsoid=html2wt
 <h2> hi <span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"bogus","href":"./Template:Bogus"},"params":{"1":{"wt":"there\nyou"}},"i":0}}]}'>there</span><span about="#mwt1">
 </span><span about="#mwt1">you</span> </h2>
 
 <h2> hi <span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"bogus","href":"./Template:Bogus"},"params":{"1":{"wt":"there\nyou"}},"i":0}}]}'>there</span><span about="#mwt1">
 </span><span about="#mwt1">you</span> </h2>
 
-<h2> foo <span about="#mwt2" class="reference" 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">[1]</a></span> </h2>
+<h2> 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> </h2>
 
 <ol class="references" typeof="mw:Extension/references" about="#mwt3" 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="{}">hello
 there</span></li></ol>
 
 <ol class="references" typeof="mw:Extension/references" about="#mwt3" 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="{}">hello
 there</span></li></ol>
@@ -24960,7 +25159,7 @@ Edited ISBN links not serializable as ISBN links should serialize as wikilinks
 !! options
 parsoid=html2wt
 !! html/parsoid
 !! options
 parsoid=html2wt
 !! html/parsoid
-<a rel="mw:ExtLink" href="./Special:BookSources/1234567890">ISBN 1234567895</a>
+<a href="./Special:BookSources/1234567890" rel="mw:ExtLink">ISBN 1234567895</a>
 !! wikitext
 [[Special:BookSources/1234567890|ISBN 1234567895]]
 !! end
 !! wikitext
 [[Special:BookSources/1234567890|ISBN 1234567895]]
 !! end
@@ -25070,6 +25269,92 @@ parsoid=html2wt
 http://example.com<nowiki> http://example.com is not a link.</nowiki>
 !! end
 
 http://example.com<nowiki> http://example.com is not a link.</nowiki>
 !! end
 
+!! test
+Magic links inside links (not autolinked)
+!! wikitext
+[[Foo|http://example.com]]
+[[Foo|RFC 1234]]
+[[Foo|PMID 1234]]
+[[Foo|ISBN 123456789x]]
+
+[http://foo.com http://example.com]
+[http://foo.com RFC 1234]
+[http://foo.com PMID 1234]
+[http://foo.com ISBN 123456789x]
+!! html+tidy
+<p><a href="/wiki/Foo" title="Foo">http://example.com</a> <a href="/wiki/Foo" title="Foo">RFC 1234</a> <a href="/wiki/Foo" title="Foo">PMID 1234</a> <a href="/wiki/Foo" title="Foo">ISBN 123456789x</a></p>
+<p><a rel="nofollow" class="external text" href="http://foo.com">http://example.com</a> <a rel="nofollow" class="external text" href="http://foo.com">RFC 1234</a> <a rel="nofollow" class="external text" href="http://foo.com">PMID 1234</a> <a rel="nofollow" class="external text" href="http://foo.com">ISBN 123456789x</a></p>
+!! html/parsoid
+<p><a rel="mw:WikiLink" href="./Foo" title="Foo">http://example.com</a>
+<a rel="mw:WikiLink" href="./Foo" title="Foo">RFC 1234</a>
+<a rel="mw:WikiLink" href="./Foo" title="Foo">PMID 1234</a>
+<a rel="mw:WikiLink" href="./Foo" title="Foo">ISBN 123456789x</a></p>
+
+<p><a rel="mw:ExtLink" href="http://foo.com">http://example.com</a>
+<a rel="mw:ExtLink" href="http://foo.com">RFC 1234</a>
+<a rel="mw:ExtLink" href="http://foo.com">PMID 1234</a>
+<a rel="mw:ExtLink" href="http://foo.com">ISBN 123456789x</a></p>
+!! end
+
+!! test
+Magic links inside image captions (autolinked)
+!! wikitext
+[[File:Foobar.jpg|thumb|http://example.com]]
+[[File:Foobar.jpg|thumb|RFC 1234]]
+[[File:Foobar.jpg|thumb|PMID 1234]]
+[[File:Foobar.jpg|thumb|ISBN 123456789x]]
+!! html+tidy
+<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"></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"></a></div>
+<a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc1234">RFC 1234</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"></a></div>
+<a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract">PMID 1234</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"></a></div>
+<a href="/wiki/Special:BookSources/123456789X" class="internal mw-magiclink-isbn">ISBN 123456789x</a></div>
+</div>
+</div>
+!! 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><a rel="mw:ExtLink" href="http://example.com">http://example.com</a></figcaption></figure>
+<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><a href="//tools.ietf.org/html/rfc1234" rel="mw:ExtLink">RFC 1234</a></figcaption></figure>
+<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><a href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract" rel="mw:ExtLink">PMID 1234</a></figcaption></figure>
+<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><a href="./Special:BookSources/123456789X" rel="mw:WikiLink">ISBN 123456789x</a></figcaption></figure>
+!! end
+
+!! test
+WTS of magic word text (T109371)
+!! options
+parsoid=html2wt
+!! html/parsoid
+<p>RFC 1234</p>
+<p><a href="http://foo.com" rel="mw:ExtLink">RFC 1234</a></p>
+<p><a href="./Foo" rel="mw:WikiLink">RFC 1234</a></p>
+!! wikitext
+<nowiki>RFC 1234</nowiki>
+
+[http://foo.com RFC 1234]
+
+[[Foo|RFC 1234]]
+!! end
+
 !! test
 Edited Redirect link should emit a non-piped wikitext link
 !! options
 !! test
 Edited Redirect link should emit a non-piped wikitext link
 !! options
@@ -25775,6 +26060,16 @@ parsoid={
 </table>
 !! end
 
 </table>
 !! end
 
+!! test
+Escape nowiki DOM elements
+!! options
+parsoid=html2wt
+!! html/parsoid
+<nowiki><i>foo</i></nowiki>
+!! wikitext
+&lt;nowiki&gt;''foo''&lt;/nowiki&gt;
+!! end
+
 # ---------------------------------------------------
 # End of tests spec'ing wikitext serialization norms |
 # ---------------------------------------------------
 # ---------------------------------------------------
 # End of tests spec'ing wikitext serialization norms |
 # ---------------------------------------------------