Merge "Escape return of {{int:}} if message not exists"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Wed, 19 Aug 2015 17:31:48 +0000 (17:31 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 19 Aug 2015 17:31:48 +0000 (17:31 +0000)
1  2 
tests/parser/parserTests.txt

@@@ -160,22 -160,6 +160,22 @@@ Template:table_attribs_
  |</noinclude>style="color:red;"||Bar
  !! endarticle
  
 +!! article
 +Template:table_attribs_6
 +!! text
 +style="background: <nowiki>
 +
 +
 +red;</nowiki>" |
 +!! endarticle
 +
 +!! article
 +Template:table_attribs_7
 +!! text
 +<noinclude>
 +|</noinclude>style{{=}}"background:&#35;f9f9f9;"|Foo<ref>foo</ref>
 +!! endarticle
 +
  !! article
  Template:table_header_cells
  !! text
@@@ -838,12 -822,15 +838,12 @@@ parsoid=wt2htm
  !!end
  
  # same html as previous, but wikitext adjusted to match parsoid html2wt
 -# skipping wt2html and html2html because it wants to put <i> before <b>
  !! test
  Italics and bold: 5-quote opening sequence: (5,2+3)
 -!! options
 -parsoid=wt2wt,html2wt
  !! wikitext
  '''''foo'''''
 -!! html
 -<p><b><i>foo</i></b>
 +!! html/*
 +<p><i><b>foo</b></i>
  </p>
  !! end
  
@@@ -1327,7 -1314,7 +1327,7 @@@ Non-word characters don't terminate ta
  Non-word characters are valid in extension tags (T19663)
  !! wikitext
  <tåg>tåg</tåg>
 -!! html
 +!! html/php
  <pre>
  'tåg'
  array (
  
  !! test
  Isolated close tags should be treated as literal text (bug 52760)
 +!! options
 +parsoid=wt2html
  !! wikitext
  </b>
  
  <s.foo>s</s>
 -!! html+tidy
 +!! html/php+tidy
 +<p>&lt;s.foo&gt;s</p>
 +!! html/parsoid
  <p>&lt;s.foo&gt;s</p>
  !! end
  
@@@ -1380,11 -1363,9 +1380,11 @@@ Bare pipe character from a template (bu
  <nowiki> unordered list
  !! wikitext
  <nowiki>* This is not an unordered list item.</nowiki>
 -!! html
 +!! html/php
  <p>* This is not an unordered list item.
  </p>
 +!! html/parsoid
 +<p><span typeof="mw:Nowiki">* This is not an unordered list item.</span></p>
  !! end
  
  !! test
@@@ -1397,7 -1378,7 +1397,7 @@@ sed abit
  
  :and a colon
  </nowiki>
 -!! html
 +!! html/php
  <p>Lorem ipsum dolor
  
  sed abit.
  :and a colon
  
  </p>
 +!! html/parsoid
 +<p><span typeof="mw:Nowiki">Lorem ipsum dolor
 +
 +sed abit.
 +  sed nullum.
 +
 +:and a colon
 +</span></p>
  !! end
  
  !! test
@@@ -1427,7 -1400,7 +1427,7 @@@ nowiki 
  
  *There is not nowiki.
  *There is <nowiki>nowiki</nowiki>.
 -!! html
 +!! html/php
  <dl><dd>There is not nowiki.</dd>
  <dd>There is nowiki.</dd></dl>
  <ol><li>There is not nowiki.</li>
  <ul><li>There is not nowiki.</li>
  <li>There is nowiki.</li></ul>
  
 +!! html/parsoid
 +<dl><dd data-parsoid='{}'>There is not nowiki.</dd>
 +<dd data-parsoid='{}'>There is <span typeof="mw:Nowiki">nowiki</span>.</dd></dl>
 +
 +<ol><li data-parsoid='{}'>There is not nowiki.</li>
 +<li data-parsoid='{}'>There is <span typeof="mw:Nowiki">nowiki</span>.</li></ol>
 +
 +<ul><li data-parsoid='{}'>There is not nowiki.</li>
 +<li data-parsoid='{}'>There is <span typeof="mw:Nowiki">nowiki</span>.</li></ul>
  !! end
  
  !! test
@@@ -1457,11 -1421,11 +1457,11 @@@ Entities inside <nowiki
  
  !! test
  Entities inside template parameters
 -!! options
 -parsoid
  !! wikitext
  {{echo|&ndash;}}
 -!! html
 +!! html/php+tidy
 +<p>–</p>
 +!! html/parsoid
  <p><span typeof="mw:Transclusion mw:Entity" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&amp;ndash;"}},"i":0}}]}'>&ndash;</span></p>
  !! end
  
  Properly escape nowiki when combined with other wiki markup
  !! options
  parsoid=html2wt
 -!! html
 +!! html/parsoid
  <p>* &lt;/nowiki&gt; tag</p>
  !! wikitext
 -<nowiki>* &lt;/nowiki&gt;</nowiki> tag
 +<nowiki>*</nowiki> <nowiki>&lt;/nowiki&gt;</nowiki> tag
  !! end
  
  !! test
  T93824: Put escaped HTML tags inside nowiki
  !! options
  parsoid=html2wt
 -!! html
 +!! html/parsoid
  <p>&lt;h2&gt;foo&lt;/h2&gt;</p>
  !! wikitext
  <nowiki><h2>foo</h2></nowiki>
  T71950: 1. Put nowiki as close to cause as possible, even with non-quote escapable chars
  !! options
  parsoid=html2wt
 -!! html
 +!! html/parsoid
  <p>This text: L'<a rel="mw:WikiLink" href="./Foo">Foo</a>
  This text: L''<a rel="mw:WikiLink" href="./Foo">Foo</a>
  This text: L'''<a rel="mw:WikiLink" href="./Foo">Foo</a>''</p>
@@@ -1504,7 -1468,7 +1504,7 @@@ This text: L<nowiki>'''</nowiki>[[Foo]]
  T71950: 2. Put nowiki as close to cause as possible, after ' :'
  !! options
  parsoid=html2wt
 -!! html
 +!! html/parsoid
  <p>This text : L''<a rel="mw:WikiLink" href="./Foo">Foo</a>
  </p>
  !! wikitext
@@@ -1547,7 -1511,7 +1547,7 @@@ parsoid=html2w
  Cases where "!!" needs nowiki protection
  !! options
  parsoid=html2wt
 -!! html
 +!! html/parsoid
  <table>
  <tr><th>this needs protection !! here</th></tr>
  </table>
@@@ -1800,11 -1764,7 +1800,11 @@@ parsoid=wt2html,wt2w
  !! wikitext
  <!--c1-->*a
  <!--c2--><!--c3--><!--c4-->*b
 -!! html
 +!! html/php
 +<ul><li>a</li>
 +<li>b</li></ul>
 +
 +!! html/parsoid
  <!--c1--><ul>
  <li>a
  </li>
@@@ -2017,7 -1977,7 +2017,7 @@@ a [[Category:A1]] [[Category:A2]
  [[Category:A4]]
  !! html/parsoid
  <p>a</p>
 -<link rel="mw:PageProp/Category" href="Category:A1"/> <link rel="mw:PageProp/Category" href="Category:A2"/> <link rel="mw:PageProp/Category" href="Category:A3"/> <link rel="mw:PageProp/Category" href="Category:A4"/>
 +<link rel="mw:PageProp/Category" href="./Category:A1"/> <link rel="mw:PageProp/Category" href="./Category:A2"/> <link rel="mw:PageProp/Category" href="./Category:A3"/> <link rel="mw:PageProp/Category" href="./Category:A4"/>
  !! end
  
  !! test
@@@ -2027,7 -1987,7 +2027,7 @@@ parsoid=wt2htm
  !! wikitext
  [[Category:A1]]a
  !! html/parsoid
 -<link rel="mw:PageProp/Category" href="Category:A1"/><p>a</p>
 +<link rel="mw:PageProp/Category" href="./Category:A1"/><p>a</p>
  !! end
  
  ###
@@@ -2263,7 -2223,7 +2263,7 @@@ Entities inside <pre
  </nowiki>
  </pre>
  
 -!! html
 +!! html/php
  <pre>
  &lt;nowiki&gt;
  </pre>
  
  &lt;/pre&gt;
  </p>
 +!! html/parsoid
 +<pre data-parsoid='{"stx":"html","strippedNL":true}'>&lt;nowiki>
 +</pre>
 +<p><span typeof="mw:Placeholder" data-parsoid='{"src":"&lt;/nowiki>"}'>&lt;/nowiki></span>
 +&lt;/pre></p>
 +
 +<p><span typeof="mw:Nowiki">
 +&lt;pre>
 +&lt;nowiki>
 +&lt;/pre>
 +</span>
 +&lt;/pre></p>
  !! end
  
  !! test
@@@ -2344,17 -2292,13 +2344,17 @@@ HTML pre followed by indent-pr
  </pre>
  !! end
  
 +# Note that tidy removes the empty <p> tags from the start and end.
 +# Parsoid does not, by design.
  !!test
  Block tag pre
 -!!options
 -parsoid
  !! wikitext
  <p><pre>foo</pre></p>
 -!! html
 +!! html/php+tidy
 +<pre>
 +foo
 +</pre>
 +!! html/parsoid
  <p data-parsoid='{"stx":"html","autoInsertedEnd":true}'></p><pre data-parsoid='{"stx":"html"}'>foo</pre><p data-parsoid='{"autoInsertedStart":true,"stx":"html"}'></p>
  !!end
  
@@@ -2477,19 -2421,6 +2477,19 @@@ Templates: Indent-Pre: 1f: Wrapping sho
  </pre>
  !!end
  
 +!! test
 +Pres with newline attributes
 +!! wikitext
 +<pre class="one
 +two">hi</pre>
 +!! html/php
 +<pre class="one two">hi</pre>
 +
 +!! html/parsoid
 +<pre class="one
 +two" data-parsoid='{"stx":"html"}'>hi</pre>
 +!! end
 +
  !! test
  Things that look like <pre> tags aren't treated as such
  !! wikitext
@@@ -2529,10 -2460,7 +2529,10 @@@ Parsoid: handle pre with space after at
  parsoid=wt2html
  !! wikitext
  <pre style="width:50%;" >{{echo|foo}}</pre>
 -!! html
 +!! html/php
 +<pre style="width:50%;">{{echo|foo}}</pre>
 +
 +!! html/parsoid
  <pre style="width:50%;">{{echo|foo}}</pre>
  !! end
  
@@@ -2738,32 -2666,32 +2738,32 @@@ Templates: Other wikitext in parameter 
  #--------------------------------------------------------------------
  !! test
  Templates: Parsoid parameter escaping test 1
 -!! options
 -parsoid
  !! wikitext
  {{echo|[foo]|{{echo|[bar]}}}}
 -!! html
 +!! html/php+tidy
 +<p>[foo]</p>
 +!! html/parsoid
  <p about="#mwt1" typeof="mw:Transclusion"
  data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[foo]"},"2":{"wt":"{{echo|[bar]}}"}},"i":0}}]}'>[foo]</p>
  !! end
  
  !! test
  Parsoid: Pipes in external links in template parameter
 -!! options
 -parsoid
  !! wikitext
  {{echo|[{{echo|http://example.com}} link]}}
 -!! html
 +!! html/php+tidy
 +<p><a rel="nofollow" class="external text" href="http://example.com">link</a></p>
 +!! html/parsoid
  <p><a rel="mw:ExtLink" href="http://example.com" about="#mwt31" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[{{echo|http://example.com}} link]"}},"i":0}}]}'>link</a></p>
  !! end
  
  !! test
  Parsoid: pipe in transclusion parameter
 -!! options
 -parsoid
  !! wikitext
  {{echo|http://foo.com/a&#124;b}}
 -!! html
 +!! html/php+tidy
 +<p><a rel="nofollow" class="external free" href="http://foo.com/a%7Cb">http://foo.com/a%7Cb</a></p>
 +!! html/parsoid
  <p><a rel="mw:ExtLink" href="http://foo.com/a|b" about="#mwt1"
  typeof="mw:Transclusion"
  data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"http://foo.com/a&amp;#124;b"}},"i":0}}]}'>http://foo.com/a|b</a></p>
@@@ -2775,9 -2703,7 +2775,9 @@@ Parsoid: Pipe in external link target a
  parsoid=html2wt,wt2wt
  !! wikitext
  {{echo|[http://foo.com/a&#124;b a&#124;b]}}
 -!! html
 +!! html/php+tidy
 +<p><a rel="nofollow" class="external text" href="http://foo.com/a%7Cb">a|b</a></p>
 +!! html/parsoid
  <p><a rel="mw:ExtLink" href="http://foo.com/a|b" about="#mwt1"
  typeof="mw:Transclusion"
  data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},
@@@ -2802,9 -2728,7 +2802,9 @@@ parsoid=html2wt,wt2w
  {{echo|foo<nowiki>|</nowiki>bar}}
  {{echo|<nowiki>&lt;div&gt;</nowiki>}}
  {{echo|<nowiki></nowiki>}}
 -!! html
 +!! html/php+tidy
 +<p>foo|bar &lt;div&gt;</p>
 +!! html/parsoid
  <p><span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo<nowiki>|</nowiki>bar"}},"i":0}}]}'}'>foo</span><span typeof="mw:Nowiki" about="#mwt1">|</span><span about="#mwt1">bar</span>
  <span typeof="mw:Transclusion mw:Nowiki" about="#mwt2" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"<nowiki>&amp;lt;div&amp;gt;</nowiki>"}},"i":0}}]}'><span typeof="mw:Entity">&lt;</span>div<span typeof="mw:Entity">&gt;</span></span>
  <span typeof="mw:Transclusion mw:Nowiki" about="#mwt3" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"<nowiki></nowiki>"}},"i":0}}]}'></span>
@@@ -2818,20 -2742,18 +2818,20 @@@ Templates: '=' char in nested transclus
  parsoid=html2wt,wt2wt
  !! wikitext
  {{echo|{{echo|1=bar}}}}
 -!! html
 +!! html/php+tidy
 +<p>bar</p>
 +!! html/parsoid
  <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"{{echo|1=bar}}"}},"i":0}}]}'>bar</p>
  !! end
  
  ## Bug 56733
  !! test
  Templates parameters with special tokenizing behavior dont get modified because of arg escaping
 -!! options
 -parsoid
  !! wikitext
  {{echo|a : b}}
 -!! html
 +!! html/php+tidy
 +<p>a&#160;: b</p>
 +!! html/parsoid
  <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"a : b"}},"i":0}}]}'>a<span typeof="mw:DisplaySpace mw:Placeholder" data-parsoid='{"isDisplayHack":true}'> </span>: b</p>
  !! end
  
  Templates: Preserve blank parameter names
  !! wikitext
  {{echo|=foo}}
 -!! html/php
 -<p>{{{1}}}
 -</p>
 +!! html/php+tidy
 +<p>{{{1}}}</p>
  !! html/parsoid
  <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"":{"wt":"foo"}},"i":0}}]}'>{{{1}}}</p>
  !! end
  Templates: Preserve blank parameter names in other positions
  !! wikitext
  {{blank_param|bar|=foo}}
 -!! html/php
 -<p>bar
 -foo
 -</p>
 +!! html/php+tidy
 +<p>bar foo</p>
  !! html/parsoid
  <p about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"1","spc":["","","",""]},{"k":"","named":true,"spc":["","","",""]}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"blank_param","href":"./Template:Blank_param"},"params":{"1":{"wt":"bar"},"":{"wt":"foo"}},"i":0}}]}'>bar
  foo</p>
@@@ -3307,7 -3232,6 +3307,7 @@@ parsoid=wt2html,wt2w
  !! wikitext
   [[Category:foo]] <!-- No pre-wrapping -->
  {{echo| [[Category:foo]]}} <!-- No pre-wrapping -->
 +!! html/php+tidy
  !! html/parsoid
   <link rel="mw:PageProp/Category" href="./Category:Foo"> <!-- No pre&#x2D;wrapping -->
  <span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":" [[Category:foo]]"}},"i":0}}]}'> </span><link rel="mw:PageProp/Category" href="./Category:Foo" about="#mwt1"> <!-- No pre&#x2D;wrapping -->
@@@ -3331,8 -3255,6 +3331,8 @@@ Indent-Pre: Newlines in comments should
  a <!--
  foo
  --> b
 +!! html/php+tidy
 +<p>a b</p>
  !! html/parsoid
  <p>a <!--
  foo
  
  foo
  </pre>
 -!! html
 -<pre>foo</pre>
 +!! html/php+tidy
 +<pre>
 +foo
 +</pre>
  <pre>
  foo
  </pre>
@@@ -3378,6 -3298,7 +3378,6 @@@ fo
  
  foo
  </pre>
 -
  !! html/parsoid
  <pre data-parsoid='{"stx":"html"}'>foo</pre>
  
@@@ -3416,7 -3337,7 +3416,7 @@@ hah
  
  
  </pre>
 -!! html
 +!! html/php+tidy
  <pre>
  
  
@@@ -3433,6 -3354,7 +3433,6 @@@ hah
  
  
  </pre>
 -
  !! html/parsoid
  <pre data-parsoid='{"stx":"html"}'>
  
@@@ -3475,7 -3397,7 +3475,7 @@@ HTML-pre: 3: other wikitex
  '' no-italic ''
  [[ NoLink ]]
  </pre>
 -!! html
 +!! html/php
  <pre>
  * foo
  # bar
  [[ NoLink ]]
  </pre>
  
 +!! html/parsoid
 +<pre data-parsoid='{"stx":"html","strippedNL":true}'>* foo
 +# bar
 += no-h =
 +'' no-italic ''
 +[[ NoLink ]]
 +</pre>
  !!end
  
  ###
@@@ -3814,7 -3729,7 +3814,7 @@@ Definition Lists: Hacky use to indent t
  ##
  ## All Parsoid only definition list tests have this difference.
  ##
 -## See also: https://bugzilla.wikimedia.org/show_bug.cgi?id=6569
 +## See also: https://phabricator.wikimedia.org/T8569
  ## and http://lists.wikimedia.org/pipermail/wikitext-l/2011-November/000483.html
  
  !! test
@@@ -3904,19 -3819,12 +3904,19 @@@ parsoi
  
  !! test
  Definition Lists: Nesting: Test 2 (Parsoid only)
 -!! options
 -parsoid
  !! wikitext
  ;t1
  ::d2
 -!! html
 +!! html/php+tidy
 +<dl>
 +<dt>t1</dt>
 +<dd>
 +<dl>
 +<dd>d2</dd>
 +</dl>
 +</dd>
 +</dl>
 +!! html/parsoid
  <dl>
    <dt>t1</dt>
    <dd>
  
  !! test
  Definition Lists: Nesting: Test 3 (Parsoid only)
 -!! options
 -parsoid
  !! wikitext
  :;t1
  ::::d2
 -!! html
 +!! html/php+tidy
 +<dl>
 +<dd>
 +<dl>
 +<dt>t1</dt>
 +<dd>
 +<dl>
 +<dd>
 +<dl>
 +<dd>d2</dd>
 +</dl>
 +</dd>
 +</dl>
 +</dd>
 +</dl>
 +</dd>
 +</dl>
 +!! html/parsoid
  <dl>
    <dd>
      <dl>
@@@ -4343,17 -4236,6 +4343,17 @@@ Definition Lists: colons occurring in t
  </dl>
  </dd>
  </dl>
 +!! html/parsoid
 +<dl><dt>a</dt><dd data-parsoid='{"stx":"row"}'>b</dd>
 +<dt><b>a:b</b></dt>
 +<dt><i data-parsoid='{"stx":"html"}'>a:b</i></dt>
 +<dt><span data-parsoid='{"stx":"html"}'>a:b</span></dt>
 +<dt><div data-parsoid='{"stx":"html"}'>a:b</div></dt>
 +<dt><div data-parsoid='{"stx":"html","autoInsertedEnd":true}'>a</div></dt>
 +<dd>b</dd>
 +<dt><span about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"1","spc":["","","",""]}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"a:b"}},"i":0}}]}'>a:b</span></dt>
 +<dt><i about="#mwt2" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"1","spc":["","","",""]}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&#39;&#39;a:b&#39;&#39;"}},"i":0}}]}'>a:b</i>
 +<dl><dt><dl><dt><i>a:b</i></dt></dl></dt></dl></dt></dl>
  !! end
  
  !! test
@@@ -4674,25 -4556,6 +4674,25 @@@ http://example.com/url_with_entity&#60
  <a rel="mw:ExtLink" href="http://example.com/url_with_entity&lt;">http://example.com/url_with_entity&lt;</a></p>
  !! end
  
 +!! test
 +External links: Lone protocols are never linked (T105697)
 +!! wikitext
 +http://
 +http://;
 +(http://)
 +bitcoin:
 +bitcoin:;
 +(bitcoin:)
 +!! html
 +<p>http://
 +http://;
 +(http://)
 +bitcoin:
 +bitcoin:;
 +(bitcoin:)
 +</p>
 +!! end
 +
  !! test
  External links: No preceding word characters allowed (bug 65278)
  !! wikitext
@@@ -5341,91 -5204,14 +5341,91 @@@ http://example.com/index.php?foozoid&#x
  !! end
  
  !! test
 -IPv6 urls (bug 21261)
 -!! options
 -disabled
 +IPv6 urls, autolink format (T23261)
  !! wikitext
  http://[2404:130:0:1000::187:2]/index.php
 +
 +Examples from RFC2373, section 2.2:
 +* http://[1080::8:800:200C:417A]/unicast
 +* http://[FF01::101]/multicast
 +* http://[::1]/loopback
 +* http://[::]/unspecified
 +* http://[::13.1.68.3]/ipv4compat
 +* http://[::FFFF:129.144.52.38]/ipv4compat
 +
 +Examples from RFC 2732, section 2:
 +* http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html
 +* http://[1080:0:0:0:8:800:200C:417A]/index.html
 +* http://[3ffe:2a00:100:7031::1]
 +* http://[1080::8:800:200C:417A]/foo
 +* http://[::192.9.5.5]/ipng
 +* http://[::FFFF:129.144.52.38]:80/index.html
 +* http://[2010:836B:4179::836B:4179]
 +
  !! html
  <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>
 +<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>
 +<li> <a rel="nofollow" class="external free" href="http://[::1]/loopback">http://[::1]/loopback</a></li>
 +<li> <a rel="nofollow" class="external free" href="http://[::]/unspecified">http://[::]/unspecified</a></li>
 +<li> <a rel="nofollow" class="external free" href="http://[::13.1.68.3]/ipv4compat">http://[::13.1.68.3]/ipv4compat</a></li>
 +<li> <a rel="nofollow" class="external free" href="http://[::FFFF:129.144.52.38]/ipv4compat">http://[::FFFF:129.144.52.38]/ipv4compat</a></li></ul>
 +<p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc2732">RFC 2732</a>, section 2:
 +</p>
 +<ul><li> <a rel="nofollow" class="external free" 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="nofollow" class="external free" 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="nofollow" class="external free" href="http://[3ffe:2a00:100:7031::1]">http://[3ffe:2a00:100:7031::1]</a></li>
 +<li> <a rel="nofollow" class="external free" href="http://[1080::8:800:200C:417A]/foo">http://[1080::8:800:200C:417A]/foo</a></li>
 +<li> <a rel="nofollow" class="external free" href="http://[::192.9.5.5]/ipng">http://[::192.9.5.5]/ipng</a></li>
 +<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>
 +
 +!! end
 +
 +!! test
 +IPv6 urls, bracketed format (T23261)
 +!! wikitext
 +[http://[2404:130:0:1000::187:2]/index.php test]
 +
 +Examples from RFC2373, section 2.2:
 +* [http://[1080::8:800:200C:417A] unicast]
 +* [http://[FF01::101] multicast]
 +* [http://[::1]/ loopback]
 +* [http://[::] unspecified]
 +* [http://[::13.1.68.3] ipv4compat]
 +* [http://[::FFFF:129.144.52.38] ipv4compat]
 +
 +Examples from RFC 2732, section 2:
 +* [http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html 1]
 +* [http://[1080:0:0:0:8:800:200C:417A]/index.html 2]
 +* [http://[3ffe:2a00:100:7031::1] 3]
 +* [http://[1080::8:800:200C:417A]/foo 4]
 +* [http://[::192.9.5.5]/ipng 5]
 +* [http://[::FFFF:129.144.52.38]:80/index.html 6]
 +* [http://[2010:836B:4179::836B:4179] 7]
 +
 +!! html
 +<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>
 +<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>
 +<li> <a rel="nofollow" class="external text" href="http://[::1]/">loopback</a></li>
 +<li> <a rel="nofollow" class="external text" href="http://[::]">unspecified</a></li>
 +<li> <a rel="nofollow" class="external text" href="http://[::13.1.68.3]">ipv4compat</a></li>
 +<li> <a rel="nofollow" class="external text" href="http://[::FFFF:129.144.52.38]">ipv4compat</a></li></ul>
 +<p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc2732">RFC 2732</a>, section 2:
 +</p>
 +<ul><li> <a rel="nofollow" class="external text" href="http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html">1</a></li>
 +<li> <a rel="nofollow" class="external text" href="http://[1080:0:0:0:8:800:200C:417A]/index.html">2</a></li>
 +<li> <a rel="nofollow" class="external text" href="http://[3ffe:2a00:100:7031::1]">3</a></li>
 +<li> <a rel="nofollow" class="external text" href="http://[1080::8:800:200C:417A]/foo">4</a></li>
 +<li> <a rel="nofollow" class="external text" href="http://[::192.9.5.5]/ipng">5</a></li>
 +<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>
 +
  !! end
  
  !! test
@@@ -5541,7 -5327,7 +5541,7 @@@ Parenthesis in external links, w/ trans
  Serialize <a> tags with invalid link targets as plain text
  !! options
  parsoid=html2wt
 -!! html
 +!! html/parsoid
  <a rel="mw:WikiLink" href="[[foo]]">text</a>
  <a rel="mw:WikiLink" href="[[foo]]">*text</a>
  <a rel="mw:WikiLink" href="[[foo]]">[[foo]]</a>
@@@ -6377,21 -6163,6 +6377,21 @@@ Indented table markup mixed with indent
  </tbody></table>
  !! end
  
 +## Edge case fix to prevent future regressions
 +!! test
 +T107652: <ref>s in templates that also generate table cell attributes should be rendered properly
 +!! wikitext
 +{|
 +|{{table_attribs_7}}
 +|}
 +<references />
 +!! html/parsoid
 +<table>
 +<tbody><tr><td style="background:#f9f9f9;" typeof="mw:Transclusion" about="#mwt1" data-mw='{"parts":["|",{"template":{"target":{"wt":"table_attribs_7","href":"./Template:Table_attribs_7"},"params":{},"i":0}}]}'>Foo<span class="mw-ref" id="cite_ref-1" rel="dc:references" data-mw='{"name":"ref","body":{"id":"mw-reference-text-cite_note-1"},"attrs":{}}'><a href="#cite_note-1" style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a></span></td></tr>
 +</tbody></table>
 +<ol class="mw-references" typeof="mw:Extension/references" about="#mwt5" 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
  Table with row followed by newlines and table heading
  !! wikitext
@@@ -6805,7 -6576,7 +6805,7 @@@ parsoid=wt2html,wt2w
  Parsoid: Default to a newline after tables in new content (bug 51219)
  !! options
  parsoid=html2wt
 -!! html
 +!! html/parsoid
  <table><tbody>
  <tr><td>foo</td></tr></tbody></table> bar
  <table><tbody>
  Parsoid: newline inducing block nodes don't suppress <nowiki>
  !! options
  parsoid=html2wt
 -!! html
 +!! html/parsoid
   a<h1>foo</h1>
  !! wikitext
  <nowiki> </nowiki>a
@@@ -6891,7 -6662,7 +6891,7 @@@ fo
  Strip unsupported table tags
  !! options
  parsoid=html2wt
 -!! html
 +!! html/parsoid
  <table>
  <thead>
  <tr>
@@@ -7196,7 -6967,7 +7196,7 @@@ Namespace takes precedence over interwi
  Link to namespace preferred over interwiki with correct rel attribute
  !! options
  parsoid=html2wt,html2html
 -!! html
 +!! html/parsoid
  <p><a rel="mw:WikiLink" href="./MemoryAlpha:AlphaTest" title="MemoryAlpha:AlphaTest">MemoryAlpha:AlphaTest</a></p>
  !! wikitext
  [[MemoryAlpha:AlphaTest]]
@@@ -7384,10 -7155,10 +7384,10 @@@ Broken image links with HTML captions (
  <a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">abc</a>
  </p>
  !! html/parsoid
 -<p><span class="mw-default-size" typeof="mw:Error mw:Image" data-mw='{"errors":[{"key":"missing-image","message":"This image does not exist."}],"caption":"&lt;script>&lt;/script>"}'><a href="./File:Nonexistent"><img resource="./File:Nonexistent" src="./Special:FilePath/Nonexistent" height="220" width="220"/></a></span>
 -<span typeof="mw:Error mw:Image" data-mw='{"errors":[{"key":"missing-image","message":"This image does not exist."}],"caption":"&lt;script>&lt;/script>"}'><a href="./File:Nonexistent" data-parsoid='{"a":{"href":"./File:Nonexistent"},"sa":{}}'><img resource="./File:Nonexistent" src="./Special:FilePath/Nonexistent" height="100" width="100"/></a></span>
 -<span class="mw-default-size" typeof="mw:Error mw:Image" data-mw='{"errors":[{"key":"missing-image","message":"This image does not exist."}],"caption":"&amp;lt;"}'><a href="./File:Nonexistent"><img resource="./File:Nonexistent" src="./Special:FilePath/Nonexistent" height="220" width="220"/></a></span>
 -<span class="mw-default-size" typeof="mw:Error mw:Image" data-mw='{"errors":[{"key":"missing-image","message":"This image does not exist."}],"caption":"a&lt;i>b&lt;/i>c"}'><a href="./File:Nonexistent"><img resource="./File:Nonexistent" src="./Special:FilePath/Nonexistent" height="220" width="220"/></a></span></p>
 +<p><span class="mw-default-size" typeof="mw:Error mw:Image" data-mw='{"errors":[{"key":"missing-image","message":"This image does not exist."}],"caption":"&amp;lt;script&amp;gt;&amp;lt;/script&amp;gt;"}'><a href="./File:Nonexistent"><img resource="./File:Nonexistent" src="./Special:FilePath/Nonexistent" height="220" width="220"/></a></span>
 +<span typeof="mw:Error mw:Image" data-mw='{"errors":[{"key":"missing-image","message":"This image does not exist."}],"caption":"&amp;lt;script&amp;gt;&amp;lt;/script&amp;gt;"}'><a href="./File:Nonexistent"><img resource="./File:Nonexistent" src="./Special:FilePath/Nonexistent" height="100" width="100"/></a></span>
 +<span class="mw-default-size" typeof="mw:Error mw:Image" data-mw='{"errors":[{"key":"missing-image","message":"This image does not exist."}],"caption":"&lt;span typeof=\"mw:Entity\" data-parsoid=\"{&amp;quot;src&amp;quot;:&amp;quot;&amp;amp;lt;&amp;quot;,&amp;quot;srcContent&amp;quot;:&amp;quot;&lt;&amp;quot;,&amp;quot;dsr&amp;quot;:[107,111,null,null]}\">&amp;lt;&lt;/span>"}'><a href="./File:Nonexistent"><img resource="./File:Nonexistent" src="./Special:FilePath/Nonexistent" height="220" width="220"/></a></span>
 +<span class="mw-default-size" typeof="mw:Error mw:Image" data-mw='{"errors":[{"key":"missing-image","message":"This image does not exist."}],"caption":"a&lt;i data-parsoid=\"{&amp;quot;stx&amp;quot;:&amp;quot;html&amp;quot;,&amp;quot;dsr&amp;quot;:[134,142,3,4]}\">b&lt;/i>c"}'><a href="./File:Nonexistent"><img resource="./File:Nonexistent" src="./Special:FilePath/Nonexistent" height="220" width="220"/></a></span></p>
  !! end
  
  !! test
@@@ -7704,7 -7475,7 +7704,7 @@@ mótmælenda[[söfnuður|söfnuðir]]xx
  Parsoid link trail escaping
  !! options
  parsoid=html2wt,html2html
 -!! html
 +!! html/parsoid
  <p><a rel="mw:WikiLink" href="Apple" title="Apple">apple</a>s</p>
  !! wikitext
  [[apple]]<nowiki/>s
@@@ -7715,7 -7486,7 +7715,7 @@@ Parsoid link prefix escapin
  !! options
  language=is
  parsoid=html2wt,html2html
 -!! html
 +!! html/parsoid
  <p>Aðrir mótmælenda<a rel="mw:WikiLink" href="Söfnuður" title="Söfnuður">söfnuður</a></p>
  !! wikitext
  Aðrir mótmælenda<nowiki/>[[söfnuður]]
@@@ -8100,7 -7871,7 +8100,7 @@@ language=l
  Parsoid bug 53221: Wikilinks should be properly entity-escaped
  !! options
  parsoid=html2wt
 -!! html
 +!! html/parsoid
  <p>He&amp;nbsp;llo <a href="Foo" rel="mw:WikiLink">He&amp;nbsp;llo</a></p>
  <p>He&amp;nbsp;llo <a href="He&amp;nbsp;llo" rel="mw:WikiLink">He&amp;nbsp;llo</a></p>
  !! wikitext
@@@ -8206,7 -7977,7 +8206,7 @@@ Blah blah bla
  </p>
  !! html/parsoid
  <p>Blah blah blah
 -<a rel="mw:WikiLink" href="Template:Foo" title="Template:Foo">mi:Template:Foo</a></p>
 +<a rel="mw:WikiLink" href="./Template:Foo" title="Template:Foo">mi:Template:Foo</a></p>
  !! end
  
  ###
@@@ -8502,8 -8273,8 +8502,8 @@@ Handling html with a br self-closing ta
  <br title=bar/>
  <br title=bar/ >
  !! html/php
 -<p><br title="title" />
 -<br title="title" />
 +<p><br title="" />
 +<br title="" />
  <br />
  <br title="bar" />
  <br title="bar" />
@@@ -9846,7 -9617,7 +9846,7 @@@ parsoid=wt2wt,html2w
  foo
  __NOTOC__
  bar
 -!! html
 +!! html/parsoid
  foo<meta property="mw:PageProp/notoc"/>bar
  !! end
  
@@@ -9857,19 -9628,10 +9857,19 @@@ parsoid=wt2w
  language=de
  !! wikitext
  __NOEDITSECTION__
 -!! html
 +!! html/parsoid
  <meta property="mw:PageProp/noeditsection" data-parsoid='{"magicSrc":"__NOEDITSECTION__"}'/>
  !! end
  
 +!!test
 +__proto__ is treated as normal wikitext (T105997)
 +!!wikitext
 +__proto__
 +!!html
 +<p>__proto__
 +</p>
 +!!end
 +
  ###
  ### Magic links
  ###
@@@ -10447,7 -10209,6 +10447,7 @@@ Template:MSGNW tes
  <gallery>
  File:Foobar.jpg
  </gallery>
 +<!-- comment -->
  !! endarticle
  
  # hmm, fix this or just deprecate msgnw and document its behavior?
  msgnw keyword
  !! wikitext
  {{msgnw:MSGNW test}}
 -!! html
 +!! html/php
  <p>&#39;&#39;None&#39;&#39; of &#39;&#39;&#39;this&#39;&#39;&#39; should be 
  &#42; interpreted
  &#32;but rather passed unmodified
  &#60;gallery&#62;
  File:Foobar.jpg
  &#60;/gallery&#62;
 +&#60;!-- comment --&#62;
  </p>
  !! end
  
@@@ -10476,6 -10236,15 +10476,15 @@@ int keywor
  </p>
  !! end
  
+ !! test
+ int keyword - non-existing message
+ !! wikitext
+ {{int:var}}
+ !! html
+ <p>&lt;var&gt;
+ </p>
+ !! end
  !! article
  Template:Includes
  !! text
  !! end
  
  !! test
 -Parsoid: Merge double tds (bug 50603)
 +Parsoid: Merge double tds (T52603)
  !! options
  parsoid
  !! wikitext
  !! end
  
  !! test
 -Parsoid: Merge double tds in nested transclusion content (bug 50603)
 +Parsoid: Merge double tds in nested transclusion content (T52603)
  !! options
  parsoid
  !! wikitext
@@@ -11244,36 -11013,17 +11253,36 @@@ Templates: Support for templates genera
  </tbody></table>
  !! end
  
 -!!test
 -Templates: HTML Tables: 1. Generating start of a HTML table
 +# T107622
 +!! test
 +4. Entities and nowikis inside templated attributes should be handled correctly inside templated tables
  !! wikitext
 -{{echo|<table><tr><td>foo</td>}}</tr></table>
 -!! html
 -<table><tr><td>foo</td></tr></table>
 -
 -!!end
 -
 -!!test
 -Templates: HTML Tables: 2a. Generating middle of a HTML table
 +{|
 +| {{table_attribs_6}} hi
 +|}
 +!! html/php
 +<table>
 +<tr>
 +<td style="background: red;"> hi
 +</td></tr></table>
 +
 +!! html/parsoid
 +<table>
 +<tbody><tr><td style="background:  red;" typeof="mw:Transclusion" about="#mwt1" data-parsoid='{"autoInsertedEnd":true,"pi":[[]]}' data-mw='{"parts":["| ",{"template":{"target":{"wt":"table_attribs_6","href":"./Template:Table_attribs_6"},"params":{},"i":0}}," hi"]}'> hi</td></tr>
 +</tbody></table>
 +!! end
 +
 +!!test
 +Templates: HTML Tables: 1. Generating start of a HTML table
 +!! wikitext
 +{{echo|<table><tr><td>foo</td>}}</tr></table>
 +!! html
 +<table><tr><td>foo</td></tr></table>
 +
 +!!end
 +
 +!!test
 +Templates: HTML Tables: 2a. Generating middle of a HTML table
  !! wikitext
  <table><tr>{{echo|<td>foo</td>}}</tr></table>
  !! html
@@@ -11727,40 -11477,41 +11736,40 @@@ Parser Functions: 2. Nested use (only o
  !! test
  pre-save transform: subst:
  !! options
 -PST
 +pst
  !! wikitext
  {{subst:test}}
 -!! html
 +!! html/php
  This is a test template
  !! end
  
  !! test
  pre-save transform: normal template
  !! options
 -PST
 +pst
  !! wikitext
  {{test}}
 -!! html
 +!! html/php
  {{test}}
  !! end
  
  !! test
  pre-save transform: nonexistent template
  !! options
 -PST
 +pst
  !! wikitext
  {{thistemplatedoesnotexist}}
 -!! html
 +!! html/php
  {{thistemplatedoesnotexist}}
  !! end
  
 -
  !! test
  pre-save transform: subst magic variables
  !! options
 -PST
 +pst
  !! wikitext
  {{subst:SITENAME}}
 -!! html
 +!! html/php
  MediaWiki
  !! end
  
@@@ -11771,7 -11522,7 +11780,7 @@@ pre-save transform: subst: templates wi
  pst
  !! wikitext
  {{subst:paramtest|param="something else"}}
 -!! html
 +!! html/php
  This is a test template with parameter "something else"
  !! end
  
@@@ -11787,10 -11538,11 +11796,10 @@@ pre-save transform: nowiki in subst (bu
  pst
  !! wikitext
  {{subst:nowikitest}}
 -!! html
 +!! html/php
  <nowiki>'''not wiki'''</nowiki>
  !! end
  
 -
  !! article
  Template:commenttest
  !! text
@@@ -11803,7 -11555,7 +11812,7 @@@ pre-save transform: comment in subst (b
  pst
  !! wikitext
  {{subst:commenttest}}
 -!! html
 +!! html/php
  This template has <!-- a comment --> in it.
  !! end
  
@@@ -11813,7 -11565,7 +11822,7 @@@ pre-save transform: unclosed ta
  pst noxml
  !! wikitext
  <nowiki>'''not wiki'''
 -!! html
 +!! html/php
  <nowiki>'''not wiki'''
  !! end
  
@@@ -11823,7 -11575,7 +11832,7 @@@ pre-save transform: mixed tag cas
  pst noxml
  !! wikitext
  <NOwiki>'''not wiki'''</noWIKI>
 -!! html
 +!! html/php
  <NOwiki>'''not wiki'''</noWIKI>
  !! end
  
@@@ -11833,7 -11585,7 +11842,7 @@@ pre-save transform: unclosed comment i
  pst noxml
  !! wikitext
  wiki<nowiki>nowiki<!--nowiki</nowiki>wiki
 -!! html
 +!! html/php
  wiki<nowiki>nowiki<!--nowiki</nowiki>wiki
  !!end
  
@@@ -11861,7 -11613,7 +11870,7 @@@ pre-save transform: comment containing 
  pst
  !! wikitext
  <!-- <gallery>data</gallery> -->
 -!! html
 +!! html/php
  <!-- <gallery>data</gallery> -->
  !!end
  
@@@ -11871,7 -11623,7 +11880,7 @@@ pre-save transform: comment containing 
  pst
  !! wikitext
  <!-- <tag>data</tag> -->
 -!! html
 +!! html/php
  <!-- <tag>data</tag> -->
  !!end
  
@@@ -11881,7 -11633,7 +11890,7 @@@ pre-save transform: comment containing 
  pst
  !! wikitext
  <!-- <nowiki>data</nowiki> -->
 -!! html
 +!! html/php
  <!-- <nowiki>data</nowiki> -->
  !!end
  
@@@ -11891,7 -11643,7 +11900,7 @@@ pre-save transform: <noinclude> in subs
  pst
  !! wikitext
  {{subst:Includes}}
 -!! html
 +!! html/php
  Foobar
  !! end
  
@@@ -11901,7 -11653,7 +11910,7 @@@ pre-save transform: <onlyinclude> in su
  pst
  !! wikitext
  {{subst:Includes2}}
 -!! html
 +!! html/php
  Foo
  !! end
  
@@@ -11923,7 -11675,7 +11932,7 @@@ bug 22297: safesubst: works during PS
  pst
  !! wikitext
  {{subst:SafeSubstTest}}{{safesubst:SubstTest}}
 -!! html
 +!! html/php
  FoobarFoobar
  !! end
  
  [[|Article (context)]]
  [[Bar:X (Y) Z|]]
  [[:Bar:X (Y) Z|]]
 -!! html
 +!! html/php
  [[Article (context)|Article]]
  [[Bar:Article|Article]]
  [[:Bar:Article|Article]]
  [[:interwiki:Article|]]
  [[interwiki:Bar:Article|]]
  [[:interwiki:Bar:Article|]]
 -!! html
 +!! html/php
  [[interwiki:Article|Article]]
  [[:interwiki:Article|Article]]
  [[interwiki:Bar:Article|Bar:Article]]
@@@ -11993,7 -11745,7 +12002,7 @@@ pre-save transform: context links ("pip
  pst title=[[Somearticle (context)]]
  !! wikitext
  [[|Article]]
 -!! html
 +!! html/php
  [[Article (context)|Article]]
  !! end
  
@@@ -12005,7 -11757,7 +12014,7 @@@ pst title=[[Someplace, Somewhere]
  [[|Otherplace]]
  [[Otherplace, Elsewhere|]]
  [[Otherplace, Elsewhere, Anywhere|]]
 -!! html
 +!! html/php
  [[Otherplace, Somewhere|Otherplace]]
  [[Otherplace, Elsewhere|Otherplace]]
  [[Otherplace, Elsewhere, Anywhere|Otherplace]]
@@@ -12018,7 -11770,7 +12027,7 @@@ pst title=[[Someplace (IGNORED), Somewh
  !! wikitext
  [[|Otherplace]]
  [[Otherplace (place), Elsewhere|]]
 -!! html
 +!! html/php
  [[Otherplace, Somewhere|Otherplace]]
  [[Otherplace (place), Elsewhere|Otherplace]]
  !! end
@@@ -12030,7 -11782,7 +12039,7 @@@ pst title=[[Who, me? (context)]
  !! wikitext
  [[|Yes, you.]]
  [[Me, Myself, and I (1937 song)|]]
 -!! html
 +!! html/php
  [[Yes, you. (context)|Yes, you.]]
  [[Me, Myself, and I (1937 song)|Me, Myself, and I]]
  !! end
@@@ -12041,7 -11793,7 +12050,7 @@@ pre-save transform: context links ("pip
  pst title=[[Ns:Somearticle]]
  !! wikitext
  [[|Article]]
 -!! html
 +!! html/php
  [[Ns:Article|Article]]
  !! end
  
@@@ -12051,7 -11803,7 +12060,7 @@@ pre-save transform: context links ("pip
  pst title=[[Ns:Somearticle (context)]]
  !! wikitext
  [[|Article]]
 -!! html
 +!! html/php
  [[Ns:Article (context)|Article]]
  !! end
  
@@@ -12061,7 -11813,7 +12070,7 @@@ pre-save transform: context links ("pip
  pst title=[[Ns:Somearticle, Context, Whatever]]
  !! wikitext
  [[|Article]]
 -!! html
 +!! html/php
  [[Ns:Article, Context, Whatever|Article]]
  !! end
  
@@@ -12071,7 -11823,7 +12080,7 @@@ pre-save transform: context links ("pip
  pst title=[[Ns:Somearticle, Context (context)]]
  !! wikitext
  [[|Article]]
 -!! html
 +!! html/php
  [[Ns:Article (context)|Article]]
  !! end
  
@@@ -12081,7 -11833,7 +12090,7 @@@ pre-save transform: context links ("pip
  pst title=[[Ns:Somearticle (IGNORED), Context]]
  !! wikitext
  [[|Article]]
 -!! html
 +!! html/php
  [[Ns:Article, Context|Article]]
  !! end
  
  [[|Article(context)]]
  [[Bar:X(Y)Z|]]
  [[:Bar:X(Y)Z|]]
 -!! html
 +!! html/php
  [[Article(context)|Article]]
  [[Bar:Article(context)|Article]]
  [[:Bar:Article(context)|Article]]
  [[|Article (context)]]
  [[Bar:X (Y) Z|]]
  [[:Bar:X (Y) Z|]]
 -!! html
 +!! html/php
  [[Article (context)|Article]]
  [[Bar:Article (context)|Article]]
  [[:Bar:Article (context)|Article]]
  [[|Article(context)]]
  [[Bar:X(Y)Z|]]
  [[:Bar:X(Y)Z|]]
 -!! html
 +!! html/php
  [[Article(context)|Article]]
  [[Bar:Article(context)|Article]]
  [[:Bar:Article(context)|Article]]
  [[Bar:Article (context),context|]]
  [[:Bar:Article (context), context|]]
  [[:Bar:Article (context),context|]]
 -!! html
 +!! html/php
  [[Article (context), context|Article]]
  [[Article (context),context|Article]]
  [[Bar:Article (context), context|Article]]
@@@ -12175,7 -11927,7 +12184,7 @@@ Empty lines are trimme
  
  
  
 -!! html
 +!! html/php
  Empty lines are trimmed
  !! end
  
  * <noinclude>~~~</noinclude>
  * <includeonly>~~~</includeonly>
  * <onlyinclude>~~~</onlyinclude>
 -!! html
 +!! html/php
  * [[Special:Contributions/127.0.0.1|127.0.0.1]]
  * <noinclude>[[Special:Contributions/127.0.0.1|127.0.0.1]]</noinclude>
  * <includeonly>[[Special:Contributions/127.0.0.1|127.0.0.1]]</includeonly>
@@@ -12219,7 -11971,7 +12228,7 @@@ As well as inside noinclude/onlyinclud
  
  But not inside includeonly
  <includeonly>{{subst:Foo}}</includeonly>
 -!! html
 +!! html/php
  Shall not expand:
  
  <nowiki>~~~~</nowiki>
@@@ -12274,7 -12026,7 +12283,7 @@@ parsoid=wt2htm
  Parsoid: Escape nowiki with trailing space in tags
  !! options
  parsoid=html2wt
 -!! html
 +!! html/parsoid
  <p>&lt;nowiki &gt; foo &lt/nowiki ></p>
  <p>a&lt;nowiki /&gt;b</p>
  <p>c&lt;nowiki/ &gt;d</p>
@@@ -12290,7 -12042,7 +12299,7 @@@ c&lt;nowiki/ &gt;
  Parsoid: Escape weird noWikI capitalizations
  !! options
  parsoid=html2wt
 -!! html
 +!! html/parsoid
  <p>&lt;noWikI &gt; foo &lt/NoWikI ></p>
  !! wikitext
  &lt;noWikI &gt; foo &lt;/NoWikI &gt;
@@@ -12731,21 -12483,6 +12740,21 @@@ Image with link parameter, protocol-les
  <p><span class="mw-default-size" typeof="mw:Image"><a href="//example.com/"><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
 +Escaping non-block captions (T107435)
 +!! options
 +parsoid={
 +  "modes": ["wt2wt"],
 +  "changes": [
 +    ["[typeof~='mw:Image']", "attr", "data-mw", "{\"caption\": \"|\"}"]
 +  ]
 +}
 +!! wikitext
 +[[Image:Foobar.jpg|caption]]
 +!! wikitext/edited
 +[[Image:Foobar.jpg|<nowiki>|</nowiki>]]
 +!! end
 +
  !! test
  Image with link parameter, wgExternalLinkTarget
  !! wikitext
@@@ -12934,6 -12671,8 +12943,6 @@@ parsoid=wt2html,wt2wt,html2htm
  
  !! test
  Image with wiki markup in implicit alt
 -!! options
 -parsoid=wt2html,wt2wt,html2html
  !! wikitext
  [[Image:Foobar.jpg|testing '''bold''' in alt]]
  
  </p><p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="testing bold in alt" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
  </p>
  !! html/parsoid
 -<p><span class="mw-default-size" typeof="mw:Image" data-mw="{&quot;caption&quot;:&quot;testing '''bold''' in alt&quot;}"><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"><a href="./File:Foobar.jpg"><img alt="testing bold in alt" 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":"testing &lt;b data-parsoid=\"{&amp;quot;dsr&amp;quot;:[27,37,3,3]}\">bold&lt;/b> in alt"}'><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" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"resource":"Image:Foobar.jpg"}}'/></a></span></p>
 +<p><span class="mw-default-size" typeof="mw:Image"><a href="./File:Foobar.jpg"><img alt="testing bold in alt" 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":{"alt":"testing bold in alt","resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"alt":"alt=testing &#39;&#39;&#39;bold&#39;&#39;&#39; in alt","resource":"Image:Foobar.jpg"}}'/></a></span></p>
  !! end
  
  !! test
@@@ -13025,7 -12764,7 +13034,7 @@@ parsoid=wt2html,wt2wt,html2htm
  ###################
  # Image sizing.
  # See https://www.mediawiki.org/wiki/Help:Images#Size_and_frame
 -# and https://bugzilla.wikimedia.org/show_bug.cgi?id=62258
 +# and https://phabricator.wikimedia.org/T64258
  # Foobar has actual size of 1941x220
  # 1. Thumbs & frameless always reduce, can't be enlarged unless it's
  #    a scalable format.
@@@ -13182,7 -12921,7 +13191,7 @@@ Frameless image caption with a free UR
  <p><a href="/wiki/File:Foobar.jpg" class="image" title="http://example.com"><img alt="http://example.com" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
  </p>
  !! html/parsoid
 -<p><span class="mw-default-size" typeof="mw:Image" data-mw='{"caption":"http://example.com"}'><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;a rel=\"mw:ExtLink\" href=\"http://example.com\" data-parsoid=\"{&amp;quot;stx&amp;quot;:&amp;quot;url&amp;quot;,&amp;quot;dsr&amp;quot;:[18,36,0,0]}\">http://example.com&lt;/a>"}'><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
@@@ -13258,7 -12997,7 +13267,7 @@@ BUG 1887: A ISBN with a thumbnai
  <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:ExtLink">ISBN 1235467890</a></figcaption></figure>
  !! end
  
  !! test
@@@ -13292,7 -13031,7 +13301,7 @@@ BUG 648: Frameless image caption with 
  <p><a href="/wiki/File:Foobar.jpg" class="image" title="text with a link in it"><img alt="text with a link in it" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
  </p>
  !! html/parsoid
 -<p><span class="mw-default-size" typeof="mw:Image" data-mw='{"caption":"text with a [[link]] in it"}'><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":"text with a &lt;a rel=\"mw:WikiLink\" href=\"./Link\" title=\"Link\" data-parsoid=\"{&amp;quot;stx&amp;quot;:&amp;quot;simple&amp;quot;,&amp;quot;a&amp;quot;:{&amp;quot;href&amp;quot;:&amp;quot;./Link&amp;quot;},&amp;quot;sa&amp;quot;:{&amp;quot;href&amp;quot;:&amp;quot;link&amp;quot;},&amp;quot;dsr&amp;quot;:[30,38,2,2]}\">link&lt;/a> in it"}'><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
@@@ -13303,7 -13042,7 +13312,7 @@@ BUG 648: Frameless image caption with 
  <p><a href="/wiki/File:Foobar.jpg" class="image" title="text with a linkfoo in it"><img alt="text with a linkfoo in it" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
  </p>
  !! html/parsoid
 -<p><span class="mw-default-size" typeof="mw:Image" data-mw='{"caption":"text with a [[link]]foo in it"}'><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":"text with a &lt;a rel=\"mw:WikiLink\" href=\"./Link\" title=\"Link\" data-parsoid=\"{&amp;quot;stx&amp;quot;:&amp;quot;simple&amp;quot;,&amp;quot;a&amp;quot;:{&amp;quot;href&amp;quot;:&amp;quot;./Link&amp;quot;},&amp;quot;sa&amp;quot;:{&amp;quot;href&amp;quot;:&amp;quot;link&amp;quot;},&amp;quot;dsr&amp;quot;:[30,41,2,5],&amp;quot;tail&amp;quot;:&amp;quot;foo&amp;quot;}\">linkfoo&lt;/a> in it"}'><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
@@@ -13314,7 -13053,7 +13323,7 @@@ BUG 648: Frameless image caption with a
  <p><a href="/wiki/File:Foobar.jpg" class="image" title="text with a MeatBall:Link in it"><img alt="text with a MeatBall:Link in it" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
  </p>
  !! html/parsoid
 -<p><span class="mw-default-size" typeof="mw:Image" data-mw='{"caption":"text with a [[MeatBall:Link]] in it"}'><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":"text with a &lt;a rel=\"mw:ExtLink\" href=\"http://www.usemod.com/cgi-bin/mb.pl?Link\" title=\"meatball:Link\" data-parsoid=\"{&amp;quot;stx&amp;quot;:&amp;quot;simple&amp;quot;,&amp;quot;a&amp;quot;:{&amp;quot;href&amp;quot;:&amp;quot;http://www.usemod.com/cgi-bin/mb.pl?Link&amp;quot;},&amp;quot;sa&amp;quot;:{&amp;quot;href&amp;quot;:&amp;quot;MeatBall:Link&amp;quot;},&amp;quot;isIW&amp;quot;:true,&amp;quot;dsr&amp;quot;:[30,47,2,2]}\">MeatBall:Link&lt;/a> in it"}'><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
@@@ -13325,15 -13064,7 +13334,15 @@@ BUG 648: Frameless image caption with 
  <p><a href="/wiki/File:Foobar.jpg" class="image" title="text with a link in it"><img alt="text with a link in it" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
  </p>
  !! html/parsoid
 -<p><span class="mw-default-size" typeof="mw:Image" data-mw='{"caption":"text with a [[MeatBall:Link|link]] in it"}'><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":"text with a &lt;a rel=\"mw:ExtLink\" href=\"http://www.usemod.com/cgi-bin/mb.pl?Link\" title=\"meatball:Link\" data-parsoid=\"{&amp;quot;stx&amp;quot;:&amp;quot;piped&amp;quot;,&amp;quot;a&amp;quot;:{&amp;quot;href&amp;quot;:&amp;quot;http://www.usemod.com/cgi-bin/mb.pl?Link&amp;quot;},&amp;quot;sa&amp;quot;:{&amp;quot;href&amp;quot;:&amp;quot;MeatBall:Link&amp;quot;},&amp;quot;isIW&amp;quot;:true,&amp;quot;dsr&amp;quot;:[30,52,16,2]}\">link&lt;/a> in it"}'><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
 +T107474: Frameless image caption with <nowiki>
 +!! 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" 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
@@@ -13344,7 -13075,7 +13353,7 @@@ Escape HTML special chars in image alt 
  <p><a href="/wiki/File:Foobar.jpg" class="image" title="&amp; &lt; &gt; &quot;"><img alt="&amp; &lt; &gt; &quot;" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
  </p>
  !! html/parsoid
 -<p><span class="mw-default-size" typeof="mw:Image" data-mw='{"caption":"&amp; &lt; > \""}'><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":"&amp;amp; &amp;lt; &amp;gt; \""}'><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
@@@ -13355,7 -13086,7 +13364,7 @@@ BUG 499: Alt text should have &#1234;, 
  <p><a href="/wiki/File:Foobar.jpg" class="image" title="♀"><img alt="♀" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
  </p>
  !! html/parsoid
 -<p><span class="mw-default-size" typeof="mw:Image" data-mw='{"caption":"&amp;#9792;"}'><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:Entity\" data-parsoid=\"{&amp;quot;src&amp;quot;:&amp;quot;&amp;amp;#9792;&amp;quot;,&amp;quot;srcContent&amp;quot;:&amp;quot;♀&amp;quot;,&amp;quot;dsr&amp;quot;:[18,25,null,null]}\">♀&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
@@@ -13682,7 -13413,7 +13691,7 @@@ Parsoid-specific image handling - simpl
  !! wikitext
  [[File:Foobar.jpg|<table><tr><td>a</td><td>b</td></tr><tr><td>c</td></tr></table>]]
  !! html/parsoid
 -<p><span class="mw-default-size" typeof="mw:Image" data-mw='{"caption":"&lt;table>&lt;tr>&lt;td>a&lt;/td>&lt;td>b&lt;/td>&lt;/tr>&lt;tr>&lt;td>c&lt;/td>&lt;/tr>&lt;/table>"}'><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;table data-parsoid=\"{&amp;quot;stx&amp;quot;:&amp;quot;html&amp;quot;,&amp;quot;dsr&amp;quot;:[18,81,7,8]}\">&lt;tbody data-parsoid=\"{&amp;quot;dsr&amp;quot;:[25,73,0,0]}\">&lt;tr data-parsoid=\"{&amp;quot;stx&amp;quot;:&amp;quot;html&amp;quot;,&amp;quot;dsr&amp;quot;:[25,54,4,5]}\">&lt;td data-parsoid=\"{&amp;quot;stx&amp;quot;:&amp;quot;html&amp;quot;,&amp;quot;dsr&amp;quot;:[29,39,4,5]}\">a&lt;/td>&lt;td data-parsoid=\"{&amp;quot;stx&amp;quot;:&amp;quot;html&amp;quot;,&amp;quot;dsr&amp;quot;:[39,49,4,5]}\">b&lt;/td>&lt;/tr>&lt;tr data-parsoid=\"{&amp;quot;stx&amp;quot;:&amp;quot;html&amp;quot;,&amp;quot;dsr&amp;quot;:[54,73,4,5]}\">&lt;td data-parsoid=\"{&amp;quot;stx&amp;quot;:&amp;quot;html&amp;quot;,&amp;quot;dsr&amp;quot;:[58,68,4,5]}\">c&lt;/td>&lt;/tr>&lt;/tbody>&lt;/table>"}'><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
  bar</p>
  !! end
  
 +## Edge case bug in Parsoid
 +!! test
 +T93580: Templated <ref> inside 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
  
  ###
  ### Subpages
@@@ -14147,7 -13866,7 +14156,7 @@@ parsoid=wt2htm
  !! html/parsoid
  <ul>
  <li>This <link rel="mw:PageProp/Category" href="./Category:Foo"/> and this should be part of the same list item</li>
 -<li>So should this <link rel="mw:PageProp/Category" href="Category:Foo" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[[Category:Foo]] and this should be part of the same list item"}},"i":0}}]}'/><span> and this should be part of the same list item</span></li>
 +<li>So should this <link rel="mw:PageProp/Category" href="./Category:Foo" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[[Category:Foo]] and this should be part of the same list item"}},"i":0}}]}'/><span> and this should be part of the same list item</span></li>
  </ul>
  !! end
  
@@@ -14256,8 -13975,8 +14265,8 @@@ parsoi
  [[:Category:Foo|Bar]]
  !! html
  <p>
 -<a rel="mw:WikiLink" href="Category:Foo" title="Category:Foo">Category:Foo</a>
 -<a rel="mw:WikiLink" href="Category:Foo" title="Category:Foo">Bar</a>
 +<a rel="mw:WikiLink" href="./Category:Foo" title="Category:Foo">Category:Foo</a>
 +<a rel="mw:WikiLink" href="./Category:Foo" title="Category:Foo">Bar</a>
  </p>
  !! end
  
@@@ -14301,15 -14020,15 +14310,15 @@@ parsoi
  [[Category:Foo]]
  [[Category:Foo|Bar]]
  !! html
 -<link rel="mw:PageProp/Category" href="Category:Foo">
 -<link rel="mw:PageProp/Category" href="Category:Foo#Bar">
 +<link rel="mw:PageProp/Category" href="./Category:Foo">
 +<link rel="mw:PageProp/Category" href="./Category:Foo#Bar">
  !! end
  
  !! test
  Normalize hrefs properly before testing for invalid link targets (bug 70894)
  !! options
  parsoid=html2wt
 -!! html
 +!! html/parsoid
  <link rel="mw:PageProp/Category" href="./Category:Toxine_bactérienne"/>
  !! wikitext
  [[Category:Toxine bactérienne]]
@@@ -15209,8 -14928,11 +15218,8 @@@ I always thought &xacute; was a cute le
  </p>
  !! end
  
 -# TODO: generalize to PHP parser?
  !! test
  HTML5 tags
 -!! options
 -parsoid
  !! wikitext
  <data value="5">five</data>
  <time datetime="2000-01-01T00:00Z">The new millenium started</time>
  !! html
  <p><data value="5">five</data>
  <time datetime="2000-01-01T00:00Z">The new millenium started</time>
 -<mark>This highlighted text</mark></p>
 +<mark>This highlighted text</mark>
 +</p>
  !! end
  
  !! test
@@@ -15459,19 -15180,13 +15468,19 @@@ Attribute test: unquoted but illegal va
  </p>
  !! end
  
 +# Parsoid does not serialize to empty attribute syntax,
 +# so wt2wt and html2wt cases are skipped
  !! test
 -Attribute test: no value
 +Attribute test: no value (T54330)
 +!! options
 +parsoid=wt2html,html2html
  !! wikitext
  <font color>foo</font>
 -!! html
 -<p><font color="color">foo</font>
 +!! html/php
 +<p><font color="">foo</font>
  </p>
 +!! html/parsoid
 +<p><font color="">foo</font></p>
  !! end
  
  !! test
@@@ -15843,7 -15558,7 +15852,7 @@@ CSS line continuation 
  !! wikitext
  <div style="background-image: u\&#13;rl(test.jpg); "></div>
  !! html
 -<div style="/* insecure input */"></div>
 +<div style="/* invalid control char */"></div>
  
  !! end
  
@@@ -15900,7 -15615,7 +15909,7 @@@ evil <math>-wiki-tags without Extension
  Parser hook: empty input
  !! wikitext
  <tag></tag>
 -!! html
 +!! html/php
  <pre>
  ''
  array (
  Parser hook: empty input using terminated empty elements
  !! wikitext
  <tag/>
 -!! html
 +!! html/php
  <pre>
  NULL
  array (
  Parser hook: empty input using terminated empty elements (space before)
  !! wikitext
  <tag />
 -!! html
 +!! html/php
  <pre>
  NULL
  array (
  Parser hook: basic input
  !! wikitext
  <tag>input</tag>
 -!! html
 +!! html/php
  <pre>
  'input'
  array (
  Parser hook: case insensitive
  !! wikitext
  <TAG>input</TAG>
 -!! html
 +!! html/php
  <pre>
  'input'
  array (
  Parser hook: case insensitive, redux
  !! wikitext
  <TaG>input</TAg>
 -!! html
 +!! html/php
  <pre>
  'input'
  array (
@@@ -15982,7 -15697,7 +15991,7 @@@ Parser hook: nested tag
  noxml
  !! wikitext
  <tag><tag></tag></tag>
 -!! html
 +!! html/php
  <pre>
  '<tag>'
  array (
  Parser hook: basic arguments
  !! wikitext
  <tag width=200 height = "100" depth = '50' square></tag>
 -!! html
 +!! html/php
  <pre>
  ''
  array (
    'width' => '200',
    'height' => '100',
    'depth' => '50',
 -  'square' => 'square',
 +  'square' => '',
  )
  </pre>
  
  Parser hook: argument containing a forward slash (bug 5344)
  !! wikitext
  <tag filename='/tmp/bla'></tag>
 -!! html
 +!! html/php
  <pre>
  ''
  array (
  Parser hook: empty input using terminated empty elements (bug 2374)
  !! wikitext
  <tag foo=bar/>text
 -!! html
 +!! html/php
  <pre>
  NULL
  array (
@@@ -16043,14 -15758,14 +16052,14 @@@ Parser hook: basic arguments using term
  <tag width=200 height = "100" depth = '50' square/>
  other stuff
  </tag>
 -!! html
 +!! html/php
  <pre>
  NULL
  array (
    'width' => '200',
    'height' => '100',
    'depth' => '50',
 -  'square' => 'square',
 +  'square' => '',
  )
  </pre>
  <p>other stuff
@@@ -16067,7 -15782,7 +16076,7 @@@ Parser hook: static parser hook not ins
  !! wikitext
  <statictag>hello, world</statictag>
  <statictag action=flush/>
 -!! html
 +!! html/php
  <p>hello, world
  </p>
  !! end
@@@ -16078,7 -15793,7 +16087,7 @@@ Parser hook: static parser hook inside 
  !! wikitext
  <!-- <statictag>hello, world</statictag> -->
  <statictag action=flush/>
 -!! html
 +!! html/php
  <p><br />
  </p>
  !! end
@@@ -16137,24 -15852,20 +16146,24 @@@ Sanitizer: Closing of open but not clos
  
  !! test
  Sanitizer: Closing of closed but not open tags
 +!! options
 +parsoid=wt2html
  !! wikitext
  </s>
 -!! html
 -<p>&lt;/s&gt;
 -</p>
 +!! html/php+tidy
 +!! html/parsoid
  !! end
  
  !! test
  Sanitizer: Closing of closed but not open table tags
 +!! options
 +parsoid=wt2html
  !! wikitext
  Table not started</td></tr></table>
 -!! html
 -<p>Table not started&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
 -</p>
 +!! html/php+tidy
 +<p>Table not started</p>
 +!! html/parsoid
 +<p>Table not started</p>
  !! end
  
  !! test
@@@ -16201,7 -15912,7 +16210,7 @@@ Sanitizer: Validating that <meta> and <
        <link rel="stylesheet" itemprop="hello" href="{{SERVER}}">
  </div>
  !! html
 -<div itemscope="itemscope">
 +<div itemscope="">
  <p>   <meta itemprop="hello" content="world" />
        &lt;meta http-equiv="refresh" content="5"&gt;
        <meta itemprop="hello" content="5" />
@@@ -16953,7 -16664,7 +16962,7 @@@ star
  ===bc===
  ==c==
  ===ca===
 -!! html
 +!! html/php
  start
  !! end
  
@@@ -16973,7 -16684,7 +16982,7 @@@ star
  ===bc===
  ==c==
  ===ca===
 -!! html
 +!! html/php
  ==a==
  ===aa===
  ====aaa====
@@@ -16995,7 -16706,7 +17004,7 @@@ star
  ===bc===
  ==c==
  ===ca===
 -!! html
 +!! html/php
  ===aa===
  ====aaa====
  !! end
@@@ -17016,7 -16727,7 +17025,7 @@@ star
  ===bc===
  ==c==
  ===ca===
 -!! html
 +!! html/php
  ====aaa====
  !! end
  
@@@ -17036,7 -16747,7 +17045,7 @@@ star
  ===bc===
  ==c==
  ===ca===
 -!! html
 +!! html/php
  ==b==
  ===ba===
  ===bb===
@@@ -17060,7 -16771,7 +17069,7 @@@ star
  ===bc===
  ==c==
  ===ca===
 -!! html
 +!! html/php
  ===ba===
  !! end
  
@@@ -17080,7 -16791,7 +17089,7 @@@ star
  ===bc===
  ==c==
  ===ca===
 -!! html
 +!! html/php
  ===bb===
  ====bba====
  !! end
@@@ -17101,7 -16812,7 +17110,7 @@@ star
  ===bc===
  ==c==
  ===ca===
 -!! html
 +!! html/php
  ====bba====
  !! end
  
@@@ -17121,7 -16832,7 +17130,7 @@@ star
  ===bc===
  ==c==
  ===ca===
 -!! html
 +!! html/php
  ===bc===
  !! end
  
@@@ -17141,7 -16852,7 +17150,7 @@@ star
  ===bc===
  ==c==
  ===ca===
 -!! html
 +!! html/php
  ==c==
  ===ca===
  !! end
@@@ -17162,7 -16873,7 +17171,7 @@@ star
  ===bc===
  ==c==
  ===ca===
 -!! html
 +!! html/php
  ===ca===
  !! end
  
@@@ -17182,7 -16893,7 +17191,7 @@@ star
  ===bc===
  ==c==
  ===ca===
 -!! html
 +!! html/php
  !! end
  
  !! test
@@@ -17193,7 -16904,7 +17202,7 @@@ section=
  ==a==
  ==bogus== not a legal section
  ==b==
 -!! html
 +!! html/php
  ==a==
  ==bogus== not a legal section
  !! end
@@@ -17206,7 -16917,7 +17215,7 @@@ section=
  ==a==
  ==bogus== not a legal section
  ==b==
 -!! html
 +!! html/php
  ==b==
  !! end
  
@@@ -17218,7 -16929,7 +17227,7 @@@ section=
  ==a==
  ==b== <!-- -->
  ==c==
 -!! html
 +!! html/php
  ==a==
  !! end
  
@@@ -17230,7 -16941,7 +17239,7 @@@ section=
  ==a==
  ==b== <!-- -->
  ==c==
 -!! html
 +!! html/php
  ==b== <!-- -->
  !! end
  
@@@ -17242,7 -16953,7 +17251,7 @@@ section=
  ==a==
  ==bogus== <nowiki>not a legal section</nowiki>
  ==b==
 -!! html
 +!! html/php
  ==a==
  ==bogus== <nowiki>not a legal section</nowiki>
  !! end
@@@ -17255,10 -16966,11 +17264,10 @@@ section=
  ==a==
  ==bogus== <nowiki>not a legal section</nowiki>
  ==b==
 -!! html
 +!! html/php
  ==b==
  !! end
  
 -
  # Formerly testing for bug 2587, now resolved by the use of unmarked sections
  # instead of respecting commented sections
  !! test
@@@ -17268,7 -16980,7 +17277,7 @@@ section=
  !! wikitext
  <!-- -->==sec1==
  ==sec2==
 -!! html
 +!! html/php
  ==sec2==
  !!end
  
@@@ -17279,10 -16991,11 +17288,10 @@@ section=
  !! wikitext
  <!-- -->==sec1==
  ==sec2==
 -!! html
 +!! html/php
  
  !!end
  
 -
  # Formerly testing for bug 2607, now resolved by the use of unmarked sections
  # instead of respecting HTML-style headings
  !! test
@@@ -17296,7 -17009,7 +17305,7 @@@ unmarke
  one
  ==2==
  two
 -!! html
 +!! html/php
  ==1==
  one
  !! end
@@@ -17312,7 -17025,7 +17321,7 @@@ unmarke
  one
  ==2==
  two
 -!! html
 +!! html/php
  ==2==
  two
  !! end
@@@ -17326,7 -17039,7 +17335,7 @@@ section=
  !! wikitext
  <noinclude>==unmarked==</noinclude>
  ==marked==
 -!! html
 +!! html/php
  ==marked==
  !!end
  
@@@ -17341,7 -17054,7 +17350,7 @@@ The line above must have a trailing spa
  === <!--
  --> <!-- -->
  But just in case it doesn't...
 -!! html
 +!! html/php
  === <!--
  --> <!-- -->
  But just in case it doesn't...
@@@ -17363,7 -17076,7 +17372,7 @@@ star
  ===bc===
  ==c==
  ===ca===
 -!! html
 +!! html/php
  xxx
  
  ==a==
@@@ -17394,7 -17107,7 +17403,7 @@@ star
  ===bc===
  ==c==
  ===ca===
 -!! html
 +!! html/php
  start
  xxx
  
@@@ -17423,7 -17136,7 +17432,7 @@@ star
  ===bc===
  ==c==
  ===ca===
 -!! html
 +!! html/php
  start
  ==a==
  xxx
@@@ -17453,7 -17166,7 +17462,7 @@@ star
  ===bc===
  ==c==
  ===ca===
 -!! html
 +!! html/php
  start
  ==a==
  ===aa===
@@@ -17484,7 -17197,7 +17493,7 @@@ star
  ===bc===
  ==c==
  ===ca===
 -!! html
 +!! html/php
  start
  ==a==
  ===aa===
@@@ -17511,7 -17224,7 +17520,7 @@@ star
  ===bc===
  ==c==
  ===ca===
 -!! html
 +!! html/php
  start
  ==a==
  ===aa===
@@@ -17542,7 -17255,7 +17551,7 @@@ star
  ===bc===
  ==c==
  ===ca===
 -!! html
 +!! html/php
  start
  ==a==
  ===aa===
@@@ -17572,7 -17285,7 +17581,7 @@@ star
  ===bc===
  ==c==
  ===ca===
 -!! html
 +!! html/php
  start
  ==a==
  ===aa===
@@@ -17603,7 -17316,7 +17612,7 @@@ star
  ===bc===
  ==c==
  ===ca===
 -!! html
 +!! html/php
  start
  ==a==
  ===aa===
@@@ -17634,7 -17347,7 +17643,7 @@@ star
  ===bc===
  ==c==
  ===ca===
 -!! html
 +!! html/php
  start
  ==a==
  ===aa===
@@@ -17663,7 -17376,7 +17672,7 @@@ star
  ===bc===
  ==c==
  ===ca===
 -!! html
 +!! html/php
  start
  ==a==
  ===aa===
@@@ -17685,7 -17398,7 +17694,7 @@@ replace=2,"xxx
   Preformatted initial line
  ==a==
  ===a===
 -!! html
 +!! html/php
   Preformatted initial line
  ==a==
  xxx
@@@ -17699,7 -17412,7 +17708,7 @@@ section=
  !! wikitext
  ==a==
                      a
 -!! html
 +!! html/php
  ==a==
                      a
  !! end
@@@ -17711,7 -17424,7 +17720,7 @@@ section=
  !! wikitext
  ==a==
                     a
 -!! html
 +!! html/php
  ==a==
                     a
  !! end
@@@ -17729,7 -17442,7 +17738,7 @@@ noxml section=
  
  == Section Two ==
  stuff
 -!! html
 +!! html/php
  == Section Two ==
  stuff
  !! end
@@@ -17746,7 -17459,7 +17755,7 @@@ noxml replace=2,"xxx
  
  == Section Two ==
  stuff
 -!! html
 +!! html/php
  == Section One ==
  <pre>
  =======
  !! end
  
  
 -
  !! test
  Handling of &#x0A; in URLs
  !! wikitext
@@@ -18176,38 -17890,6 +18185,38 @@@ parsoid=wt2html,wt2wt,html2htm
  <p><span typeof="mw:Entity">î</span><span typeof="mw:Entity">î</span></p>
  !! end
  
 +# See: http://www.w3.org/TR/html5/syntax.html#character-references
 +# Note that U+000C (form feed) is not a valid XML character, so
 +# it is banned even though allowed in HTML5.
 +!! test
 +Illegal character references (T106578)
 +!! wikitext
 +; Null: &#00;
 +; FF: &#xC;
 +; CR: &#xD;
 +; Control (low): &#8;
 +; Control (high): &#x7F; &#x9F;
 +; Surrogate: &#xD83D;&#xDCA9;
 +; This is an okay astral character: &#x1F4A9;
 +!! html+tidy
 +<dl>
 +<dt>Null</dt>
 +<dd>&amp;#00;</dd>
 +<dt>FF</dt>
 +<dd>&amp;#xC;</dd>
 +<dt>CR</dt>
 +<dd>&amp;#xD;</dd>
 +<dt>Control (low)</dt>
 +<dd>&amp;#8;</dd>
 +<dt>Control (high)</dt>
 +<dd>&amp;#x7F; &amp;#x9F;</dd>
 +<dt>Surrogate</dt>
 +<dd>&amp;#xD83D;&amp;#xDCA9;</dd>
 +<dt>This is an okay astral character</dt>
 +<dd>💩</dd>
 +</dl>
 +!! end
 +
  !! test
  __FORCETOC__ override
  !! wikitext
@@@ -18251,31 -17933,21 +18260,31 @@@ ISBN ISBN 123456789
  <p>ISBN <a href="./Special:BookSources/1234567890" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a></p>
  !! end
  
 +# Uppercase X and lowercase x as well
  !! test
  ISBN with an X
  !! wikitext
  ISBN 3-462-04561-X
 +ISBN 3-462-04561-x
  ISBN 080442957X
 +ISBN 080442957x
  ISBN 978080442957X
 +ISBN 978080442957x
  !! html/php
  <p><a href="/wiki/Special:BookSources/346204561X" class="internal mw-magiclink-isbn">ISBN 3-462-04561-X</a>
 +<a href="/wiki/Special:BookSources/346204561X" class="internal mw-magiclink-isbn">ISBN 3-462-04561-x</a>
  <a href="/wiki/Special:BookSources/080442957X" class="internal mw-magiclink-isbn">ISBN 080442957X</a>
 +<a href="/wiki/Special:BookSources/080442957X" class="internal mw-magiclink-isbn">ISBN 080442957x</a>
  <a href="/wiki/Special:BookSources/978080442957X" class="internal mw-magiclink-isbn">ISBN 978080442957X</a>
 +<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/978080442957X" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>ISBN 978080442957X</a></p>
 +<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>
  !! end
  
  !! test
@@@ -18286,7 -17958,7 +18295,7 @@@ ISBN 123456789
  <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:ExtLink">ISBN 1234567890</a></p>
  !! end
  
  !! test
@@@ -18584,7 -18256,7 +18593,7 @@@ Don't fall for the self-closing di
  MSGNW magic word
  !! wikitext
  {{MSGNW:msg}}
 -!! html
 +!! html/php
  <p>&#91;&#91;:Template:Msg&#93;&#93;
  </p>
  !! end
@@@ -20017,7 -19689,7 +20026,7 @@@ wgAllowDisplayTitle=tru
  wgRestrictDisplayTitle=false
  !! wikitext
  this is not the the title
 -!! html
 +!! html/php
  Parser test
  <p>this is not the the title
  </p>
@@@ -20034,7 -19706,7 +20043,7 @@@ wgRestrictDisplayTitle=fals
  !! wikitext
  this is not the the title
  {{DISPLAYTITLE:whatever}}
 -!! html
 +!! html/php
  whatever
  <p>this is not the the title
  </p>
@@@ -20051,7 -19723,7 +20060,7 @@@ wgRestrictDisplayTitle=tru
  !! wikitext
  this is not the the title
  {{DISPLAYTITLE:whatever}}
 -!! html
 +!! html/php
  Screen
  <p>this is not the the title
  </p>
@@@ -20068,7 -19740,7 +20077,7 @@@ wgRestrictDisplayTitle=tru
  !! wikitext
  this is not the the title
  {{DISPLAYTITLE:screen}}
 -!! html
 +!! html/php
  screen
  <p>this is not the the title
  </p>
@@@ -20084,7 -19756,7 +20093,7 @@@ wgAllowDisplayTitle=fals
  !! wikitext
  this is not the the title
  {{DISPLAYTITLE:screen}}
 -!! html
 +!! html/php
  Screen
  <p>this is not the the title
  <a href="/index.php?title=Template:DISPLAYTITLE:screen&amp;action=edit&amp;redlink=1" class="new" title="Template:DISPLAYTITLE:screen (page does not exist)">Template:DISPLAYTITLE:screen</a>
@@@ -20100,7 -19772,7 +20109,7 @@@ title=[[Screen]
  wgAllowDisplayTitle=false
  !! wikitext
  this is not the the title
 -!! html
 +!! html/php
  Screen
  <p>this is not the the title
  </p>
@@@ -20117,7 -19789,7 +20126,7 @@@ wgRestrictDisplayTitle=tru
  !! wikitext
  this is not the the title
  {{DISPLAYTITLE:<span style="display: none;">s</span>creen}}
 -!! html
 +!! html/php
  <span style="/* attempt to bypass $wgRestrictDisplayTitle */">s</span>creen
  <p>this is not the the title
  </p>
@@@ -20134,7 -19806,7 +20143,7 @@@ wgRestrictDisplayTitle=tru
  !! wikitext
  this is not the the title
  {{DISPLAYTITLE:<span style="color: red;">s</span>creen}}
 -!! html
 +!! html/php
  <span style="color: red;">s</span>creen
  <p>this is not the the title
  </p>
@@@ -20159,7 -19831,7 +20168,7 @@@ Page status indicators: Weird syntaxes 
  showindicators
  !! wikitext
  <indicator name="empty" />
 -<indicator name></indicator>
 +<indicator name="name"></indicator>
  !! html
  empty=
  name=
@@@ -20222,7 -19894,7 +20231,7 @@@ preload: check <noinclude> and <include
  preload
  !! wikitext
  Hello <noinclude>cruel</noinclude><includeonly>kind</includeonly> world.
 -!! html
 +!! html/php
  Hello kind world.
  !! end
  
@@@ -20232,7 -19904,7 +20241,7 @@@ preload: check <onlyinclude
  preload
  !! wikitext
  Goodbye <onlyinclude>Hello world</onlyinclude>
 -!! html
 +!! html/php
  Hello world
  !! end
  
@@@ -20242,7 -19914,7 +20251,7 @@@ preload: can pass tags through if we wa
  preload
  !! wikitext
  <includeonly><</includeonly>includeonly>Hello world<includeonly><</includeonly>/includeonly>
 -!! html
 +!! html/php
  <includeonly>Hello world</includeonly>
  !! end
  
@@@ -20252,7 -19924,7 +20261,7 @@@ preload: check that it doesn't try to d
  preload
  !! wikitext
  * <!-- Hello --> ''{{world}}'' {{<includeonly>subst:</includeonly>How are you}}{{ {{{|safesubst:}}} #if:1|2|3}}
 -!! html
 +!! html/php
  * <!-- Hello --> ''{{world}}'' {{subst:How are you}}{{ {{{|safesubst:}}} #if:1|2|3}}
  !! end
  
@@@ -20305,7 -19977,7 +20314,7 @@@ percent-encoding and + signs in interna
  !! html/parsoid
  <p><a rel="mw:WikiLink" href="./User:+%25" title="User:+%">User:+%</a> <a rel="mw:WikiLink" href="Page+title%25" title="Page+title%">Page+title%</a>
  <a rel="mw:WikiLink" href="%25+" title="%+">%+</a> <a rel="mw:WikiLink" href="%25+" title="%+">%20</a> <a rel="mw:WikiLink" href="%25+" title="%+">%+ </a> <a rel="mw:WikiLink" href="%25+r" title="%+r">%+r</a>
 -<a rel="mw:WikiLink" href="%25" title="%">%</a> <a rel="mw:WikiLink" href="+" title="+">+</a> <span class="mw-default-size" typeof="mw:Error mw:Image" data-parsoid='{"optList":[{"ck":"bogus","ak":"foo"},{"ck":"caption","ak":"[[bar]]"}]}' data-mw='{"errors":[{"key":"missing-image","message":"This image does not exist."}],"caption":"[[bar]]"}'><a href="./File:%25+abc9" data-parsoid='{"a":{"href":"./File:%25+abc9"},"sa":{}}'><img resource="./File:%25+abc9" src="./Special:FilePath/%25+abc9" height="220" width="220" data-parsoid='{"a":{"resource":"./File:%25+abc9","height":"220","width":"220"},"sa":{"resource":"File:%+abc%39"}}'/></a></span>
 +<a rel="mw:WikiLink" href="%25" title="%">%</a> <a rel="mw:WikiLink" href="+" title="+">+</a> <span class="mw-default-size" typeof="mw:Error mw:Image" data-parsoid='{"optList":[{"ck":"bogus","ak":"foo"},{"ck":"caption","ak":"[[bar]]"}]}' data-mw='{"errors":[{"key":"missing-image","message":"This image does not exist."}],"caption":"&lt;a rel=\"mw:WikiLink\" href=\"./Bar\" title=\"Bar\" data-parsoid=\"{&amp;quot;stx&amp;quot;:&amp;quot;simple&amp;quot;,&amp;quot;a&amp;quot;:{&amp;quot;href&amp;quot;:&amp;quot;./Bar&amp;quot;},&amp;quot;sa&amp;quot;:{&amp;quot;href&amp;quot;:&amp;quot;bar&amp;quot;},&amp;quot;dsr&amp;quot;:[94,101,2,2]}\">bar&lt;/a>"}'><a href="./File:%25+abc9"><img resource="./File:%25+abc9" src="./Special:FilePath/%25+abc9" height="220" width="220" data-parsoid='{"a":{"resource":"./File:%25+abc9","height":"220","width":"220"},"sa":{"resource":"File:%+abc%39"}}'/></a></span>
  <a rel="mw:WikiLink" href="./3E" title="3E" data-parsoid='{"stx":"simple","a":{"href":"./3E"},"sa":{"href":"%33%45"}}'>3E</a> <a rel="mw:WikiLink" href="./3E+" title="3E+" data-parsoid='{"stx":"simple","a":{"href":"./3E+"},"sa":{"href":"%33%45+"}}'>3E+</a></p>
  !! end
  
@@@ -20320,7 -19992,7 +20329,7 @@@ Special characters in embedded file lin
  </p>
  !! html/parsoid
  <p><span class="mw-default-size" typeof="mw:Error mw:Image" data-mw='{"errors":[{"key":"missing-image","message":"This image does not exist."}]}'><a href="./File:Contains_&amp;_ampersand.jpg"><img resource="./File:Contains_&amp;_ampersand.jpg" src="./Special:FilePath/Contains_&amp;_ampersand.jpg" height="220" width="220"/></a></span>
 -<span class="mw-default-size" typeof="mw:Error mw:Image" data-mw='{"errors":[{"key":"missing-image","message":"This image does not exist."}],"caption":"Title with &amp; ampersand"}'><a href="./File:Does_not_exist.jpg"><img resource="./File:Does_not_exist.jpg" src="./Special:FilePath/Does_not_exist.jpg" height="220" width="220"/></a></span></p>
 +<span class="mw-default-size" typeof="mw:Error mw:Image" data-mw='{"errors":[{"key":"missing-image","message":"This image does not exist."}],"caption":"Title with &amp;amp; ampersand"}'><a href="./File:Does_not_exist.jpg"><img resource="./File:Does_not_exist.jpg" src="./Special:FilePath/Does_not_exist.jpg" height="220" width="220"/></a></span></p>
  !! end
  
  !! test
@@@ -21084,30 -20756,6 +21093,30 @@@ parsoid=wt2html,wt2w
  <small><figure class="mw-halign-right" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/300px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="34" width="300"/></a></figure></small>
  !! end
  
 +!! test
 +3. Bad treebuilder fixup of formatting elt is cleaned up
 +!! options
 +parsoid=wt2html,wt2wt
 +!! wikitext
 +<small>'''foo[[File:Foobar.jpg|thumb|caption]]bar'''</small>
 +!! html/parsoid
 +<p><small><b>foo</b></small></p>
 +<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><small><b>caption</b></small></figcaption></figure>
 +<p><small><b>bar</b></small></p>
 +!! end
 +
 +!! test
 +4. Bad treebuilder fixup of formatting elt is cleaned up: formatting tags around captionless images are ignored
 +!! options
 +parsoid=wt2html,wt2wt
 +!! wikitext
 +'''<small>[[Image:Foobar.jpg|right|300px]]</small>'''
 +!! html/parsoid
 +<p><b><small></small></b></p>
 +<figure class="mw-halign-right" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/300px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="34" width="300"/></a></figure>
 +<p></p>
 +!! end
 +
  #### ----------------------------------------------------------------
  #### Parsoid-only testing of Parsoid's impl of <ref> and <references>
  #### tags. Parsoid's output for these tags differs from that of the
@@@ -21831,7 -21479,7 +21840,7 @@@ parsoi
  Headings: 1. Nested inside html
  !! options
  parsoid=html2wt
 -!! html
 +!! html/parsoid
  <h1>=foo=</h1>
  <h2>=foo=</h2>
  <h3>=foo=</h3>
  Headings: 2. Outside heading nest on a single line <h1>foo</h1>*bar
  !! options
  parsoid=html2wt
 -!! html
 +!! html/parsoid
  <h1>foo</h1>*bar
  <h1>foo</h1>=bar
  <h1>foo</h1>=bar=
@@@ -21920,7 -21568,7 +21929,7 @@@ Headings: 4a. No escaping needed (testi
  Headings: 4b. No escaping needed (inside p-tags)
  !! options
  parsoid=html2wt
 -!! html
 +!! html/parsoid
  <p>===
  =foo= x
  =foo= <s></s>
@@@ -21961,6 -21609,8 +21970,6 @@@ Headings: 5. Empty heading
  
  !! test
  Headings: 6a. Heading chars in SOL context (with trailing spaces)
 -!! options
 -parsoid
  !! wikitext
  <nowiki>=a=</nowiki>
  
  <nowiki>=a=</nowiki>  
  
  <nowiki>=a=</nowiki>  
 -!! html
 -<p>=a=</p>
 -<p>=a= </p>
 -<p>=a=        </p>
 -<p>=a=        </p>
 +!! 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)
 -!! options
 -parsoid
  !! wikitext
  <nowiki>=a=
  b</nowiki>
@@@ -21999,65 -21642,48 +22008,65 @@@ b</nowiki
  
  <nowiki>=a=    
  b</nowiki>
 -!! html
 +!! html/php
  <p>=a=
 -b</p>
 -<p>=a= 
 -b</p>
 -<p>=a=        
 -b</p>
 -<p>=a=         
 -b</p>
 +b
 +</p><p>=a= 
 +b
 +</p><p>=a=    
 +b
 +</p><p>=a=     
 +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>
 +
 +<p><span typeof="mw:Nowiki">=a=        
 +b</span></p>
  !!end
  
  !! test
  Headings: 6c. Heading chars in SOL context (leading newline break)
 -!! options
 -parsoid
  !! wikitext
  a
  <nowiki>=b=</nowiki>
 -!! html
 +!! html/php
  <p>a
 -=b=</p>
 +=b=
 +</p>
 +!! html/parsoid
 +<p>a
 +<span typeof="mw:Nowiki">=b=</span>
  !!end
  
  !! test
  Headings: 6d. Heading chars in SOL context (with interspersed comments)
 -!! options
 -parsoid
  !! wikitext
  <!--c0--><nowiki>=a=</nowiki>
  
  <!--c1--><nowiki>=a=</nowiki> <!--c2-->        <!--c3-->
 -!! html
 -<p><!--c0-->=a=</p>
 -<p><!--c1-->=a= <!--c2-->      <!--c3--></p>
 +!! 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
  Headings: 6d. Heading chars in SOL context (No escaping needed)
  !! options
  parsoid=html2wt
 -!! html
 +!! html/parsoid
  =a=<div>b</div>
  !! wikitext
  =a=<div>b</div>
  Headings: 7. Insert a newline between new content and headings
  !! options
  parsoid=html2wt
 -!! html
 +!! html/parsoid
  <h2>NEW</h2>
  <p>new</p>
 -<h2 data-parsoid='{"dsr":[0,5,2,2]}'>A</h2>
 -<p data-parsoid='{"dsr":[6,7,0,0]}'>a</p>
 +<h2 data-parsoid='{}'>A</h2>
 +<p data-parsoid='{}'>a</p>
  !! wikitext
  == NEW ==
  new
@@@ -22100,17 -21726,11 +22109,17 @@@ Lists: 0. Outside nest
  <nowiki>#</nowiki>foo
  
  <nowiki>;Foo:</nowiki>bar
 -!! html
 +!! 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>
  !!end
  
  !! test
@@@ -22237,7 -21857,7 +22246,7 @@@ Lists: 5. No unnecessary escape
  Lists: 6. Escape bullets in SOL position
  !! options
  parsoid=html2wt
 -!! html
 +!! html/parsoid
  <p><!--cmt-->*foo</p>
  !! wikitext
  <!--cmt--><nowiki>*</nowiki>foo
  Lists: 8. Escape colons only if not present in tags
  !! options
  parsoid=html2wt
 -!! html
 +!! html/parsoid
  <dl><dt>a:b<i>c:d</i></dt></dl>
  !! wikitext
  ; <nowiki>a:b</nowiki>''c:d''
@@@ -22634,7 -22254,7 +22643,7 @@@ parsoid=wt2htm
  T97430: Don't emit empty nowiki pairs around marker meta tags
  !! options
  parsoid=html2wt
 -!! html
 +!! html/parsoid
  <p>*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
@@@ -22950,7 -22570,7 +22959,7 @@@ parsoid=html2w
  <p>this is not a link: http://example.com
  </p>
  !! wikitext
 -this is not a link: <nowiki>http://example.com</nowiki>
 +<nowiki>this is not a link: http://example.com</nowiki>
  !! end
  
  !! test
@@@ -23200,7 -22820,7 +23209,7 @@@ parsoi
  5. Nowiki escaping should account for indent-pres
  !! options
  parsoid=html2wt
 -!! html
 +!! html/parsoid
  <pre>==foo==</pre>
  !! wikitext
   ==foo==
@@@ -23226,7 -22846,7 +23235,7 @@@ parsoi
  1. Valid behavior switches should be escaped
  !! options
  parsoid=html2wt
 -!! html
 +!! html/parsoid
  __TOC__
  <i>__TOC__</i>
  !! wikitext
  2. Invalid behavior switches should not be escaped
  !! options
  parsoid=html2wt
 -!! html
 +!! html/parsoid
  __TOO__
  __|__
  !! wikitext
@@@ -23781,9 -23401,9 +23790,9 @@@ Improperly nested inline or quotes tag
  !!test
  Encapsulate protected attributes from wt
  !! wikitext
 -<div typeof="mw:placeholder stuff" data-parsoid="weird" data-parsoid-other="no" about="time" rel="mw:true">foo</div>
 +<div typeof="mw:placeholder stuff" data-mw="whoo" data-parsoid="weird" data-parsoid-other="no" about="time" rel="mw:true">foo</div>
  !! html/parsoid
 -<body><div data-x-typeof="mw:placeholder stuff" data-x-data-parsoid="weird" data-x-data-parsoid-other="no" data-x-about="time" data-x-rel="mw:true">foo</div>
 +<body><div data-x-typeof="mw:placeholder stuff" data-x-data-mw="whoo" data-x-data-parsoid="weird" data-x-data-parsoid-other="no" data-x-about="time" data-x-rel="mw:true">foo</div>
  </body>
  !!end
  
@@@ -24073,7 -23693,7 +24082,7 @@@ Don't block XML namespace declaratio
  Serialize interwiki links pointing to the current wiki as plain wiki links (bug 65869)
  !! options
  parsoid=html2wt
 -!! html
 +!! html/parsoid
  <p><a rel="mw:ExtLink" href="http://mi.wikipedia.org/wiki/Foo">Foo</a></p>
  !! wikitext
  [[Foo]]
  New wikilinks should be serialized properly
  !! options
  parsoid=html2wt
 -!! html
 +!! html/parsoid
  <a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{}'>Foo</a>
  <a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a>
  !! wikitext
  New wiki links (href variations)
  !! options
  parsoid=html2wt
 -!! html
 +!! html/parsoid
  <a rel="mw:WikiLink" href="./Foo_bar">Foo_bar</a>
  <a rel="mw:WikiLink" href="Foo_bar">Foo_bar</a>
  <a rel="mw:WikiLink" href="Foo bar">Foo_bar</a>
  New wiki links (content string variations)
  !! options
  parsoid=html2wt
 -!! html
 +!! html/parsoid
  <a rel="mw:WikiLink" href="./Foo_bar">Foo_bar</a>
  <a rel="mw:WikiLink" href="./Foo_bar">Foo bar</a>
  <a rel="mw:WikiLink" href="./Foo_bar">./Foo_bar</a>
  New category links (href variations)
  !! options
  parsoid=html2wt
 -!! html
 +!! html/parsoid
  <link rel="mw:PageProp/Category" href="./Category:Toxine_bactérienne" />
  <link rel="mw:PageProp/Category" href="./Category:Toxine_bact%C3%A9rienne" />
  <link rel="mw:PageProp/Category" href="Category:Toxine_bact%C3%A9rienne" />
@@@ -24141,7 -23761,7 +24150,7 @@@ New sol transparent links don't need in
  !! options
  parsoid=html2wt
  language=de
 -!! html
 +!! html/parsoid
           <link rel="mw:PageProp/redirect" href="./Main_Page">
  <!-- this is good  -->    <link rel="mw:PageProp/Category" href="./Category:Good" />
  <!-- this is great -->    <link rel="mw:PageProp/Category" href="./Kategorie:Great" />
  New interlanguage links (href variations)
  !! options
  parsoid=html2wt
 -!! html
 +!! html/parsoid
  <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine bactérienne" />
  <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine_bactérienne" />
  <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine_bact%C3%A9rienne" />
@@@ -24302,17 -23922,16 +24311,17 @@@ parsoi
  <figure class="mw-default-size" typeof="mw:Image/Thumb" data-parsoid='{"optList":[{"ck":"thumbnail","ak":"thumb"},{"ck":"alt","ak":"alt="},{"ck":"caption","ak":"bar"}]}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"}}'><img alt="" 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":{"alt":"","resource":"./File:Foobar.jpg","height":"25","width":"220"},"sa":{"alt":"alt=","resource":"File:Foobar.jpg"}}'/></a><figcaption>bar</figcaption></figure>
  !! end
  
 -#!! test
 -#Image: new attributes should be serialized in wiki's language for RTL languages (bug 51852)
 -#!! options
 -#parsoid=html2wt
 -#language=ar
 -#!! html
 -#<figure class="mw-default-size mw-halign-right" typeof="mw:Image/Thumb"><a href="Imagen:Foobar.jpg"><img resource="./Imagen:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="20" width="180"/></a></figure>
 -#!! wikitext
 -#[[Imagen:Foobar.jpg|derecha|miniaturadeimagen]]
 -#!! end
 +!! test
 +Image: new attributes should be serialized in wiki's language for RTL languages (bug 51852)
 +!! options
 +parsoid=html2wt
 +language=ar
 +disabled
 +!! html/parsoid
 +<figure class="mw-default-size mw-halign-right" typeof="mw:Image/Thumb"><a href="./Imagen:Foobar.jpg"><img resource="./Imagen:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="20" width="180"/></a></figure>
 +!! wikitext
 +[[Imagen:Foobar.jpg|derecha|miniaturadeimagen]]
 +!! end
  
  !! test
  Image: Block level image should have \n before and after
@@@ -24404,7 -24023,7 +24413,7 @@@ parsoid=html2w
  Lists: Serialize correctly even when list content is wrapped in p-tags (like VE does)
  !! options
  parsoid=html2wt
 -!! html
 +!! html/parsoid
  <ul>
  <li><p>foo</p></li>
  </ul>
  Lists: Serialize correctly even when list tags has unneeded whitespace between tags
  !! options
  parsoid=html2wt
 -!! html
 +!! html/parsoid
  <ul> <li>foo</li></ul>
  !! wikitext
  * foo
  Don't strip leading whitespace when handling indent-pre suppressing tags
  !! options
  parsoid=html2wt
 -!! html
 +!! html/parsoid
  <table>
    <tr><td> indented row</td></tr>
  </table>
  Nowiki-wrap leading whitespace when handling indent-pre inducing tags
  !! options
  parsoid=html2wt
 -!! wikitext
 -foo
 -<nowiki> </nowiki><span>bar</span>
 +!! html/parsoid
 +<p>foo</p>
 + <span>bar</span>
  
  <span>foo2
 -<nowiki> </nowiki></span>bar2
 + </span>bar2
  
  <div>foo</div>
 -<nowiki> </nowiki><span>bar</span>
 + <span>bar</span>
  
  <div>
 -<nowiki> </nowiki><span>foo</span>
 + <span>foo</span>
  </div>
 -!! html
 -<p>foo</p>
 - <span>bar</span>
 +!! wikitext
 +foo
 +<nowiki> </nowiki><span>bar</span>
  
  <span>foo2
 - </span>bar2
 +<nowiki> </nowiki></span>bar2
  
  <div>foo</div>
 - <span>bar</span>
 +<nowiki> </nowiki><span>bar</span>
  
  <div>
 - <span>foo</span>
 +<nowiki> </nowiki><span>foo</span>
  </div>
  !! end
  
  Lists: Dont insert newlines in a serialized list item.
  !! options
  parsoid=html2wt
 -!! html
 +!! html/parsoid
  <ul><li>a<br>b</li><li>c</li></ul>
  !! wikitext
  * a<br>b
  !! end
  
  !! test
 -Headings: Force sol-transparent links and behavior switches to serialize before/after
 +1. Headings: Force sol-transparent links and behavior switches to serialize before/after
  !! options
 -parsoid=html2wt
 -!! html
 -<h2>hello there<link href="Category:A1" rel="mw:PageProp/Category" /></h2>
 -<h2><link href="Category:A2" rel="mw:PageProp/Category" />hi pal</h2>
 +parsoid={
 +  "modes": ["html2wt"],
 +  "scrubWikitext": false
 +}
 +!! html/parsoid
 +<h2>hello there<link href="./Category:A1" rel="mw:PageProp/Category" /></h2>
 +<h2><link href="./Category:A2" rel="mw:PageProp/Category" />hi pal</h2>
 +
 +<h2><!--foo-->  <link href="./Category:A3" rel="mw:PageProp/Category" />   how goes it</h2>
 +<h2>it goes well   <link href="./Category:A4" rel="mw:PageProp/Category" />  <!--bar--></h2>
 +
 +<h2 data-parsoid='{}'>howdy<link href="./Category:A5" rel="mw:PageProp/Category" /></h2>
 +
 +<h2><meta property="mw:PageProp/toc" /> ok</h2>
 +!! wikitext
 +== hello there [[Category:A1]]  ==
 +
 +==  [[Category:A2]] hi pal ==
 +
 +== <!--foo-->   [[Category:A3]]    how goes it ==
 +
 +== it goes well    [[Category:A4]]  <!--bar-->  ==
 +
 +==howdy [[Category:A5]] ==
 +
 +==  __TOC__  ok ==
 +!! end
  
 -<h2><!--foo-->  <link href="Category:A3" rel="mw:PageProp/Category" />   how goes it</h2>
 -<h2>it goes well   <link href="Category:A4" rel="mw:PageProp/Category" />  <!--bar--></h2>
 +!! test
 +2. Headings: Force sol-transparent links and behavior switches to serialize before/after
 +!! options
 +parsoid={
 +  "modes": ["html2wt"],
 +  "scrubWikitext": true
 +}
 +!! html/parsoid
 +<h2>hello there<link href="./Category:A1" rel="mw:PageProp/Category" /></h2>
 +<h2><link href="./Category:A2" rel="mw:PageProp/Category" />hi pal</h2>
  
 -<h2 data-parsoid='{}'>howdy<link href="Category:A5" rel="mw:PageProp/Category" /></h2>
 +<h2><!--foo-->  <link href="./Category:A3" rel="mw:PageProp/Category" />   how goes it</h2>
 +<h2>it goes well   <link href="./Category:A4" rel="mw:PageProp/Category" />  <!--bar--></h2>
  
  <h2><meta property="mw:PageProp/toc" /> ok</h2>
  !! wikitext
  == it goes well ==
  [[Category:A4]]  <!--bar-->
  
 -==howdy [[Category:A5]] ==
 -
  __TOC__
  
  == ok ==
  !! test
  Headings: Don't hoist metas that come from templates
  !! options
 -parsoid=html2wt
 -!! html
 +parsoid={
 +  "modes": ["html2wt"],
 +  "scrubWikitext": true
 +}
 +!! html/parsoid
  <h2><span about="#mwt1" typeof="mw:Transclusion" data-parsoid="{}" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo [[Category:Foo]]"}},"i":0}}]}'>foo </span><link rel="mw:PageProp/Category" href="./Category:Foo" about="#mwt1" data-parsoid="{}" /></h2>
  !! wikitext
  == {{echo|foo [[Category:Foo]]}} ==
  !! test
  Headings: Category in ref isn't hoisted
  !! options
 -parsoid=html2wt
 -!! html
 -<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>
 +parsoid={
 +  "modes": ["html2wt"],
 +  "scrubWikitext": true
 +}
 +!! html/parsoid
 +<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
  Parsoid: Serialize positional parameters with = in them as named parameter
  !! options
  parsoid=html2wt
 -!! html
 +!! html/parsoid
  <p about="#mwt1" typeof="mw:Transclusion"
  data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"f=oo"}},"i":0}}]}'>foo</p>
  
@@@ -24622,7 -24205,7 +24631,7 @@@ data-mw='{"parts":[{"template":{"target
  Parsoid: Serialize positional parameters with = in extlink as named parameter
  !! options
  parsoid=html2wt
 -!! html
 +!! html/parsoid
  <p><a rel="mw:ExtLink" href="http://stuff?is=ok" about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"http://stuff?is=ok"}},"i":0}}]}'>http://stuff?is=ok</a></p>
  !! wikitext
  {{echo|1 = http://stuff?is=ok}}
  Parsoid: Correctly serialize block-node children when they are a combination of text and p-nodes
  !! options
  parsoid=html2wt
 -!! html
 +!! html/parsoid
  <div>a<p>b</p></div>
  <div>a
  <p>b</p></div>
  Substrings resembling wikitext in hrefs should not get nowiki escapes
  !! options
  parsoid=html2wt
 -!! html
 +!! html/parsoid
  <a rel="mw:WikiLink" href="./Foo''bar''baz">Foo''bar''baz</a>
  !! wikitext
  [[Foo''bar''baz]]
  Enforce single-line context in the serializer
  !! options
  parsoid=html2wt
 -!! html
 +!! html/parsoid
  <h2>testing
  123</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>
  baz</li>
  <li>foo <b>bar</b>
  baz</li></ul>
 +
 +<dl><dt>hi
 +ho </dt><dd data-parsoid='{"stx":"row"}'> hi
 +ho</dd></dl>
 +
 +<dl><dd> <table>
 +<tbody><tr><td> ha
 +ha
 +ha</td></tr>
 +</tbody></table></dd></dl>
  !! wikitext
  == testing 123 ==
  
@@@ -24712,21 -24285,13 +24721,21 @@@ there</ref> =
  
  * foo bar baz
  * foo '''bar''' baz
 +
 +; hi ho : hi ho
 +
 +: {|
 +| ha
 +ha
 +ha
 +|}
  !! end
  
  !! test
  Serialize new placeholder space without spans
  !! options
  parsoid=html2wt
 -!! html
 +!! html/parsoid
  <p>foo<span typeof="mw:Placeholder"> </span>: bar</p>
  
  <p>foo<span typeof="mw:DisplaySpace mw:Placeholder" data-parsoid='{"src":" ","isDisplayHack":true}'> </span>: bar</p>
@@@ -24749,7 -24314,7 +24758,7 @@@ foo : ba
  1. I/B quote minimization: wikitext-only tags should be combined
  !! options
  parsoid=html2wt
 -!! html
 +!! html/parsoid
  <p><i>A</i><i>B</i></p>
  <p><b>A</b><b>B</b></p>
  <p><i>A</i><b><i>B</i></b></p>
  2. I/B quote minimization: wikitext and html tags should not be combined
  !! options
  parsoid=html2wt
 -!! html
 +!! html/parsoid
  <p><i>A</i><i data-parsoid='{"stx":"html"}'>B</i></p>
  <p><i>A</i><b><i data-parsoid='{"stx":"html"}'>B</i></b></p>
  !! wikitext
  3. I/B quote minimization: templated content stops minimization
  !! options
  parsoid=html2wt
 -!! html
 +!! html/parsoid
  <p><i>A</i><i about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&#39;&#39;B&#39;&#39;"}},"i":0}}]}'>B</i>
  <p><i>A</i><b about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&#39;&#39;&#39;&#39;&#39;B&#39;&#39;&#39;&#39;&#39;"}},"i":0}}]}'><i>B</i></b>
  !! wikitext
  4. I/B quote minimization: new content should be mimimized with adjacent old content
  !! options
  parsoid=html2wt
 -!! html
 +!! html/parsoid
  <p><i>A</i><i>B</i></p>
  <p><b>A</b><b>B</b></p>
  <p><i>A</i><b><i>B</i></b></p>
@@@ -24855,7 -24420,7 +24864,7 @@@ parsoid=
    "modes": ["html2wt"],
    "scrubWikitext": true
  }
 -!! html
 +!! html/parsoid
  <a rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
  <a data-parsoid="{}" rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
  <a data-parsoid="{}" rel="mw:WikiLink" href="./Football">Foot</a><a data-parsoid="{}" rel="mw:WikiLink" href="./Football">ball</a>
@@@ -24872,7 -24437,7 +24881,7 @@@ parsoid=
    "modes": ["html2wt"],
    "scrubWikitext": true
  }
 -!! html
 +!! html/parsoid
  <a rel="mw:WikiLink" href="./Football"><i>Foot</i></a><a rel="mw:WikiLink" href="./Football"><i>ball</i></a>
  !! wikitext
  [[Football|''Football'']]
@@@ -24885,7 -24450,7 +24894,7 @@@ parsoid=
    "modes": ["html2wt"],
    "scrubWikitext": false
  }
 -!! html
 +!! html/parsoid
  <a rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
  !! wikitext
  [[Football|Foot]][[Football|ball]]
  Bug 54262: New entities
  !! options
  parsoid=html2wt
 +!! html/parsoid
 +<span typeof="mw:Entity">&nbsp;</span>
  !! wikitext
  &nbsp;
 -!! html
 -<span typeof="mw:Entity">&nbsp;</span>
  !! end
  
  ## Note that there is no wikitext output for 'unknownproperty' ##
@@@ -24939,7 -24504,7 +24948,7 @@@ __NOCONTENTCONVERT_
  Consecutive <pre>s should not get merged
  !! options
  parsoid=html2wt,html2html
 -!! html
 +!! html/parsoid
  <pre>a</pre><pre>b</pre>
  
  <pre>c
@@@ -24971,7 -24536,7 +24980,7 @@@ f</pre
  Edited ISBN links not serializable as ISBN links should serialize as wikilinks
  !! options
  parsoid=html2wt
 -!! html
 +!! html/parsoid
  <a rel="mw:ExtLink" href="./Special:BookSources/1234567890">ISBN 1234567895</a>
  !! wikitext
  [[Special:BookSources/1234567890|ISBN 1234567895]]
  Edited RFC links not serializable as RFC links should serialize as extlinks
  !! options
  parsoid=html2wt
 -!! html
 +!! html/parsoid
  <a href="//tools.ietf.org/html/rfc123" rel="mw:ExtLink">New RFC</a>
  !! wikitext
  [//tools.ietf.org/html/rfc123 New RFC]
  Edited PMID links not serializable as PMID links should serialize as extlinks
  !! options
  parsoid=html2wt
 -!! html
 +!! html/parsoid
  <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink">New PMID</a>
  !! wikitext
  [//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract New PMID]
@@@ -25047,46 -24612,11 +25056,46 @@@ x<nowiki/>http://cscott.net<nowiki/>
  x<nowiki/>http://cscott.net<nowiki/>x
  !! end
  
 +!! test
 +WTS of edited autolink-like text (T103364)
 +!! options
 +parsoid={
 +  "modes": ["wt2wt"],
 +  "changes": [
 +    [ "span[typeof]", "removeAttr", "typeof" ]
 +  ]
 +}
 +!! wikitext
 +Not a link: <nowiki>http://example.com</nowiki>.
 +!! wikitext/edited
 +Not a link: <span><nowiki>http://example.com</nowiki></span>.
 +!! end
 +
 +!! test
 +WTS of newly-authored autolink-like text (T103364)
 +!! options
 +parsoid=html2wt
 +!! html/parsoid
 +<p>http://example.com is not a link.</p>
 +!! wikitext
 +<nowiki>http://example.com is not a link.</nowiki>
 +!! end
 +
 +!! test
 +WTS of autolink-like text after an autolink (T108563)
 +!! options
 +parsoid=html2wt
 +!! html/parsoid
 +<p><a rel="mw:ExtLink" href="http://example.com">http://example.com</a> http://example.com is not a link.</p>
 +!! wikitext
 +http://example.com<nowiki> http://example.com is not a link.</nowiki>
 +!! end
 +
  !! test
  Edited Redirect link should emit a non-piped wikitext link
  !! options
  parsoid=html2wt
 -!! html
 +!! html/parsoid
  <link rel="mw:PageProp/redirect" href="Bar" data-parsoid='{"a":{"href":"./Foo"},"sa":{"href":"Foo"}}'>
  !! wikitext
  #REDIRECT [[Bar]]
  T75121: Infer extension name from typeOf if data-mw is not present
  !! options
  parsoid=html2wt
 -!! html
 +!! html/parsoid
  <div typeOf="mw:Extension/foo"></div>
  !! wikitext
  <foo />
@@@ -25156,7 -24686,7 +25165,7 @@@ parsoid=html2wt,wt2w
  HTML id attribute with Parsoid-like element ids should not be serialized to wikitext
  !! options
  parsoid=html2wt
 -!! html
 +!! html/parsoid
  <table id='mwAb'>
  <td id='mwAc'>foo</td>
  <td id='serialize-this'>bar</td>
  Parsoid-like element ids should not be serialized to wikitext unless shadowed
  !! options
  parsoid=html2wt
 -!! html
 +!! html/parsoid
  <div id="mwAQ" data-parsoid='{"stx":"html","a":{"id":"mwAQ"},"sa":{"id":"hello"}}'>ok</div>
  !! wikitext
  <div id="hello">ok</div>
@@@ -25199,7 -24729,7 +25208,7 @@@ parsoid=
  Never serialize a-tag as html, regardless of what data-parsoid has to say
  !! options
  parsoid=html2wt
 -!! html
 +!! html/parsoid
  <a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{"stx":"html"}'>Foo</a>
  !! wikitext
  [[Foo]]
  Never serialize a-tag as html, no matter what attributes it has
  !! options
  parsoid=html2wt
 -!! html
 +!! html/parsoid
  <a bad='true' href='http://boo.org'><img src='http://boohoo.org' /></a>
  !! wikitext
  [http://boo.org http://boohoo.org]
  !! end
  
 +# Misnested is an indication that selser can reuse the source but these have
 +# shown to sneak through on occasion. See T101768.
 +# The original wikitext here is: [http://test.com [[one]] two three]
 +!! test
 +Strip span tags added to mark as misnested
 +!! options
 +parsoid=html2wt
 +!! html/parsoid
 +<p data-parsoid='{}'><a rel="mw:ExtLink" href="http://test.com" data-parsoid='{"targetOff":17,"contentOffsets":[17,34]}'></a><a rel="mw:WikiLink" href="./One" title="One" data-parsoid='{"stx":"simple","a":{"href":"./One"},"sa":{"href":"one"},"misnested":true}'>one</a><span data-parsoid='{"misnested":true}'> two three</span></p>
 +!! wikitext
 +[http://test.com][[one]] two three
 +!! end
 +
  # --------------------------------------------
  # Tests spec'ing wikitext serialization norms |
  # --------------------------------------------
  Lists: Add space after bullets
  !! options
  parsoid=html2wt
 -!! html
 +!! html/parsoid
  <ul>
  <li>foo</li>
  <li> bar</li>
  !! end
  
  !! test
 -Headings: Add space before/after == (T53744)
 +1. Headings: Add space before/after == (T53744)
  !! options
  parsoid=html2wt
 -!! html
 +!! html/parsoid
  <h2>foo</h2>
  <h2> bar</h2>
  <h2>baz </h2>
  <h2><span> baz</span></h2>
 -
 -<!-- Even after hoisted content -->
 -<h2> <link href="Category:A2" rel="mw:PageProp/Category" />ok</h2>
  !! wikitext
  == foo ==
  
  == baz ==
  
  == <span> baz</span> ==
 +!! end
  
 -<!-- Even after hoisted content -->
 +!! test
 +2. Headings: Add space before/after == even after hoisted content
 +!! options
 +parsoid={
 +  "modes": ["html2wt"],
 +  "scrubWikitext": true
 +}
 +!! html/parsoid
 +<h2> <link href="./Category:A2" rel="mw:PageProp/Category" />ok</h2>
 +!! wikitext
   [[Category:A2]]
  
  == ok ==
@@@ -25293,7 -24803,7 +25302,7 @@@ parsoid=
    "modes": ["html2wt"],
    "scrubWikitext": true
  }
 -!! html
 +!! html/parsoid
  <h2></h2>
  !! wikitext
  !! end
  2. Headings: don't suppress empty headings if scrubWikitext is false
  !! options
  parsoid=html2wt
 -!! html
 +!! html/parsoid
  <h2></h2>
  !! wikitext
  ==<nowiki/>==
  !! end
  
  !! test
 -3. Headings: don't suppress empty headings for existing headings even if scrubWikitext is true
 +3. Headings: suppress empty headings on edits
  !! options
  parsoid={
 -  "modes": ["html2wt"],
 -  "scrubWikitext": true
 +  "modes": ["selser"],
 +  "scrubWikitext": true,
 +  "changes": [
 +    [ "#x", "remove"]
 +  ]
  }
 -!! html
 -<h2 data-parsoid='{}'></h2>
  !! wikitext
 -==<nowiki/>==
 +==<span id="x">foo</span>==
 +!! wikitext/edited
  !! end
  
  !! test
@@@ -25330,7 -24838,7 +25339,7 @@@ parsoid=
    "modes": ["html2wt"],
    "scrubWikitext": true
  }
 -!! html
 +!! html/parsoid
  <i></i><b></b>
  !! wikitext
  !! end
  2. WT Quote Tags: don't suppress empty style tags if scrubWikitext is false
  !! options
  parsoid=html2wt
 -!! html
 +!! html/parsoid
  <i></i><b></b>
  !! wikitext
  ''<nowiki/>'''''<nowiki/>'''
  !! end
  
  !! test
 -1. Indent Pre Nowiki: suppress whitespace at the start of new paragraph
 +3. WT Quote Tags: suppress empty style tags on edits
 +!! options
 +parsoid={
 +  "modes": ["selser"],
 +  "scrubWikitext": true,
 +  "changes": [
 +    [ "#x", "remove"]
 +  ]
 +}
 +!! wikitext
 +'''<span id="x">foo</span>'''
 +!! wikitext/edited
 +!! end
 +
 +!! test
 +1. Anchors: suppress newly created empty anchors
 +!! options
 +parsoid={
 +  "modes": ["html2wt"],
 +  "scrubWikitext": true
 +}
 +!! html/parsoid
 +<a rel="mw:WikiLink" href="./Test" title="Test"></a>
 +!! wikitext
 +!! end
 +
 +!! test
 +2. Anchors: don't suppress empty anchors if scrubWikitext is false
 +!! options
 +parsoid={
 +  "modes": ["html2wt"],
 +  "scrubWikitext": false
 +}
 +!! html/parsoid
 +<a rel="mw:WikiLink" href="./Test" title="Test"></a>
 +!! wikitext
 +[[Test|<nowiki/>]]
 +!! end
 +
 +!! test
 +3. Anchors: suppress empty anchors on edits
 +!! options
 +parsoid={
 +  "modes": ["selser"],
 +  "scrubWikitext": true,
 +  "changes": [
 +    [ "#x", "remove"]
 +  ]
 +}
 +!! wikitext
 +[[Test|<span id="x">foo</span>]]
 +!! wikitext/edited
 +!! end
 +
 +!! test
 +3a. Anchors: do not suppress numbered extlinks
 +!! options
 +parsoid={
 +  "modes": ["wt2wt"],
 +  "scrubWikitext": true
 +}
 +!! wikitext
 +[http://foo.com]
 +!! html/parsoid
 +<a rel="mw:ExtLink" href="http://foo.com"></a>
 +!! end
 +
 +!! test
 +3b. Anchors: do not suppress numbered extlinks
 +!! options
 +parsoid={
 +  "modes": ["wt2wt"],
 +  "scrubWikitext": true,
 +  "changes": [
 +    [ "#x", "remove"]
 +  ]
 +}
 +!! wikitext
 +[http://foo.com <span id="x">foo</span>]
 +!! wikitext/edited
 +[http://foo.com]
 +!! end
 +
 +!!test
 +Normalizations should be restricted to edited content
 +!!options
 +parsoid={
 +  "modes": ["selser"],
 +  "scrubWikitext": true,
 +  "changes": [
 +    [ "h1", "before", "<i></i>"]
 +  ]
 +}
 +!!wikitext
 +a
 += =
 +b
 +!!wikitext/edited
 +a
 += =
 +b
 +!!end
 +
 +!! test
 +1. Multiple normalizations (html2wt)
  !! options
  parsoid={
    "modes": ["html2wt"],
    "scrubWikitext": true
  }
  !! html
 +<h2><i></i></h2>
 +<p><a href='Foo' rel='mw:WikiLink'>foo<i></i>
 + </a><b><i></i></b>x</p>
 +!! wikitext
 +
 +[[foo]]
 +x
 +
 +!! end
 +
 +!! test
 +2. Multiple normalizations (selser)
 +!! options
 +parsoid={
 +  "modes": ["selser"],
 +  "scrubWikitext": true,
 +  "changes": [
 +    [ "#x", "after", "<h1><i></i></h1>\n<p> x<b></b></p>"]
 +  ]
 +}
 +!! wikitext
 +<span id="x">foo</span>
 +!! wikitext/edited
 +<span id="x">foo</span>
 +
 +x
 +!! end
 +
 +!! test
 +1. Indent Pre Nowiki: suppress whitespace at the start of new paragraph
 +!! options
 +parsoid={
 +  "modes": ["html2wt"],
 +  "scrubWikitext": true
 +}
 +!! html/parsoid
  <p> hi</p>
 +<p>    hello</p>
  !! wikitext
  hi
 +
 +hello
  !! end
  
  !! test
  2. Indent Pre Nowiki: don't suppress whitespace at the start of new paragraph if scrubWikitext is false
  !! options
  parsoid=html2wt
 -!! html
 +!! html/parsoid
  <p> hi</p>
 +<p>    hello</p>
  !! wikitext
  <nowiki> </nowiki>hi
 +
 +<nowiki> </nowiki>   hello
 +!! end
 +
 +!! test
 +3. Indent Pre Nowiki: suppress whitespace after newlines in new paragraph or table cell
 +!! options
 +parsoid={
 +  "modes": ["html2wt"],
 +  "scrubWikitext": true
 +}
 +!! html/parsoid
 +<p>Foo
 + bar
 +baz</p>
 +
 +<table><tr><td>Foo
 + bar
 + baz bang</td></tr></table>
 +
 +<p><!--boo--> foo
 + bar</p>
 +
 +<p> foo
 + bar<span>boo</span></p>
 +!! wikitext
 +Foo
 +bar
 +baz
 +
 +{|
 +|Foo
 +bar
 +baz bang
 +|}
 +
 +<!--boo-->foo
 +bar
 +
 +foo
 +bar<span>boo</span>
 +!! end
 +
 +!! test
 +4. Indent Pre Nowiki: suppress leading whitespace in edited paragraphs
 +!! options
 +parsoid={
 +  "modes": ["selser"],
 +  "scrubWikitext": true,
 +  "changes": [
 +    [ "p", "html", " a\n b" ]
 +  ]
 +}
 +!! wikitext
 +xyz
 +!! wikitext/edited
 +a
 +b
 +!! end
 +
 +!! test
 +1. New links that end in spaces
 +!! options
 +parsoid={
 +  "modes": ["html2wt"],
 +  "scrubWikitext": false
 +}
 +!! html/parsoid
 +<p><a rel="mw:WikiLink" href="./Berlin" title="Berlin">Berlin </a>is the capital of Germany.</p>
 +<p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo </a><b>bar</b></p>
 +<p><a rel="mw:WikiLink" href="./Boston" title="Boston">Boston </a> is a city.</p>
 +!! wikitext
 +[[Berlin ]]<nowiki/>is the capital of Germany.
 +
 +[[Foo ]]'''bar'''
 +
 +[[Boston ]] is a city.
 +!! end
 +
 +!! test
 +2. New links that end in spaces
 +!! options
 +parsoid={
 +  "modes": ["html2wt"],
 +  "scrubWikitext": true
 +}
 +!! html/parsoid
 +<p><a rel="mw:WikiLink" href="./Berlin" title="Berlin">Berlin </a>is the capital of Germany.</p>
 +<p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo </a><b>bar</b></p>
 +<p><a rel="mw:WikiLink" href="./Boston" title="Boston">Boston </a> is a city.</p>
 +!! wikitext
 +[[Berlin]] is the capital of Germany.
 +
 +[[Foo]] '''bar'''
 +
 +[[Boston]] is a city.
 +!! end
 +
 +!! test
 +1. Table cells with escapable prefixes
 +!! options
 +parsoid={
 +  "modes": ["html2wt"],
 +  "scrubWikitext": false
 +}
 +!! html
 +<table>
 +<tr><td>a</td></tr>
 +<tr><td>-</td></tr>
 +<tr><td>+</td></tr>
 +</table>
 +!! wikitext
 +{|
 +|a
 +|-
 +|<nowiki>-</nowiki>
 +|-
 +|<nowiki>+</nowiki>
 +|}
 +!! end
 +
 +!! test
 +2. Table cells with escapable prefixes
 +!! options
 +parsoid={
 +  "modes": ["html2wt"],
 +  "scrubWikitext": true
 +}
 +!! html
 +<table>
 +<tr><td>a</td></tr>
 +<tr><td>-</td></tr>
 +<tr><td>+</td></tr>
 +</table>
 +!! wikitext
 +{|
 +|a
 +|-
 +| -
 +|-
 +| +
 +|}
 +!! end
 +
 +!! test
 +3a. Table cells with escapable prefixes after edits
 +!! options
 +parsoid={
 +  "modes": ["selser"],
 +  "scrubWikitext": true,
 +  "changes": [
 +    [ "table tbody tr:first-child td:first-child", "remove"]
 +  ]
 +}
 +!! wikitext
 +{|
 +|a||-
 +|}
 +!! wikitext/edited
 +{|
 +| -
 +|}
 +!! end
 +
 +!! test
 +3b. Table cells with escapable prefixes after edits
 +!! options
 +parsoid={
 +  "modes": ["selser"],
 +  "scrubWikitext": true,
 +  "changes": [
 +    [ "table tbody tr:first-child td:first-child", "html", "-" ],
 +    [ "#x", "remove" ]
 +  ]
 +}
 +!! wikitext
 +{|
 +|pqr
 +|<span id="x">foo</span>+
 +|}
 +!! wikitext/edited
 +{|
 +| -
 +| +
 +|}
 +!! end
 +
 +# FIXME: This test will fail because
 +# normalization doesn't realize that the id attribute
 +# will eliminate the escapable scenario
 +!! test
 +4a. Table cells without escapable prefixes after edits
 +!! options
 +parsoid={
 +  "modes": ["selser"],
 +  "scrubWikitext": true,
 +  "changes": [
 +    [ "#x", "html", "-" ]
 +  ]
 +}
 +!! wikitext
 +{|
 +| id="x" |abcd
 +|}
 +!! wikitext/edited
 +{|
 +| id="x" |-
 +|}
 +!! end
 +
 +## This tests normalizer's ability to discriminate between
 +## cells having identical content.
 +!! test
 +4b. Table cells without escapable prefixes after edits
 +!! options
 +parsoid={
 +  "modes": ["selser"],
 +  "scrubWikitext": true,
 +  "changes": [
 +    [ "td", "html", "-" ]
 +  ]
 +}
 +!! wikitext
 +{|
 +|a||b
 +|}
 +!! wikitext/edited
 +{|
 +| -||-
 +|}
 +!! end
 +
 +## This tests normalizer's ability to not be tripped by
 +## comments (and whitespace)
 +!! test
 +4c. Table cells without escapable prefixes after edits
 +!! options
 +parsoid={
 +  "modes": ["selser"],
 +  "scrubWikitext": true,
 +  "changes": [
 +    [ "table tbody tr td:first-child", "remove" ]
 +  ]
 +}
 +!! wikitext
 +{|
 +|-
 +<!--foo--> |a||-
 +|}
 +!! wikitext/edited
 +{|
 +|-
 +<!--foo--> | -
 +|}
 +!! end
 +
 +## This tests normalizer's ability to handle HTML cells
 +!! test
 +4d. Table cells without escapable prefixes after edits
 +!! options
 +parsoid={
 +  "modes": ["selser"],
 +  "scrubWikitext": true,
 +  "changes": [
 +    [ "td", "html", "-" ]
 +  ]
 +}
 +!! wikitext
 +<table>
 +<tr><td>a</td></tr>
 +</table>
 +!! wikitext/edited
 +<table>
 +<tr><td>-</td></tr>
 +</table>
  !! end
  
  # ---------------------------------------------------