Merge "Allow CategoryPageView to set $mCategoryViewerClass"
[lhc/web/wiklou.git] / tests / parser / parserTests.txt
index a94b276..8127695 100644 (file)
@@ -32,6 +32,7 @@
 # local         format section links in edit comment text as local links
 # notoc         disable table of contents
 # thumbsize=NNN set the default thumb size to NNNpx for this test
+# wrap          include the normal wrapper <div class="mw-parser-output"> (since 1.30)
 #
 # You can also set the following parser properties via test options:
 #  wgEnableUploads, wgAllowExternalImages, wgMaxTocLevel,
@@ -609,7 +610,7 @@ Italics and bold
 
 !! end
 
-# this example taken from the [[simple:Moon]] article (bug 47326)
+# this example taken from the [[simple:Moon]] article (T49326)
 !! test
 Italics and possessives (1)
 !! wikitext
@@ -619,7 +620,7 @@ obtained by ''[[Lunar Prospector]]'''s gamma-ray spectrometer
 </p>
 !! end
 
-# this example taken from [[en:Flaming Pie]] (bug 49926)
+# this example taken from [[en:Flaming Pie]] (T51926)
 !! test
 Italics and possessives (2)
 !! wikitext
@@ -629,7 +630,7 @@ Italics and possessives (2)
 </p>
 !! end
 
-# this example taken from [[en:Dictionary]] (bug 49926)
+# this example taken from [[en:Dictionary]] (T51926)
 !! test
 Italics and possessives (3)
 !! wikitext
@@ -1178,7 +1179,7 @@ Non-html5 tags should be accepted
 !! end
 
 !! test
-<wbr> is valid wikitext (bug 52468)
+<wbr> is valid wikitext (T54468)
 !! wikitext
 <wbr>
 !! html
@@ -1293,7 +1294,7 @@ Ruby markup (W3C-style)
 
 # The next two test different paths in the sanitizer.
 !! test
-Non-word characters don't terminate tag names (bug 17663, 40670, 52022)
+Non-word characters don't terminate tag names (T19663, T42670, T54022)
 !! wikitext
 <blockquote|>a</blockquote>
 
@@ -1364,7 +1365,7 @@ array (
 !! end
 
 !! test
-Isolated close tags should be treated as literal text (bug 52760)
+Isolated close tags should be treated as literal text (T54760)
 !! options
 parsoid=wt2html
 !! wikitext
@@ -1382,7 +1383,7 @@ parsoid=wt2html
 ###
 
 !! test
-Bare pipe character (bug 52363)
+Bare pipe character (T54363)
 !! wikitext
 |
 !! html
@@ -1391,7 +1392,7 @@ Bare pipe character (bug 52363)
 !! end
 
 !! test
-Bare pipe character from a template (bug 52363)
+Bare pipe character from a template (T54363)
 !! wikitext
 {{pipe}}
 !! html
@@ -1488,9 +1489,11 @@ nowiki 3
 Entities inside <nowiki>
 !! wikitext
 <nowiki>&lt;</nowiki>
-!! html
+!! html/php
 <p>&lt;
 </p>
+!! html/parsoid
+<p><span typeof="mw:Nowiki"><span typeof="mw:Entity" data-parsoid='{"src":"&amp;lt;","srcContent":"&lt;"}'>&lt;</span></span></p>
 !! end
 
 !! test
@@ -2162,7 +2165,7 @@ Regression with preformatted in <center>
 !! end
 
 !! test
-Bug 52763: Preformatted in <blockquote>
+T54763: Preformatted in <blockquote>
 !! wikitext
 <blockquote>
  Blah
@@ -2186,7 +2189,7 @@ Bug 52763: Preformatted in <blockquote>
 !! end
 
 !! test
-Bug 51086: Double newlines in blockquotes should be turned into paragraphs
+T53086: Double newlines in blockquotes should be turned into paragraphs
 !! wikitext
 <blockquote>
 Foo
@@ -2203,7 +2206,7 @@ Bar
 !! end
 
 !! test
-Bug 15491: <ins>/<del> in blockquote
+T17491: <ins>/<del> in blockquote
 !! wikitext
 <blockquote>
 Foo <del>bar</del> <ins>baz</ins> quux
@@ -2218,9 +2221,9 @@ Foo <del>bar</del> <ins>baz</ins> quux
 
 # Note that the p-wrapping is newline sensitive, which could be
 # considered a bug: tidy will wrap only the 'Foo' in the example
-# below in a <p> tag. (see comment 23-25 of bug #6200)
+# below in a <p> tag. (see comment 23-25 of T8200)
 !! test
-Bug 15491: <ins>/<del> in blockquote (2)
+T17491: <ins>/<del> in blockquote (2)
 !! wikitext
 <blockquote>Foo <del>bar</del> <ins>baz</ins> quux
 </blockquote>
@@ -2235,7 +2238,7 @@ Bug 15491: <ins>/<del> in blockquote (2)
 !! end
 
 !! test
-<pre> with attributes (bug 3202)
+<pre> with attributes (T5202)
 !! wikitext
 <pre style="background: blue; color:white">Bluescreen of WikiDeath</pre>
 !! html
@@ -2244,7 +2247,7 @@ Bug 15491: <ins>/<del> in blockquote (2)
 !! end
 
 !! test
-<pre> with width attribute (bug 3202)
+<pre> with width attribute (T5202)
 !! wikitext
 <pre width="8">Narrow screen goodies</pre>
 !! html
@@ -2253,7 +2256,7 @@ Bug 15491: <ins>/<del> in blockquote (2)
 !! end
 
 !! test
-<pre> with forbidden attribute (bug 3202)
+<pre> with forbidden attribute (T5202)
 !! wikitext
 <pre width="8" onmouseover="alert(document.cookie)">Narrow screen goodies</pre>
 !! html
@@ -2271,7 +2274,7 @@ Entities inside <pre>
 !! end
 
 !! test
-<pre> with forbidden attribute values (bug 3202)
+<pre> with forbidden attribute values (T5202)
 !! wikitext
 <pre width="8" style="border-width: expression(alert(document.cookie))">Narrow screen goodies</pre>
 !! html
@@ -2280,7 +2283,7 @@ Entities inside <pre>
 !! end
 
 !! test
-<nowiki> inside <pre> (bug 13238)
+<nowiki> inside <pre> (T15238)
 !! wikitext
 <pre>
 <nowiki>
@@ -2308,11 +2311,15 @@ Entities inside <pre>
 <pre>Foo &#8594;bar</pre>
 
 !! html/parsoid
-<pre about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"#tag:pre","function":"#tag"},"params":{"1":{"wt":"Foo &lt;nowiki>&amp;rarr;bar&lt;/nowiki>"}},"i":0}}]}'>Foo <span typeof="mw:Entity">→</span>bar</pre>
+<pre about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"#tag:pre","function":"tag"},"params":{"1":{"wt":"Foo &lt;nowiki>&amp;rarr;bar&lt;/nowiki>"}},"i":0}}]}'>Foo <span typeof="mw:Entity">→</span>bar</pre>
 !! end
 
+## Don't expect this to rt, Parsoid drops the unmatched closing pre tags that
+## aren't enclosed in nowikis.
 !! test
 <nowiki> and <pre> preference (first one wins)
+!! options
+parsoid=wt2html
 !! wikitext
 <pre>
 <nowiki>
@@ -2341,17 +2348,16 @@ Entities inside <pre>
 &lt;/pre&gt;
 </p>
 !! html/parsoid
-<pre data-parsoid='{"stx":"html","strippedNL":true}'>&lt;nowiki>
+<pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n&lt;nowiki>\n"}}'>&lt;nowiki>
 </pre>
-<p><span typeof="mw:Placeholder" data-parsoid='{"src":"&lt;/nowiki>"}'>&lt;/nowiki></span>
-&lt;/pre></p>
+<p>&lt;/nowiki></p>
+
 
 <p><span typeof="mw:Nowiki">
 &lt;pre>
 &lt;nowiki>
 &lt;/pre>
-</span>
-&lt;/pre></p>
+</span></p>
 !! end
 
 !! test
@@ -2365,9 +2371,7 @@ Entities inside <pre>
 
 # Parsoid doesn't strip empty tags, like Tidy does.
 !! test
-Empty pre; pre inside other HTML tags (bug 54946)
-!! options
-parsoid=wt2html,wt2wt
+Empty pre; pre inside other HTML tags (T56946)
 !! wikitext
 a
 
@@ -2392,9 +2396,9 @@ foo
 !! html/parsoid
 <p>a</p>
 
-<div><pre>foo
+<div data-parsoid='{"stx":"html"}'><pre typeof="mw:Extension/pre" about="#mwt2" data-parsoid='{"stx":"html"}' data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\nfoo\n"}}'>foo
 </pre></div>
-<pre></pre>
+<pre typeof="mw:Extension/pre" about="#mwt4" data-parsoid='{"stx":"html"}' data-mw='{"name":"pre","attrs":{},"body":{"extsrc":""}}'></pre>
 !! end
 
 !! test
@@ -2410,7 +2414,7 @@ HTML pre followed by indent-pre
 
 # Note that tidy removes the empty <p> tags from the start and end.
 # Parsoid does not, by design.
-!!test
+!! test
 Block tag pre
 !! wikitext
 <p><pre>foo</pre></p>
@@ -2419,8 +2423,8 @@ Block tag 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
+<p data-parsoid='{"stx":"html","autoInsertedEnd":true}'></p><pre typeof="mw:Extension/pre" about="#mwt2" data-parsoid='{"stx":"html"}' data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo"}}'>foo</pre><p data-parsoid='{"autoInsertedStart":true,"stx":"html"}'></p>
+!! end
 
 !!test
 Templates: Indent-Pre: 1a. Templates that break a line should suppress <pre>
@@ -2541,8 +2545,11 @@ Templates: Indent-Pre: 1f: Wrapping should be based on expanded content
 </pre>
 !!end
 
+## Hmm, should Parsoid rt this?
 !! test
 Pres with newline attributes
+!! options
+parsoid=wt2html,html2html
 !! wikitext
 <pre class="one
 two">hi</pre>
@@ -2550,8 +2557,7 @@ two">hi</pre>
 <pre class="one two">hi</pre>
 
 !! html/parsoid
-<pre class="one
-two" data-parsoid='{"stx":"html"}'>hi</pre>
+<pre typeof="mw:Extension/pre" about="#mwt2" class="one two" data-mw='{"name":"pre","attrs":{"class":"one two"},"body":{"extsrc":"hi"}}'>hi</pre>
 !! end
 
 !! test
@@ -2566,7 +2572,7 @@ Barack Obama <President> of the United States
 !! end
 
 !! test
-Handle broken pre-like tags (bug 64025)
+Handle broken pre-like tags (T66025)
 !! options
 parsoid=wt2html
 !! wikitext
@@ -2583,7 +2589,7 @@ x
 </pre>
 <p>&lt;pre</p>
 !! html/parsoid
-<pre about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"a":{"&lt;pre":null},"sa":{"&lt;pre":""},"stx":"html","pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;pre &lt;pre>x&lt;/pre>"}},"i":0}}]}'>x</pre>
+<pre about="#mwt1" typeof="mw:Transclusion mw:Extension/pre" data-parsoid='{"a":{"&lt;pre":null},"sa":{"&lt;pre":""},"stx":"html","pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;pre &lt;pre>x&lt;/pre>"}},"i":0}}]}'>x</pre>
 
 
 <p>&lt;pre </p>
@@ -2601,7 +2607,7 @@ parsoid=wt2html
 <pre style="width:50%;">{{echo|foo}}</pre>
 
 !! html/parsoid
-<pre style="width:50%;">{{echo|foo}}</pre>
+<pre typeof="mw:Extension/pre" about="#mwt2" style="width:50%;" data-mw='{"name":"pre","attrs":{"style":"width:50%;"},"body":{"extsrc":"{{echo|foo}}"}}'>{{echo|foo}}</pre>
 !! end
 
 # TODO / maybe: fix wt2wt for this
@@ -2730,6 +2736,39 @@ Templates: Don't strip whitespace from positional-param values
 </pre>
 !! end
 
+!! test
+Templates: Don't recognize targets split by newlines
+!! options
+parsoid=wt2html
+!! wikitext
+{{ech
+o|foo}}
+!! html/php
+<p>{{ech
+o|foo}}
+</p>
+!! html/parsoid
+<p>{{ech
+o|foo}}</p>
+!! end
+
+!! test
+Templates: Recognize targets when newlines and comments don't split the target
+!! options
+parsoid=wt2html
+!! wikitext
+{{  
+ <!--X--> ech<!--X-->o<!--X-->  
+   <!--X-->   <!--X-->
+
+ |foo}}
+!! html/php
+<p>foo
+</p>
+!! html/parsoid
+<p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"ech&lt;!--X-->o&lt;!--X-->  \n   &lt;!--X-->   &lt;!--X-->\n\n ","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</p>
+!! end
+
 !! test
 Templates: Handle empty comment-and-ws-only lines correctly
 !! wikitext
@@ -2782,7 +2821,7 @@ Templates: Handle comments in the target
 !!end
 
 !! test
-Templates: Handle comments in parameter names (bug 67657)
+Templates: Handle comments in parameter names (T69657)
 !! wikitext
 {{echo|1
 <!-- should be ignored -->
@@ -2812,7 +2851,7 @@ Templates: Handle comments in parameter names (bug 67657)
 !!end
 
 !! test
-Templates: Other wikitext in parameter names (bug 67657)
+Templates: Other wikitext in parameter names (T69657)
 !! wikitext
 {{echo|''1''=foo}}
 !! html/php
@@ -2900,7 +2939,7 @@ parsoid=html2wt,wt2wt
 </p>
 !! end
 
-## Bug 52824
+## T54824
 !! test
 Templates: '=' char in nested transclusions should not trigger nowiki escapes or conversion to named param
 !! options
@@ -2913,7 +2952,7 @@ parsoid=html2wt,wt2wt
 <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
+## T58733
 !! test
 Templates parameters with special tokenizing behavior dont get modified because of arg escaping
 !! wikitext
@@ -2924,7 +2963,7 @@ Templates parameters with special tokenizing behavior dont get modified because
 <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
 
-## Bug T73412
+## T73412
 !! test
 Templates: Preserve blank parameter names
 !! wikitext
@@ -3041,7 +3080,7 @@ c
 !!end
 
 !!test
-2c. Indent-Pre and tables (bug 42252)
+2c. Indent-Pre and tables (T44252)
 !! wikitext
 {|
  |+ foo
@@ -3112,7 +3151,7 @@ a
 !!end
 
 !! test
-2g. Indented table markup mixed with indented pre content (proposed in bug 6200)
+2g. Indented table markup mixed with indented pre content (proposed in T8200)
 !! wikitext
  <table>
  <tr>
@@ -3266,6 +3305,17 @@ array (
  a <pre typeof="mw:Extension/tag" about="#mwt2" data-parsoid='{}' data-mw='{"name":"tag","attrs":{},"body":null}'></pre>
 !! end
 
+!! test
+5. Indent-Pre and html pre
+!! wikitext
+ <pre class="123">hi</pre>
+!! html/php
+ <pre class="123">hi</pre>
+
+!! html/parsoid
+ <pre typeof="mw:Extension/pre" about="#mwt2" class="123" data-mw='{"name":"pre","attrs":{"class":"123"},"body":{"extsrc":"hi"}}'>hi</pre>
+!! end
+
 !!test
 Render paragraphs when indent-pre is suppressed in blocklevels
 !! wikitext
@@ -3455,18 +3505,17 @@ foo
 foo
 </pre>
 !! html/parsoid
-<pre data-parsoid='{"stx":"html"}'>foo</pre>
+<pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo"}}'>foo</pre>
 
-<pre data-parsoid='{"stx":"html","strippedNL":"\n"}'>
-foo
+<pre typeof="mw:Extension/pre" about="#mwt4" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\nfoo\n"}}'>foo
 </pre>
 
-<pre data-parsoid='{"stx":"html"}'>
+<pre typeof="mw:Extension/pre" about="#mwt6" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n\nfoo\n"}}'>
 
 foo
 </pre>
 
-<pre data-parsoid='{"stx":"html"}'>
+<pre typeof="mw:Extension/pre" about="#mwt8" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n\n\nfoo\n"}}'>
 
 
 foo
@@ -3510,7 +3559,7 @@ haha
 
 </pre>
 !! html/parsoid
-<pre data-parsoid='{"stx":"html"}'>
+<pre typeof="mw:Extension/pre" about="#mwt2" data-parsoid='{"stx":"html"}' data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n\n\n\n\nhaha\n\n\n\n\nhaha\n\n\n\n\n"}}'>
 
 
 
@@ -3561,7 +3610,7 @@ HTML-pre: 3: other wikitext
 </pre>
 
 !! html/parsoid
-<pre data-parsoid='{"stx":"html","strippedNL":true}'>* foo
+<pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n* foo\n# bar\n= no-h =\n&#39;&#39; no-italic &#39;&#39;\n[[ NoLink ]]\n"}}'>* foo
 # bar
 = no-h =
 '' no-italic ''
@@ -3683,7 +3732,33 @@ Definition lists: self-closed tag
 !! end
 
 !! test
-Bug 11748: Literal closing tags
+Definition lists: ignore colons inside tags
+!! wikitext
+;one <b>two : tag <i>fun:</i>:</b>: def
+!! html
+<dl><dt>one <b>two&#160;: tag <i>fun:</i>:</b></dt>
+<dd> def</dd></dl>
+
+!! end
+
+!! test
+Definition lists: excess closed tags
+!! wikitext
+;one</b>two : bad tag fun
+!! html/php+tidy
+<dl>
+<dt>onetwo&#160;</dt>
+<dd>bad tag fun</dd>
+</dl>
+!! html/parsoid
+<dl>
+<dt>onetwo</dt>
+<dd>bad tag fun</dd>
+</dl>
+!! end
+
+!! test
+T13748: Literal closing tags
 !! wikitext
 <dl>
 <dt>test 1</dt>
@@ -3810,7 +3885,7 @@ should be left alone
 !! end
 
 !! test
-Definition Lists: Hacky use to indent tables, with comments (bug 63979)
+Definition Lists: Hacky use to indent tables, with comments (T65979)
 !! wikitext
 <!-- foo -->
 ::{|
@@ -4516,7 +4591,7 @@ Non-bracketed: http://example.com
 </p>
 !! end
 
-# parsoid doesn't explicitly mark autonumbered links, see bug 53505
+# parsoid doesn't explicitly mark autonumbered links, see T55505
 !! test
 External links: numbered
 !! wikitext
@@ -4561,7 +4636,7 @@ http://example.com/1$2345
 </p>
 !! end
 
-# parsoid doesn't explicitly mark autonumbered links, see bug 53505
+# parsoid doesn't explicitly mark autonumbered links, see T55505
 !! test
 External links: dollar sign in URL (autonumber)
 !! wikitext
@@ -4574,7 +4649,7 @@ External links: dollar sign in URL (autonumber)
 !!end
 
 !! test
-External links: open square bracket forbidden in URL (bug 4377)
+External links: open square bracket forbidden in URL (T6377)
 !! options
 parsoid=wt2html,wt2wt,html2html
 !! wikitext
@@ -4587,7 +4662,7 @@ http://example.com/1[2345
 !! end
 
 !! test
-External links: open square bracket forbidden in URL (named) (bug 4377)
+External links: open square bracket forbidden in URL (named) (T6377)
 !! options
 parsoid=wt2html,html2html
 !! wikitext
@@ -4601,7 +4676,7 @@ parsoid=wt2html,html2html
 
 # parsoid adds a space before the link name
 !! test
-External links: open square bracket forbidden in URL (named) (bug 4377)
+External links: open square bracket forbidden in URL (named) (T6377)
 Parsoid variant.
 !! wikitext
 [http://example.com/1 [2345]
@@ -4611,7 +4686,7 @@ Parsoid variant.
 !!end
 
 !! test
-External links: nowiki in URL link text (bug 6230)
+External links: nowiki in URL link text (T8230)
 !! wikitext
 [http://example.com/ <nowiki>''example site''</nowiki>]
 !! html
@@ -4620,7 +4695,7 @@ External links: nowiki in URL link text (bug 6230)
 !! end
 
 !! test
-External links: newline forbidden in text (bug 6230 regression check)
+External links: newline forbidden in text (T8230 regression check)
 !! wikitext
 [http://example.com/ first
 second]
@@ -4648,7 +4723,7 @@ External links: protocol-relative URL in brackets
 </p>
 !! end
 
-# parsoid doesn't explicitly mark autonumbered links, see bug 53505
+# parsoid doesn't explicitly mark autonumbered links, see T55505
 !! test
 External links: protocol-relative URL in brackets without text
 !! wikitext
@@ -4670,7 +4745,7 @@ External links: protocol-relative URL in free text is left alone
 !!end
 
 !! test
-External links: protocol-relative URL in the middle of a word is left alone (bug 30269)
+External links: protocol-relative URL in the middle of a word is left alone (T32269)
 !! wikitext
 foo//example.com/Foo
 !! html
@@ -4821,7 +4896,7 @@ bitcoin:;
 !! end
 
 !! test
-External links: No preceding word characters allowed (bug 65278)
+External links: No preceding word characters allowed (T67278)
 !! wikitext
 NOPEhttp://example.com
 N0http://example.com
@@ -4966,7 +5041,7 @@ Old &amp; use: http://x&amp;y
 !! end
 
 !! test
-External links: encoded equals (bug 6102)
+External links: encoded equals (T8102)
 !! wikitext
 http://example.com/?foo&#61;bar
 !! html/php
@@ -4978,7 +5053,7 @@ http://example.com/?foo&#61;bar
 
 ##
 ## Note that parsoid doesn't explicit mark autonumbered links, nor
-## does it number them.  As discussed in bug 53505, we can identify
+## does it number them.  As discussed in T55505, we can identify
 ## autonumbered links via CSS.
 ##
 
@@ -5022,7 +5097,7 @@ External links: [raw equals]
 # note that parsoid html is identical to [raw equals] case; so html2wt
 # mode will return the [raw equals] wikitext
 !! test
-External links: [encoded equals] (bug 6102)
+External links: [encoded equals] (T8102)
 !! options
 parsoid=wt2html,wt2wt,html2html
 !! wikitext
@@ -5082,7 +5157,7 @@ http://e&zwnj;xample.com/
 !! end
 
 !! test
-External links: www.jpeg.org (bug 554)
+External links: www.jpeg.org (T2554)
 !! wikitext
 http://www.jpeg.org
 !! html
@@ -5090,9 +5165,9 @@ http://www.jpeg.org
 </p>
 !! end
 
-# parsoid doesn't explicitly mark autonumbered links, see bug 53505
+# parsoid doesn't explicitly mark autonumbered links, see T55505
 !! test
-External links: URL within URL (original bug 2)
+External links: URL within URL (T2002)
 !! wikitext
 [http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp]
 !! html/php
@@ -5103,7 +5178,7 @@ External links: URL within URL (original bug 2)
 !! end
 
 !! test
-BUG 361: URL inside bracketed URL
+T2361: URL inside bracketed URL
 !! wikitext
 [http://www.example.com/foo http://www.example.com/bar]
 !! html
@@ -5112,7 +5187,7 @@ BUG 361: URL inside bracketed URL
 !! end
 
 !! test
-BUG 361: URL within URL, not bracketed
+T2361: URL within URL, not bracketed
 !! wikitext
 http://www.example.com/foo?=http://www.example.com/bar
 !! html
@@ -5121,7 +5196,7 @@ http://www.example.com/foo?=http://www.example.com/bar
 !! end
 
 !! test
-BUG 289: ">"-token in URL-tail
+T2289: ">"-token in URL-tail
 !! wikitext
 http://www.example.com/<hello>
 !! html
@@ -5130,7 +5205,7 @@ http://www.example.com/<hello>
 !!end
 
 !! test
-BUG 289: literal ">"-token in URL-tail
+T2289: literal ">"-token in URL-tail
 !! wikitext
 http://www.example.com/<b>html</b>
 !! html/php
@@ -5141,7 +5216,7 @@ http://www.example.com/<b>html</b>
 !! end
 
 !! test
-BUG 289: ">"-token in bracketed URL
+T2289: ">"-token in bracketed URL
 !! wikitext
 [http://www.example.com/<hello> stuff]
 !! html
@@ -5150,7 +5225,7 @@ BUG 289: ">"-token in bracketed URL
 !!end
 
 !! test
-BUG 289: literal ">"-token in bracketed URL
+T2289: literal ">"-token in bracketed URL
 !! wikitext
 [http://www.example.com/<b>html</b> stuff]
 !! html
@@ -5159,7 +5234,7 @@ BUG 289: literal ">"-token in bracketed URL
 !!end
 
 !! test
-BUG 289: literal double quote at end of URL
+T2289: literal double quote at end of URL
 !! wikitext
 http://www.example.com/"hello"
 !! html
@@ -5168,7 +5243,7 @@ http://www.example.com/"hello"
 !!end
 
 !! test
-BUG 289: literal double quote in bracketed URL
+T2289: literal double quote in bracketed URL
 !! wikitext
 [http://www.example.com/"hello" stuff]
 !! html
@@ -5177,7 +5252,7 @@ BUG 289: literal double quote in bracketed URL
 !!end
 
 !! test
-External links: multiple legal whitespace is fine, Magnus. Don't break it please. (bug 5081)
+External links: multiple legal whitespace is fine, Magnus. Don't break it please. (T7081)
 !! wikitext
 [http://www.example.com  test]
 !! html
@@ -5197,7 +5272,7 @@ External links: link text with spaces
 !! end
 
 !! test
-External links: wiki links within external link (Bug 3695)
+External links: wiki links within external link (T5695)
 !! options
 parsoid=wt2html,html2html
 !! wikitext
@@ -5210,7 +5285,7 @@ parsoid=wt2html,html2html
 !! end
 
 !! test
-BUG 787: Links with one slash after the url protocol are invalid
+T2787: Links with one slash after the url protocol are invalid
 !! wikitext
 http:/example.com
 
@@ -5230,8 +5305,66 @@ Bracketed external links with template-generated invalid target
 </p>
 !! end
 
+# wt2html only because Parsoid would want to add <nowiki>s coming from html
 !! test
-Bug 2702: Mismatched <i>, <b> and <a> tags are invalid
+Broken wikilinks (but not external links) prevent templates from closing
+!! options
+parsoid=wt2html
+!! wikitext
+[http://example.com x
+
+{{echo|[http://example.com x}}
+
+[[Foo
+
+{{echo|[[Foo}}
+!! html/php
+<p>[<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> x
+</p><p>[<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> x
+</p><p>[[Foo
+</p><p>{{echo|[[Foo}}
+</p>
+!! html/parsoid
+<p>[<a rel="mw:ExtLink" href="http://example.com">http://example.com</a> x</p>
+<p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[http://example.com x"}},"i":0}}]}'>[<a rel="mw:ExtLink" href="http://example.com">http://example.com</a> x</p>
+<p>[[Foo</p>
+<p>{{echo|[[Foo}}</p>
+!! end
+
+!! test
+Wikilinks with embedded newlines are not broken
+!! wikitext
+{{echo|[[ Foo
+B
+C]]}}
+!! html/php
+<p>[[ Foo
+B
+C]]
+</p>
+!! html/parsoid
+<p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[[ Foo\nB\nC]]"}},"i":0}}]}'>[[ Foo B C]]</p>
+!! end
+
+!! test
+Broken templates
+!! options
+parsoid=wt2html
+!! wikitext
+{{echo|[[Foo|}}]]
+
+[[Foo|{{echo|]]}}
+!! html/php
+<p>{{echo|<a href="/wiki/Foo" title="Foo">}}</a>
+</p><p>[[Foo|]]
+</p>
+!! html/parsoid
+<p>{{echo|<a rel="mw:WikiLink" href="./Foo" title="Foo">}}</a></p>
+<p>[[Foo|<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"]]"}},"i":0}}]}'>]]</span></p>
+!! end
+
+!! test
+T4702: Mismatched <i>, <b> and <a> tags are invalid
 !! wikitext
 ''[http://example.com text'']
 [http://example.com '''text]'''
@@ -5249,7 +5382,7 @@ Bug 2702: Mismatched <i>, <b> and <a> tags are invalid
 
 
 !! test
-Bug 4781: %26 in URL
+T6781: %26 in URL
 !! wikitext
 http://www.example.com/?title=AT%26T
 !! html/php
@@ -5262,7 +5395,7 @@ http://www.example.com/?title=AT%26T
 # According to https://www.w3.org/TR/2011/WD-html5-20110525/Overview.html#parsing-urls a plain
 # % is actually legal in HTML5. Any change in output would need testing though.
 !! test
-Bug 4781, 5267: %25 in URL
+T6781, T7267: %25 in URL
 !! wikitext
 http://www.example.com/?title=100%25_Bran
 !! html/php
@@ -5273,7 +5406,7 @@ http://www.example.com/?title=100%25_Bran
 !! end
 
 !! test
-Bug 4781, 5267: %28, %29 in URL
+T6781, T7267: %28, %29 in URL
 !! wikitext
 http://www.example.com/?title=Ben-Hur_%281959_film%29
 !! html/php
@@ -5285,7 +5418,7 @@ http://www.example.com/?title=Ben-Hur_%281959_film%29
 
 
 !! test
-Bug 4781: %26 in autonumber URL
+T6781: %26 in autonumber URL
 !! wikitext
 [http://www.example.com/?title=AT%26T]
 !! html/php
@@ -5296,7 +5429,7 @@ Bug 4781: %26 in autonumber URL
 !! end
 
 !! test
-Bug 4781, 5267: %26 in autonumber URL
+T6781, T7267: %26 in autonumber URL
 !! wikitext
 [http://www.example.com/?title=100%25_Bran]
 !! html/php
@@ -5307,7 +5440,7 @@ Bug 4781, 5267: %26 in autonumber URL
 !! end
 
 !! test
-Bug 4781, 5267: %28, %29 in autonumber URL
+T6781, T7267: %28, %29 in autonumber URL
 !! wikitext
 [http://www.example.com/?title=Ben-Hur_%281959_film%29]
 !! html/php
@@ -5319,7 +5452,7 @@ Bug 4781, 5267: %28, %29 in autonumber URL
 
 
 !! test
-Bug 4781: %26 in bracketed URL
+T6781: %26 in bracketed URL
 !! wikitext
 [http://www.example.com/?title=AT%26T link]
 !! html/php
@@ -5330,7 +5463,7 @@ Bug 4781: %26 in bracketed URL
 !! end
 
 !! test
-Bug 4781, 5267: %25 in bracketed URL
+T6781, T7267: %25 in bracketed URL
 !! wikitext
 [http://www.example.com/?title=100%25_Bran link]
 !! html
@@ -5339,7 +5472,7 @@ Bug 4781, 5267: %25 in bracketed URL
 !! end
 
 !! test
-Bug 4781, 5267: %28, %29 in bracketed URL
+T6781, T7267: %28, %29 in bracketed URL
 !! wikitext
 [http://www.example.com/?title=Ben-Hur_%281959_film%29 link]
 !! html/php
@@ -5350,7 +5483,7 @@ Bug 4781, 5267: %28, %29 in bracketed URL
 !! end
 
 !! test
-External link containing a period in the anchor. (bug 63947)
+External link containing a period in the anchor. (T65947)
 !! wikitext
 [//foo.org/bar#baz. bang]
 
@@ -5365,7 +5498,7 @@ External link containing a period in the anchor. (bug 63947)
 !! end
 
 !! test
-External link containing a single quote. (bug 63947)
+External link containing a single quote. (T65947)
 !! wikitext
 [//foo.org/bar'baz]
 
@@ -5380,7 +5513,7 @@ External link containing a single quote. (bug 63947)
 !! end
 
 !! test
-External link containing double-single-quotes in text '' (bug 4598 sanity check)
+External link containing double-single-quotes in text '' (T6598 sanity check)
 !! wikitext
 Some [http://example.com/ pretty ''italics'' and stuff]!
 !! html
@@ -5389,7 +5522,7 @@ Some [http://example.com/ pretty ''italics'' and stuff]!
 !! end
 
 !! test
-External link containing double-single-quotes in text embedded in italics (bug 4598 sanity check)
+External link containing double-single-quotes in text embedded in italics (T6598 sanity check)
 !! wikitext
 ''Some [http://example.com/ pretty ''italics'' and stuff]!''
 !! html
@@ -6349,7 +6482,7 @@ Nested table
 !! end
 
 !! test
-Invalid attributes in table cell (bug 1830)
+Invalid attributes in table cell (T3830)
 !! wikitext
 {|
 |Cell:|broken
@@ -6943,12 +7076,6 @@ Wikitext table with html-syntax row
 <td>foo</td></tr></tbody></table>
 !! end
 
-## Note that Parsoid output differs from PHP and PHP+tidy here.
-## The lack of <tr> tags in the PHP output is arguably a bug in the
-## PHP parser, which tidy then compounds by fostering the content
-## entirely out of the table.  Parsoid recognizes the table context
-## and generates <tr> and <td> wrappers as needed.  Hopefully nobody
-## depends on PHP's treatment of broken table markup!
 !! test
 Implicit <td> after a |-
 !! options
 !! html/php+tidy
 <p>a</p>
 !! html/parsoid
-<table>
-<tr><td>a</td></tr>
-</table>
-!! end
-
-# Again, Parsoid adds implicit <td>s here, PHP and Tidy strip the b out.
-!! test
-<pre> tags should be recognized in an explicit <td> context, but not in an implicit <td> context
-!! options
-parsoid=wt2html,html2html
-!! wikitext
-{|
-|-
-|
- a
-|-
- b
-|}
-!! html/php
-<table>
-
-<tr>
-<td>
-<pre>a
-</pre>
-</td></tr>
- b
-</table>
+<p data-parsoid='{"fostered":true,"autoInsertedEnd":true}'>a</p><table>
+<tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
 
-!! html/php+tidy
-<p>b</p>
-<table>
-<tr>
-<td>
-<pre>
-a
-</pre></td>
-</tr>
-</table>
-!! html/parsoid
-<table>
-<tbody>
-<tr><td><pre>a</pre></td></tr>
-<tr><td> b</td></tr>
-</tbody>
-</table>
+</tr></tbody></table>
 !! end
 
-# PHP + Tidy strips the list out of the table; Parsoid wraps it.
-# Parsoid generates the missing <td>, so wt2wt won't succeed.
 !! test
 Lists should be recognized in an implicit <td> context
 !! options
@@ -7037,13 +7120,10 @@ parsoid=wt2html,html2html
 <li>a</li>
 </ul>
 !! html/parsoid
-<table>
-<tr>
-<td><ul>
-<li>a</li>
-</ul></td>
-</tr>
-</table>
+<ul data-parsoid='{"fostered":true,"autoInsertedEnd":true}'><li>a</li></ul><table>
+<tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
+
+</tr></tbody></table>
 !! end
 
 !! test
@@ -7064,12 +7144,11 @@ Table cells not properly parsed in an implicit-td context
 !! html/parsoid
 <table>
 <tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
-<td style="background-color:#DC241f;" width="10px" about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"autoInsertedEnd":true,"pi":[[]]}' data-mw='{"parts":["",{"template":{"target":{"wt":"table_attribs_4","href":"./Template:Table_attribs_4"},"params":{},"i":0}}," "]}'> </td><td data-parsoid='{"stx_v":"row","autoInsertedEnd":true}'> a </td><td data-parsoid='{"stx_v":"row","autoInsertedEnd":true}'> b</td></tr>
-</tbody></table>
+<td style="background-color:#DC241f;" width="10px" about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"autoInsertedEnd":true,"pi":[[]]}' data-mw='{"parts":[{"template":{"target":{"wt":"table_attribs_4","href":"./Template:Table_attribs_4"},"params":{},"i":0}}," || a || b"]}'> </td><td about="#mwt1"> a </td><td about="#mwt1"> b</td></tr>
 !! end
 
 !! test
-Parsoid: Round-trip tables directly followed by content (bug 51219)
+Parsoid: Round-trip tables directly followed by content (T53219)
 !! options
 parsoid=wt2html,wt2wt
 !! wikitext
@@ -7096,7 +7175,7 @@ parsoid=wt2html,wt2wt
 !! end
 
 !! test
-Parsoid: Default to a newline after tables in new content (bug 51219)
+Parsoid: Default to a newline after tables in new content (T53219)
 !! options
 parsoid=html2wt
 !! html/parsoid
@@ -7505,7 +7584,7 @@ Piped link with no link text
 !! test
 Piped link with empty link text
 !! wikitext
-[[Main Page|<nowiki />]] - empty nowiki
+[[Main Page|<nowiki/>]] - empty nowiki
 [[Main Page| ]] - empty space
 [[Main Page|&nbsp;]] - empty non breaking space
 !! html/php
@@ -7514,7 +7593,7 @@ Piped link with empty link text
 <a href="/wiki/Main_Page" title="Main Page">&#160;</a> - empty non breaking space
 </p>
 !! html/parsoid
-<p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page"><meta typeof="mw:Placeholder" data-parsoid='{"src":"&lt;nowiki />"}'/></a> - empty nowiki
+<p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page"><span typeof="mw:Nowiki"></span></a> - empty nowiki
 <a rel="mw:WikiLink" href="./Main_Page" title="Main Page"> </a> - empty space
 <a rel="mw:WikiLink" href="./Main_Page" title="Main Page"><span typeof="mw:Entity" data-parsoid='{"src":"&amp;nbsp;","srcContent":" "}'> </span></a> - empty non breaking space</p>
 !! end
@@ -7580,7 +7659,7 @@ Some text
 !! endarticle
 
 !! test
-Bug 43661: Piped links with identical prefixes
+T45661: Piped links with identical prefixes
 !! wikitext
 [[prefixed article|prefixed articles with spaces]]
 
@@ -7659,7 +7738,7 @@ Link with multiple pipes
 !! end
 
 !! test
-Anchor containing a #. (bug 63430)
+Anchor containing a #. (T65430)
 !! wikitext
 [[Main Page#And#Link]]
 !! html/php
@@ -7695,7 +7774,7 @@ This is an article in the MemoryAlpha namespace
 !! endarticle
 
 !! test
-Namespace takes precedence over interwiki link (bug 51680)
+Namespace takes precedence over interwiki link (T53680)
 !! wikitext
 [[MemoryAlpha:AlphaTest]]
 !! html
@@ -7834,7 +7913,7 @@ Link containing a tilde
 !! end
 
 !! test
-Link containing double-single-quotes '' (bug 4598)
+Link containing double-single-quotes '' (T6598)
 !! wikitext
 [[Lista d''e paise d''o munno]]
 !! html/php
@@ -7856,7 +7935,23 @@ Link containing double quotes and spaces
 !! end
 
 !! test
-Link containing double-single-quotes '' in text (bug 4598 sanity check)
+File containing double quotes and spaces
+!! wikitext
+[[File:Cool "Gator".png]]
+!! html/parsoid
+<p><span class="mw-default-size" typeof="mw:Error mw:Image" data-parsoid='{"optList":[]}' data-mw='{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}]}'><a href="./File:Cool_%22Gator%22.png" data-parsoid='{"a":{"href":"./File:Cool_%22Gator%22.png"},"sa":{"href":"File:Cool \"Gator\".png"}}'><img resource='./File:Cool_"Gator".png' src="./Special:FilePath/Cool_%22Gator%22.png" height="220" width="220" data-parsoid='{"a":{"resource":"./File:Cool_\"Gator\".png","height":"220","width":"220","src":"./Special:FilePath/Cool_%22Gator%22.png"},"sa":{"resource":"File:Cool \"Gator\".png","src":"./Special:FilePath/Cool_\"Gator\".png"}}'/></a></span></p>
+!! end
+
+!! test
+Redirect containing double quotes and spaces
+!! wikitext
+#REDIRECT [[Cool "Gator"]]
+!! html/parsoid
+<link rel="mw:PageProp/redirect" href="./Cool_%22Gator%22" data-parsoid='{"src":"#REDIRECT ","a":{"href":"./Cool_%22Gator%22"},"sa":{"href":"Cool \"Gator\""}}'/>
+!! end
+
+!! test
+Link containing double-single-quotes '' in text (T6598 sanity check)
 !! wikitext
 Some [[Link|pretty ''italics'' and stuff]]!
 !! html/php
@@ -7867,7 +7962,7 @@ Some [[Link|pretty ''italics'' and stuff]]!
 !! end
 
 !! test
-Link containing double-single-quotes '' in text embedded in italics (bug 4598 sanity check)
+Link containing double-single-quotes '' in text embedded in italics (T6598 sanity check)
 !! wikitext
 ''Some [[Link|pretty ''italics'' and stuff]]!''
 !! html
@@ -7892,14 +7987,14 @@ Link with double quotes in title part (literal) and alternate part (interpreted)
 </p><p><a href="/index.php?title=%27%27Pentecoste%27%27&amp;action=edit&amp;redlink=1" class="new" title="''Pentecoste'' (page does not exist)"><i>Pentecoste</i></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."}]}'><a href="./File:Denys_Savchenko_''Pentecoste''.jpg"><img resource="./File:Denys_Savchenko_''Pentecoste''.jpg" src="./Special:FilePath/Denys_Savchenko_''Pentecoste''.jpg" height="220" width="220"/></a></span></p>
+<p><span class="mw-default-size" typeof="mw:Error mw:Image" data-mw='{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}]}'><a href="./File:Denys_Savchenko_''Pentecoste''.jpg"><img resource="./File:Denys_Savchenko_''Pentecoste''.jpg" src="./Special:FilePath/Denys_Savchenko_''Pentecoste''.jpg" height="220" width="220"/></a></span></p>
 <p><a rel="mw:WikiLink" href="./''Pentecoste''" title="''Pentecoste''">''Pentecoste''</a></p>
 <p><a rel="mw:WikiLink" href="./''Pentecoste''" title="''Pentecoste''">Pentecoste</a></p>
 <p><a rel="mw:WikiLink" href="./''Pentecoste''" title="''Pentecoste''"><i>Pentecoste</i></a></p>
 !! end
 
 !! test
-Broken image links with HTML captions (bug 39700)
+Broken image links with HTML captions (T41700)
 !! wikitext
 [[File:Nonexistent|<script></script>]]
 [[File:Nonexistent|100x100px|<script></script>]]
@@ -7912,10 +8007,10 @@ Broken image links with HTML captions (bug 39700)
 <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-parsoid='{"optList":[{"ck":"caption","ak":"&lt;script>&lt;/script>"}]}' data-mw='{"errors":[{"key":"missing-image","message":"This image does not exist."}],"caption":"&amp;lt;script>&amp;lt;/script>"}'><a href="./File:Nonexistent" data-parsoid='{"a":{"href":"./File:Nonexistent"},"sa":{}}'><img resource="./File:Nonexistent" src="./Special:FilePath/Nonexistent" height="220" width="220" data-parsoid='{"a":{"resource":"./File:Nonexistent","height":"220","width":"220"},"sa":{"resource":"File:Nonexistent"}}'/></a></span>
-<span typeof="mw:Error mw:Image" data-parsoid='{"optList":[{"ck":"width","ak":"100x100px"},{"ck":"caption","ak":"&lt;script>&lt;/script>"}]}' data-mw='{"errors":[{"key":"missing-image","message":"This image does not exist."}],"caption":"&amp;lt;script>&amp;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" data-parsoid='{"a":{"resource":"./File:Nonexistent","height":"100","width":"100"},"sa":{"resource":"File:Nonexistent"}}'/></a></span>
-<span class="mw-default-size" typeof="mw:Error mw:Image" data-parsoid='{"optList":[{"ck":"caption","ak":"&amp;lt;"}]}' data-mw='{"errors":[{"key":"missing-image","message":"This image does not exist."}],"caption":"&lt;span typeof=\"mw:Entity\" data-parsoid=&#39;{\"src\":\"&amp;amp;lt;\",\"srcContent\":\"&amp;lt;\",\"dsr\":[107,111,null,null]}&#39;>&amp;lt;&lt;/span>"}'><a href="./File:Nonexistent" data-parsoid='{"a":{"href":"./File:Nonexistent"},"sa":{}}'><img resource="./File:Nonexistent" src="./Special:FilePath/Nonexistent" height="220" width="220" data-parsoid='{"a":{"resource":"./File:Nonexistent","height":"220","width":"220"},"sa":{"resource":"File:Nonexistent"}}'/></a></span>
-<span class="mw-default-size" typeof="mw:Error mw:Image" data-parsoid='{"optList":[{"ck":"caption","ak":"a&lt;i>b&lt;/i>c"}]}' data-mw='{"errors":[{"key":"missing-image","message":"This image does not exist."}],"caption":"a&lt;i data-parsoid=&#39;{\"stx\":\"html\",\"dsr\":[134,142,3,4]}&#39;>b&lt;/i>c"}'><a href="./File:Nonexistent" data-parsoid='{"a":{"href":"./File:Nonexistent"},"sa":{}}'><img resource="./File:Nonexistent" src="./Special:FilePath/Nonexistent" height="220" width="220" data-parsoid='{"a":{"resource":"./File:Nonexistent","height":"220","width":"220"},"sa":{"resource":"File:Nonexistent"}}'/></a></span></p>
+<p><span class="mw-default-size" typeof="mw:Error mw:Image" data-parsoid='{"optList":[{"ck":"caption","ak":"&lt;script>&lt;/script>"}]}' data-mw='{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}],"caption":"&amp;lt;script>&amp;lt;/script>"}'><a href="./File:Nonexistent" data-parsoid='{"a":{"href":"./File:Nonexistent"},"sa":{}}'><img resource="./File:Nonexistent" src="./Special:FilePath/Nonexistent" height="220" width="220" data-parsoid='{"a":{"resource":"./File:Nonexistent","height":"220","width":"220"},"sa":{"resource":"File:Nonexistent"}}'/></a></span>
+<span typeof="mw:Error mw:Image" data-parsoid='{"optList":[{"ck":"width","ak":"100x100px"},{"ck":"caption","ak":"&lt;script>&lt;/script>"}]}' data-mw='{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}],"caption":"&amp;lt;script>&amp;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" data-parsoid='{"a":{"resource":"./File:Nonexistent","height":"100","width":"100"},"sa":{"resource":"File:Nonexistent"}}'/></a></span>
+<span class="mw-default-size" typeof="mw:Error mw:Image" data-parsoid='{"optList":[{"ck":"caption","ak":"&amp;lt;"}]}' data-mw='{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}],"caption":"&lt;span typeof=\"mw:Entity\" data-parsoid=&#39;{\"src\":\"&amp;amp;lt;\",\"srcContent\":\"&amp;lt;\",\"dsr\":[107,111,null,null]}&#39;>&amp;lt;&lt;/span>"}'><a href="./File:Nonexistent" data-parsoid='{"a":{"href":"./File:Nonexistent"},"sa":{}}'><img resource="./File:Nonexistent" src="./Special:FilePath/Nonexistent" height="220" width="220" data-parsoid='{"a":{"resource":"./File:Nonexistent","height":"220","width":"220"},"sa":{"resource":"File:Nonexistent"}}'/></a></span>
+<span class="mw-default-size" typeof="mw:Error mw:Image" data-parsoid='{"optList":[{"ck":"caption","ak":"a&lt;i>b&lt;/i>c"}]}' data-mw='{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}],"caption":"a&lt;i data-parsoid=&#39;{\"stx\":\"html\",\"dsr\":[134,142,3,4]}&#39;>b&lt;/i>c"}'><a href="./File:Nonexistent" data-parsoid='{"a":{"href":"./File:Nonexistent"},"sa":{}}'><img resource="./File:Nonexistent" src="./Special:FilePath/Nonexistent" height="220" width="220" data-parsoid='{"a":{"resource":"./File:Nonexistent","height":"220","width":"220"},"sa":{"resource":"File:Nonexistent"}}'/></a></span></p>
 !! end
 
 !! test
@@ -7994,7 +8089,7 @@ Piped link to URL: [[http://www.example.com|an example URL]]
 !! end
 
 !! test
-BUG 2: [[page|http://url/]] should link to page, not http://url/
+T2002: [[page|http://url/]] should link to page, not http://url/
 !! wikitext
 [[Main Page|http://url/]]
 !! html/php
@@ -8006,16 +8101,16 @@ BUG 2: [[page|http://url/]] should link to page, not http://url/
 
 # Parsoid does not mark self-links, by design.
 !! test
-BUG 337: Escaped self-links should be bold
+T2337: Escaped self-links should be bold
 !! options
 title=[[Bug462]]
 !! wikitext
 [[Bu&#103;462]] [[Bug462]]
 !! html/php
-<p><strong class="selflink">Bu&#103;462</strong> <strong class="selflink">Bug462</strong>
+<p><a class="mw-selflink selflink">Bu&#103;462</a> <a class="mw-selflink selflink">Bug462</a>
 </p>
 !! html/php+tidy
-<p><strong class="selflink">Bug462</strong> <strong class="selflink">Bug462</strong></p>
+<p><a class="mw-selflink selflink">Bug462</a> <a class="mw-selflink selflink">Bug462</a></p>
 !! html/parsoid
 <p><a rel="mw:WikiLink" href="./Bug462" title="Bug462">Bug462</a> <a rel="mw:WikiLink" href="./Bug462" title="Bug462">Bug462</a></p>
 !! end
@@ -8044,7 +8139,7 @@ title=[[0]]
 !! wikitext
 [[0]]
 !! html
-<p><strong class="selflink">0</strong>
+<p><a class="mw-selflink selflink">0</a>
 </p>
 !!end
 
@@ -8078,7 +8173,7 @@ Non-breaking spaces in title
 !!end
 
 !! test
-Internal link with ca linktrail, surrounded by bold apostrophes (bug 27473 primary issue)
+Internal link with ca linktrail, surrounded by bold apostrophes (T29473 primary issue)
 !! options
 language=ca
 !! wikitext
@@ -8089,7 +8184,7 @@ language=ca
 !! end
 
 !! test
-Internal link with ca linktrail, surrounded by italic apostrophes (bug 27473 primary issue)
+Internal link with ca linktrail, surrounded by italic apostrophes (T29473 primary issue)
 !! options
 language=ca
 !! wikitext
@@ -8100,7 +8195,7 @@ language=ca
 !! end
 
 !! test
-Internal link with en linktrail: no apostrophes (bug 27473)
+Internal link with en linktrail: no apostrophes (T29473)
 !! options
 language=en
 !! wikitext
@@ -8111,7 +8206,7 @@ language=en
 !! end
 
 !! test
-Internal link with ca linktrail with apostrophes (bug 27473)
+Internal link with ca linktrail with apostrophes (T29473)
 !! options
 language=ca
 !! wikitext
@@ -8122,7 +8217,7 @@ language=ca
 !! end
 
 !! test
-Internal link with kaa linktrail with apostrophes (bug 27473)
+Internal link with kaa linktrail with apostrophes (T29473)
 !! options
 language=kaa
 !! wikitext
@@ -8133,7 +8228,7 @@ language=kaa
 !! end
 
 !! test
-Link with multiple ":" in a subpage-supporting namespace (bug 63636)
+Link with multiple ":" in a subpage-supporting namespace (T65636)
 !! wikitext
 [[User:Foo/Test/63636:Bar|Test]]
 !! html/php
@@ -8352,7 +8447,7 @@ parsoid=wt2html,wt2wt,html2html
 !! end
 
 !! test
-Inline interwiki link with empty title (bug 2372)
+Inline interwiki link with empty title (T4372)
 !! options
 parsoid=wt2html,wt2wt,html2html
 !! wikitext
@@ -8365,7 +8460,7 @@ parsoid=wt2html,wt2wt,html2html
 !! end
 
 !! test
-Interwiki link encoding conversion (bug 1636)
+Interwiki link encoding conversion (T3636)
 !! wikitext
 *[[Wikipedia:ro:Olteni&#0355;a]]
 *[[Wikipedia:ro:Olteni&#355;a]]
@@ -8381,7 +8476,7 @@ Interwiki link encoding conversion (bug 1636)
 !! end
 
 !! test
-Interwiki link with fragment (bug 2130)
+Interwiki link with fragment (T4130)
 !! wikitext
 [[MeatBall:SoftSecurity#foo]]
 !! html
@@ -8500,14 +8595,14 @@ parsoid=wt2html,wt2wt,html2html
 !! wikitext
 [[local:Main Page]]
 !! html/php
-<p><strong class="selflink">local:Main Page</strong>
+<p><a class="mw-selflink selflink">local:Main Page</a>
 </p>
 !! html/parsoid
 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">local:Main Page</a></p>
 !! end
 
 !! test
-Local interwiki link: prefix only (bug 64167)
+Local interwiki link: prefix only (T66167)
 !! options
 parsoid=wt2html,wt2wt,html2html
 !! wikitext
@@ -8520,7 +8615,7 @@ parsoid=wt2html,wt2wt,html2html
 !! end
 
 !! test
-Local interwiki link: with additional interwiki prefix (bug 61357)
+Local interwiki link: with additional interwiki prefix (T63357)
 !! options
 parsoid=wt2html,wt2wt,html2html
 !! wikitext
@@ -8615,7 +8710,7 @@ Blah blah blah
 !! end
 
 !! test
-Escaping of interlanguage links
+Escaping of interlanguage links (T129218, T156308)
 !! wikitext
 Blah blah blah
 [[:es:Spanish]]
@@ -8626,7 +8721,8 @@ Blah blah blah
 <a href="http://zh.wikipedia.org/wiki/Chinese" class="extiw" title="zh:Chinese"> zh : Chinese </a>
 </p>
 !! html/parsoid
-<p><a rel="mw:ExtLink" href="http://es.wikipedia.org/wiki/Spanish" title="es:Spanish">es:Spanish</a>
+<p>Blah blah blah
+<a rel="mw:ExtLink" href="http://es.wikipedia.org/wiki/Spanish" title="es:Spanish">es:Spanish</a>
 <a rel="mw:ExtLink" href="http://zh.wikipedia.org/wiki/Chinese" title="zh:Chinese"> zh : Chinese </a></p>
 !! end
 
@@ -8662,7 +8758,7 @@ Blah blah blah
 !! end
 
 !! test
-Double interlanguage link, with prefix links (bug 8897)
+Double interlanguage link, with prefix links (T10897)
 !! options
 language=ln
 !! wikitext
@@ -8679,7 +8775,7 @@ Blah blah blah
 !! end
 
 !! test
-"Extra" interlanguage links (bug 32189 / gerrit 111390)
+"Extra" interlanguage links (T34189 / gerrit 111390)
 !! wikitext
 Blah blah blah
 [[mul:Article]]
@@ -8731,7 +8827,7 @@ language=ln
 !! end
 
 !! test
-Parsoid bug 53221: Wikilinks should be properly entity-escaped
+Parsoid T55221: Wikilinks should be properly entity-escaped
 !! options
 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
 !! html/parsoid
@@ -8808,7 +8904,7 @@ parsoid=wt2html,wt2wt,html2html
 !! end
 
 !! test
-Handle interwiki links pointing to the current wiki as plain wiki links (bug 45209)
+Handle interwiki links pointing to the current wiki as plain wiki links (T47209)
 !! wikitext
 [[mi:Foo]]
 !! html/php
@@ -8819,7 +8915,7 @@ Handle interwiki links pointing to the current wiki as plain wiki links (bug 452
 !! end
 
 !! test
-Interlanguage link with preceding local interwiki link (bug 68085)
+Interlanguage link with preceding local interwiki link (T70085)
 !! options
 parsoid=wt2html,wt2wt,html2html
 !! wikitext
@@ -9066,7 +9162,7 @@ Broken br tag sanitization
 </p>
 !! end
 
-# TODO: Fix html2html mode (bug 51055)!
+# TODO: Fix html2html mode (T53055)!
 !! test
 Parsoid: Broken br tag recognition
 !! options
@@ -9450,7 +9546,7 @@ parsoid
 !! end
 
 !! test
-List items are not parsed correctly following a <pre> block (bug 785)
+List items are not parsed correctly following a <pre> block (T2785)
 !! wikitext
 * <pre>foo</pre>
 * <pre>bar</pre>
@@ -9461,8 +9557,8 @@ List items are not parsed correctly following a <pre> block (bug 785)
 <li> zar</li></ul>
 
 !! html/parsoid
-<ul><li> <pre data-parsoid='{"stx":"html"}'>foo</pre></li>
-<li> <pre data-parsoid='{"stx":"html"}'>bar</pre></li>
+<ul><li> <pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo"}}'>foo</pre></li>
+<li> <pre typeof="mw:Extension/pre" about="#mwt4" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"bar"}}'>bar</pre></li>
 <li> zar</li></ul>
 !! end
 
@@ -9659,7 +9755,7 @@ Unbalanced closing block tags break a list
 !! end
 
 # Parsoid fails this test, but it might be tricky to support properly.
-# See bug 68395.
+# See T70395.
 !! test
 Unbalanced closing non-block tags don't break a list
 (php parser relies on Tidy to fix up)
@@ -9701,7 +9797,7 @@ parsoid=wt2html,wt2wt,html2html
 <li><s> b </s></li></ol>
 !! end
 
-# See bug 68395.
+# See T70395.
 !!test
 1. List embedded in a formatting tag
 !! wikitext
@@ -9893,7 +9989,7 @@ Magic Word: {{CURRENTHOUR}}
 !! end
 
 !! test
-Magic Word: {{CURRENTWEEK}} (@bug 4594)
+Magic Word: {{CURRENTWEEK}} (T6594)
 !! wikitext
 {{CURRENTWEEK}}
 !! html
@@ -9958,9 +10054,10 @@ Magic Words LOCAL (UTC)
 Magic Word: {{FULLPAGENAME}}
 !! options
 title=[[User:Ævar Arnfjörð Bjarmason]]
+parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
 !! wikitext
 {{FULLPAGENAME}}
-!! html
+!! html/*
 <p>User:Ævar Arnfjörð Bjarmason
 </p>
 !! end
@@ -9969,9 +10066,10 @@ title=[[User:Ævar Arnfjörð Bjarmason]]
 Magic Word: {{FULLPAGENAMEE}}
 !! options
 title=[[User:Ævar Arnfjörð Bjarmason]]
+parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
 !! wikitext
 {{FULLPAGENAMEE}}
-!! html
+!! html/*
 <p>User:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
 </p>
 !! end
@@ -9980,9 +10078,10 @@ title=[[User:Ævar Arnfjörð Bjarmason]]
 Magic Word: {{TALKSPACE}}
 !! options
 title=[[User:Ævar Arnfjörð Bjarmason]]
+parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
 !! wikitext
 {{TALKSPACE}}
-!! html
+!! html/*
 <p>User talk
 </p>
 !! end
@@ -9991,9 +10090,10 @@ title=[[User:Ævar Arnfjörð Bjarmason]]
 Magic Word: {{TALKSPACE}}, same namespace
 !! options
 title=[[User talk:Ævar Arnfjörð Bjarmason]]
+parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
 !! wikitext
 {{TALKSPACE}}
-!! html
+!! html/*
 <p>User talk
 </p>
 !! end
@@ -10002,9 +10102,10 @@ title=[[User talk:Ævar Arnfjörð Bjarmason]]
 Magic Word: {{TALKSPACE}}, main namespace
 !! options
 title=[[Parser Test]]
+parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
 !! wikitext
 {{TALKSPACE}}
-!! html
+!! html/*
 <p>Talk
 </p>
 !! end
@@ -10013,9 +10114,10 @@ title=[[Parser Test]]
 Magic Word: {{TALKSPACEE}}
 !! options
 title=[[User:Ævar Arnfjörð Bjarmason]]
+parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
 !! wikitext
 {{TALKSPACEE}}
-!! html
+!! html/*
 <p>User_talk
 </p>
 !! end
@@ -10024,9 +10126,10 @@ title=[[User:Ævar Arnfjörð Bjarmason]]
 Magic Word: {{SUBJECTSPACE}}
 !! options
 title=[[User talk:Ævar Arnfjörð Bjarmason]]
+parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
 !! wikitext
 {{SUBJECTSPACE}}
-!! html
+!! html/*
 <p>User
 </p>
 !! end
@@ -10035,9 +10138,10 @@ title=[[User talk:Ævar Arnfjörð Bjarmason]]
 Magic Word: {{SUBJECTSPACE}}, same namespace
 !! options
 title=[[User:Ævar Arnfjörð Bjarmason]]
+parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
 !! wikitext
 {{SUBJECTSPACE}}
-!! html
+!! html/*
 <p>User
 </p>
 !! end
@@ -10046,9 +10150,10 @@ title=[[User:Ævar Arnfjörð Bjarmason]]
 Magic Word: {{SUBJECTSPACE}}, main namespace
 !! options
 title=[[Parser Test]]
+parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
 !! wikitext
 {{SUBJECTSPACE}}
-!! html
+!! html/*
 
 !! end
 
@@ -10056,9 +10161,10 @@ title=[[Parser Test]]
 Magic Word: {{SUBJECTSPACEE}}
 !! options
 title=[[User talk:Ævar Arnfjörð Bjarmason]]
+parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
 !! wikitext
 {{SUBJECTSPACEE}}
-!! html
+!! html/*
 <p>User
 </p>
 !! end
@@ -10067,9 +10173,10 @@ title=[[User talk:Ævar Arnfjörð Bjarmason]]
 Magic Word: {{NAMESPACE}}
 !! options
 title=[[User:Ævar Arnfjörð Bjarmason]]
+parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
 !! wikitext
 {{NAMESPACE}}
-!! html
+!! html/*
 <p>User
 </p>
 !! end
@@ -10078,9 +10185,10 @@ title=[[User:Ævar Arnfjörð Bjarmason]]
 Magic Word: {{NAMESPACEE}}
 !! options
 title=[[User:Ævar Arnfjörð Bjarmason]]
+parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
 !! wikitext
 {{NAMESPACEE}}
-!! html
+!! html/*
 <p>User
 </p>
 !! end
@@ -10089,9 +10197,10 @@ title=[[User:Ævar Arnfjörð Bjarmason]]
 Magic Word: {{NAMESPACENUMBER}}
 !! options
 title=[[User:Ævar Arnfjörð Bjarmason]]
+parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
 !! wikitext
 {{NAMESPACENUMBER}}
-!! html
+!! html/*
 <p>2
 </p>
 !! end
@@ -10100,9 +10209,10 @@ title=[[User:Ævar Arnfjörð Bjarmason]]
 Magic Word: {{SUBPAGENAME}}
 !! options
 title=[[Ævar Arnfjörð Bjarmason/sub ö]] subpage
+parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
 !! wikitext
 {{SUBPAGENAME}}
-!! html
+!! html/*
 <p>sub ö
 </p>
 !! end
@@ -10111,9 +10221,10 @@ title=[[Ævar Arnfjörð Bjarmason/sub ö]] subpage
 Magic Word: {{SUBPAGENAMEE}}
 !! options
 title=[[Ævar Arnfjörð Bjarmason/sub ö]] subpage
+parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
 !! wikitext
 {{SUBPAGENAMEE}}
-!! html
+!! html/*
 <p>sub_%C3%B6
 </p>
 !! end
@@ -10122,9 +10233,10 @@ title=[[Ævar Arnfjörð Bjarmason/sub ö]] subpage
 Magic Word: {{ROOTPAGENAME}}
 !! options
 title=[[Ævar Arnfjörð Bjarmason/sub/sub2]] subpage
+parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
 !! wikitext
 {{ROOTPAGENAME}}
-!! html
+!! html/*
 <p>Ævar Arnfjörð Bjarmason
 </p>
 !! end
@@ -10133,9 +10245,10 @@ title=[[Ævar Arnfjörð Bjarmason/sub/sub2]] subpage
 Magic Word: {{ROOTPAGENAMEE}}
 !! options
 title=[[Ævar Arnfjörð Bjarmason/sub/sub2]] subpage
+parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
 !! wikitext
 {{ROOTPAGENAMEE}}
-!! html
+!! html/*
 <p>%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
 </p>
 !! end
@@ -10144,9 +10257,10 @@ title=[[Ævar Arnfjörð Bjarmason/sub/sub2]] subpage
 Magic Word: {{BASEPAGENAME}}
 !! options
 title=[[Ævar Arnfjörð Bjarmason/sub]] subpage
+parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
 !! wikitext
 {{BASEPAGENAME}}
-!! html
+!! html/*
 <p>Ævar Arnfjörð Bjarmason
 </p>
 !! end
@@ -10155,9 +10269,10 @@ title=[[Ævar Arnfjörð Bjarmason/sub]] subpage
 Magic Word: {{BASEPAGENAMEE}}
 !! options
 title=[[Ævar Arnfjörð Bjarmason/sub]] subpage
+parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
 !! wikitext
 {{BASEPAGENAMEE}}
-!! html
+!! html/*
 <p>%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
 </p>
 !! end
@@ -10166,9 +10281,10 @@ title=[[Ævar Arnfjörð Bjarmason/sub]] subpage
 Magic Word: {{TALKPAGENAME}}
 !! options
 title=[[User:Ævar Arnfjörð Bjarmason]]
+parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
 !! wikitext
 {{TALKPAGENAME}}
-!! html
+!! html/*
 <p>User talk:Ævar Arnfjörð Bjarmason
 </p>
 !! end
@@ -10177,9 +10293,10 @@ title=[[User:Ævar Arnfjörð Bjarmason]]
 Magic Word: {{TALKPAGENAMEE}}
 !! options
 title=[[User:Ævar Arnfjörð Bjarmason]]
+parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
 !! wikitext
 {{TALKPAGENAMEE}}
-!! html
+!! html/*
 <p>User_talk:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
 </p>
 !! end
@@ -10188,9 +10305,10 @@ title=[[User:Ævar Arnfjörð Bjarmason]]
 Magic Word: {{SUBJECTPAGENAME}}
 !! options
 title=[[User talk:Ævar Arnfjörð Bjarmason]]
+parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
 !! wikitext
 {{SUBJECTPAGENAME}}
-!! html
+!! html/*
 <p>User:Ævar Arnfjörð Bjarmason
 </p>
 !! end
@@ -10199,18 +10317,21 @@ title=[[User talk:Ævar Arnfjörð Bjarmason]]
 Magic Word: {{SUBJECTPAGENAMEE}}
 !! options
 title=[[User talk:Ævar Arnfjörð Bjarmason]]
+parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
 !! wikitext
 {{SUBJECTPAGENAMEE}}
-!! html
+!! html/*
 <p>User:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
 </p>
 !! end
 
 !! test
 Magic Word: {{NUMBEROFFILES}}
+!! options
+parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
 !! wikitext
 {{NUMBEROFFILES}}
-!! html
+!! html/*
 <p>7
 </p>
 !! end
@@ -10219,9 +10340,10 @@ Magic Word: {{NUMBEROFFILES}}
 Magic Word: {{PAGENAME}}
 !! options
 title=[[User:Ævar Arnfjörð Bjarmason]]
+parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
 !! wikitext
 {{PAGENAME}}
-!! html
+!! html/*
 <p>Ævar Arnfjörð Bjarmason
 </p>
 !! end
@@ -10230,6 +10352,7 @@ title=[[User:Ævar Arnfjörð Bjarmason]]
 Magic Word: {{PAGENAME}} with metacharacters
 !! options
 title=[['foo & bar = baz']]
+parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
 !! wikitext
 ''{{PAGENAME}}''
 !! html/php
@@ -10240,9 +10363,10 @@ title=[['foo & bar = baz']]
 !! end
 
 !! test
-Magic Word: {{PAGENAME}} with metacharacters (bug 26781)
+Magic Word: {{PAGENAME}} with metacharacters (T28781)
 !! options
 title=[[*RFC 1234 http://example.com/]]
+parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
 !! wikitext
 {{PAGENAME}}
 !! html/php
@@ -10256,17 +10380,19 @@ title=[[*RFC 1234 http://example.com/]]
 Magic Word: {{PAGENAMEE}}
 !! options
 title=[[User:Ævar Arnfjörð Bjarmason]]
+parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
 !! wikitext
 {{PAGENAMEE}}
-!! html
+!! html/*
 <p>%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
 </p>
 !! end
 
 !! test
-Magic Word: {{PAGENAMEE}} with metacharacters (bug 26781)
+Magic Word: {{PAGENAMEE}} with metacharacters (T28781)
 !! options
 title=[[*RFC 1234 http://example.com/]]
+parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
 !! wikitext
 {{PAGENAMEE}}
 !! html/php
@@ -10278,53 +10404,65 @@ title=[[*RFC 1234 http://example.com/]]
 
 !! test
 Magic Word: {{REVISIONID}}
+!! options
+parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
 !! wikitext
 {{REVISIONID}}
-!! html
+!! html/*
 <p>1337
 </p>
 !! end
 
 !! test
 Magic Word: {{SCRIPTPATH}}
+!! options
+parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
 !! wikitext
 {{SCRIPTPATH}}
-!! html
+!! html/*
 
 !! end
 
 !! test
 Magic Word: {{STYLEPATH}}
+!! options
+parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
 !! wikitext
 {{STYLEPATH}}
-!! html
+!! html/*
 <p>/skins
 </p>
 !! end
 
 !! test
 Magic Word: {{SERVER}}
+!! options
+parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
 !! wikitext
 {{SERVER}}
-!! html
+!! html/*
 <p><a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>
 </p>
 !! end
 
 !! test
 Magic Word: {{SERVERNAME}}
+!! options
+parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
 !! wikitext
 {{SERVERNAME}}
-!! html
+!! html/*
 <p>example.org
 </p>
 !! end
 
 !! test
 Magic Word: {{SITENAME}}
+!! options
+parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
 !! wikitext
 {{SITENAME}}
-!! html
+!! html/*
 <p>MediaWiki
 </p>
 !! end
@@ -10333,18 +10471,21 @@ Magic Word: {{SITENAME}}
 Magic Word: {{PAGELANGUAGE}}
 !! options
 language=fr
+parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
 !! wikitext
 {{PAGELANGUAGE}}
-!! html
+!! html/*
 <p>fr
 </p>
 !! end
 
 !! test
 Magic Word: {{PAGELANGUAGE}} on a page with no explicitly set language
+!! options
+parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
 !! wikitext
 {{PAGELANGUAGE}}
-!! html
+!! html/*
 <p>en
 </p>
 !! end
@@ -10385,15 +10526,26 @@ Parsoid: Page property magic word with magic word contents
 !! wikitext
 {{DISPLAYTITLE:''{{PAGENAME}}''}}
 !! html/parsoid
-<meta property="mw:PageProp/displaytitle" content="Main Page" about="#mwt3" typeof="mw:ExpandedAttrs" data-parsoid='{"src":"{{DISPLAYTITLE:&#39;&#39;{{PAGENAME}}&#39;&#39;}}"}' data-mw='{"attribs":[[{"txt":"content"},{"html":"&lt;i data-parsoid=&#39;{\"dsr\":[15,31,2,2]}&#39;>&lt;span about=\"#mwt2\" typeof=\"mw:Transclusion\" data-parsoid=&#39;{\"pi\":[[]],\"dsr\":[17,29,null,null]}&#39; data-mw=&#39;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"PAGENAME\",\"function\":\"pagename\"},\"params\":{},\"i\":0}}]}&#39;>Main Page&lt;/span>&lt;/i>"}]]}'/>
+<meta property="mw:PageProp/displaytitle" content="Main Page" about="#mwt3" typeof="mw:ExpandedAttrs" data-parsoid='{"src":"{{DISPLAYTITLE:&#39;&#39;{{PAGENAME}}&#39;&#39;}}"}' data-mw='{"attribs":[[{"txt":"content"},{"html":"DISPLAYTITLE:&lt;i data-parsoid=&#39;{\"dsr\":[15,31,2,2]}&#39;>&lt;span about=\"#mwt1\" typeof=\"mw:Transclusion\" data-parsoid=&#39;{\"pi\":[[]],\"dsr\":[17,29,null,null]}&#39; data-mw=&#39;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"PAGENAME\",\"function\":\"pagename\"},\"params\":{},\"i\":0}}]}&#39;>Main Page&lt;/span>&lt;/i>"}]]}'/>
 !! end
 
+# NOTE: mw:ExpandedAttrs is not the best typeof here. mw:Transclusion is better.
+# But, this is a limitation of our representation and is documented in
+# TemplateHandler.js in processSpecialMagicWord
 !! test
 Parsoid: Template-generated DISPLAYTITLE
 !! wikitext
 {{{{echo|DISPLAYTITLE}}:Foo}}
+!! options
+showtitle
+!! config
+wgAllowDisplayTitle=true
+wgRestrictDisplayTitle=false
+!! html/php
+Foo
+
 !! html/parsoid
-<meta property="mw:PageProp/displaytitle" content="Foo" about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"pi":[[]]}' data-mw='{"parts":[{"template":{"target":{"wt":"{{echo|DISPLAYTITLE}}:Foo"},"params":{},"i":0}}]}'/>
+<meta property="mw:PageProp/displaytitle" content="Foo" about="#mwt1" typeof="mw:ExpandedAttrs" data-parsoid='{"pi":[[]]}' data-mw='{"attribs":[[{"txt":"content"},{"html":"&lt;span about=\"#mwt1\" typeof=\"mw:Transclusion\" data-parsoid=&#39;{\"pi\":[[{\"k\":\"1\"}]],\"dsr\":[2,23,null,null]}&#39; data-mw=&#39;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"DISPLAYTITLE\"}},\"i\":0}}]}&#39;>DISPLAYTITLE&lt;/span>:Foo"}]]}'/>
 !! end
 
 !! test
@@ -10415,7 +10567,7 @@ Namespace 1 {{ns:01}}
 !! end
 
 !! test
-Namespace 0 {{ns:0}} (bug 4783)
+Namespace 0 {{ns:0}} (T6783)
 !! wikitext
 {{ns:0}}
 !! html
@@ -10423,7 +10575,7 @@ Namespace 0 {{ns:0}} (bug 4783)
 !! end
 
 !! test
-Namespace 0 {{ns:00}} (bug 4783)
+Namespace 0 {{ns:00}} (T6783)
 !! wikitext
 {{ns:00}}
 !! html
@@ -10567,7 +10719,7 @@ __proto__
 ### Magic links
 ###
 !! test
-Magic links: internal link to RFC (bug 479)
+Magic links: internal link to RFC (T2479)
 !! wikitext
 [[RFC 123]]
 !! html/php
@@ -10578,7 +10730,7 @@ Magic links: internal link to RFC (bug 479)
 !! end
 
 !! test
-Magic links: RFC (bug 479)
+Magic links: RFC (T2479)
 !! wikitext
 RFC 822
 !! html/php
@@ -10589,7 +10741,7 @@ RFC 822
 !! end
 
 !! test
-Magic links: RFC (bug 65278)
+Magic links: RFC (T67278)
 !! wikitext
 This is RFC 822 but thisRFC 822 is not RFC 822linked.
 !! html/php
@@ -10600,7 +10752,7 @@ This is RFC 822 but thisRFC 822 is not RFC 822linked.
 !! end
 
 !! test
-Magic links: RFC (w/ non-newline whitespace, bug 28950/29025)
+Magic links: RFC (w/ non-newline whitespace, T30950/T31025)
 !! wikitext
 RFC &nbsp;&#160;&#0160;&#xA0;&#Xa0; 822
 RFC
@@ -10617,7 +10769,7 @@ RFC
 !! end
 
 !! test
-Magic links: ISBN (bug 1937)
+Magic links: ISBN (T3937)
 !! wikitext
 ISBN 0-306-40615-2
 !! html/php
@@ -10628,7 +10780,7 @@ ISBN 0-306-40615-2
 !! end
 
 !! test
-Magic links: ISBN (bug 65278)
+Magic links: ISBN (T67278)
 !! wikitext
 This is ISBN 978-0-316-09811-3 but thisISBN 978-0-316-09811-3 is not ISBN 978-0-316-09811-3linked.
 !! html/php
@@ -10639,7 +10791,7 @@ This is ISBN 978-0-316-09811-3 but thisISBN 978-0-316-09811-3 is not ISBN 978-0-
 !! end
 
 !! test
-Magic links: ISBN (w/ non-newline whitespace, bug 28950/29025)
+Magic links: ISBN (w/ non-newline whitespace, T30950/T31025)
 !! wikitext
 ISBN &nbsp;&#160;&#0160;&#xA0;&#Xa0; 978&nbsp;0&#160;316&#0160;09811&#xA0;3
 ISBN
@@ -10673,7 +10825,7 @@ PMID 1234
 !! end
 
 !! test
-Magic links: PMID (bug 65278)
+Magic links: PMID (T67278)
 !! wikitext
 This is PMID 1234 but thisPMID 1234 is not PMID 1234linked.
 !! html/php
@@ -10684,7 +10836,7 @@ This is PMID 1234 but thisPMID 1234 is not PMID 1234linked.
 !! end
 
 !! test
-Magic links: PMID (w/ non-newline whitespace, bug 28950/29025)
+Magic links: PMID (w/ non-newline whitespace, T30950/T31025)
 !! wikitext
 PMID &nbsp;&#160;&#0160;&#xA0;&#Xa0; 1234
 PMID
@@ -10775,7 +10927,7 @@ Template with invalid target containing wikilink
 !! end
 
 !! test
-Template with just whitespace in it, bug #68421
+Template with just whitespace in it, T70421
 !! wikitext
 {{echo|{{ }}}}
 !! html/parsoid
@@ -10957,26 +11109,59 @@ Template with complex template as argument
 !! end
 
 !! test
-Template with thumb image (with link in description)
+Templates with templated name
 !! wikitext
-{{paramtest|param=[[Image:noimage.png|thumb|[[no link|link]] [[no link|caption]]]]}}
-!! html/php
-This is a test template with parameter <div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/index.php?title=Special:Upload&amp;wpDestFile=Noimage.png" class="new" title="File:Noimage.png">File:Noimage.png</a>  <div class="thumbcaption"><a href="/index.php?title=No_link&amp;action=edit&amp;redlink=1" class="new" title="No link (page does not exist)">link</a> <a href="/index.php?title=No_link&amp;action=edit&amp;redlink=1" class="new" title="No link (page does not exist)">caption</a></div></div></div>
+{{{{echo|echo}}|foo}}
+{{{{echo|inner list}} }}
+!! html
+<p>foo
+</p>
+<ul><li> item 1</li></ul>
 
-!! html+tidy
-<p>This is a test template with parameter</p>
-<div class="thumb tright">
-<div class="thumbinner" style="width:182px;"><a href="/index.php?title=Special:Upload&amp;wpDestFile=Noimage.png" class="new" title="File:Noimage.png">File:Noimage.png</a>
-<div class="thumbcaption"><a href="/index.php?title=No_link&amp;action=edit&amp;redlink=1" class="new" title="No link (page does not exist)">link</a> <a href="/index.php?title=No_link&amp;action=edit&amp;redlink=1" class="new" title="No link (page does not exist)">caption</a></div>
-</div>
-</div>
 !! html/parsoid
-<p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"paramtest","href":"./Template:Paramtest"},"params":{"param":{"wt":"[[Image:noimage.png|thumb|[[no link|link]] [[no link|caption]]]]"}},"i":0}}]}'>This is a test template with parameter </p><figure class="mw-default-size" typeof="mw:Error mw:Image/Thumb" about="#mwt1" data-mw='{"errors":[{"key":"missing-image","message":"This image does not exist."}]}'><a href="./File:Noimage.png" ><img resource="./File:Noimage.png" src="./Special:FilePath/Noimage.png" height="220" width="220"/></a><figcaption><a rel="mw:WikiLink" href="./No_link" title="No link">link</a> <a rel="mw:WikiLink" href="./No_link" title="No link">caption</a></figcaption></figure>
+<p about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"{{echo|echo}}","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</p>
+<ul about="#mwt4" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"{{echo|inner list}} ","href":"./Template:Inner_list"},"params":{},"i":0}}]}'><li> item 1</li></ul>
 !! end
 
-!! article
-Template:complextemplate
-!! text
+# Parsoid markup is deliberate "broken". This is an edge case.
+# See long comment in TemplateHandler.js:convertAttribsToString.
+!! test
+Templates with invalid templated targets
+!! wikitext
+{{echo
+{{echo|foo}}
+}}
+!! html/php
+<p>{{echo
+foo
+}}
+</p>
+!! html/parsoid
+<p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo\n{{echo|foo}}\n"},"params":{},"i":0}}]}'>{{echo
+foo }}</p>
+!! end
+
+!! test
+Template with thumb image (with link in description)
+!! wikitext
+{{paramtest|param=[[Image:noimage.png|thumb|[[no link|link]] [[no link|caption]]]]}}
+!! html/php
+This is a test template with parameter <div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/index.php?title=Special:Upload&amp;wpDestFile=Noimage.png" class="new" title="File:Noimage.png">File:Noimage.png</a>  <div class="thumbcaption"><a href="/index.php?title=No_link&amp;action=edit&amp;redlink=1" class="new" title="No link (page does not exist)">link</a> <a href="/index.php?title=No_link&amp;action=edit&amp;redlink=1" class="new" title="No link (page does not exist)">caption</a></div></div></div>
+
+!! html+tidy
+<p>This is a test template with parameter</p>
+<div class="thumb tright">
+<div class="thumbinner" style="width:182px;"><a href="/index.php?title=Special:Upload&amp;wpDestFile=Noimage.png" class="new" title="File:Noimage.png">File:Noimage.png</a>
+<div class="thumbcaption"><a href="/index.php?title=No_link&amp;action=edit&amp;redlink=1" class="new" title="No link (page does not exist)">link</a> <a href="/index.php?title=No_link&amp;action=edit&amp;redlink=1" class="new" title="No link (page does not exist)">caption</a></div>
+</div>
+</div>
+!! html/parsoid
+<p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"paramtest","href":"./Template:Paramtest"},"params":{"param":{"wt":"[[Image:noimage.png|thumb|[[no link|link]] [[no link|caption]]]]"}},"i":0}}]}'>This is a test template with parameter </p><figure class="mw-default-size" typeof="mw:Error mw:Image/Thumb" about="#mwt1" data-mw='{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}]}'><a href="./File:Noimage.png" ><img resource="./File:Noimage.png" src="./Special:FilePath/Noimage.png" height="220" width="220"/></a><figcaption><a rel="mw:WikiLink" href="./No_link" title="No link">link</a> <a rel="mw:WikiLink" href="./No_link" title="No link">caption</a></figcaption></figure>
+!! end
+
+!! article
+Template:complextemplate
+!! text
 {{{1}}} {{paramtest|
   param ={{{param}}}}}
 !! endarticle
@@ -10993,7 +11178,7 @@ Template with complex arguments
 !! end
 
 !! test
-BUG 553: link with two variables in a piped link
+T2553: link with two variables in a piped link
 !! wikitext
 {|
 |[[{{{1}}}|{{{2}}}]]
@@ -11048,7 +11233,7 @@ Don't abort table cell attribute parsing if wikilink is found in template arg
 |}
 !! html/parsoid
 <table>
-<tbody><tr><td> Test <ref about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"#tag:ref","function":"#tag"},"params":{"1":{"wt":"One two \"[[three]]\" four"}},"i":0}}]}'>One two "<a rel="mw:WikiLink" href="./Three" title="Three">three</a>" four</ref></td></tr>
+<tbody><tr><td> Test <ref about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"#tag:ref","function":"tag"},"params":{"1":{"wt":"One two \"[[three]]\" four"}},"i":0}}]}'>One two "<a rel="mw:WikiLink" href="./Three" title="Three">three</a>" four</ref></td></tr>
 </tbody></table>
 !! end
 
@@ -11154,7 +11339,7 @@ Template:table
 !! endarticle
 
 !! test
-BUG 529: Template with table, not included at beginning of line
+T2529: Template with table, not included at beginning of line
 !! wikitext
 foo {{table}}
 !! html
@@ -11173,7 +11358,7 @@ foo {{table}}
 !! end
 
 !! test
-BUG 523: Template shouldn't eat newline (or add an extra one before table)
+T2523: Template shouldn't eat newline (or add an extra one before table)
 !! wikitext
 foo
 {{table}}
@@ -11193,7 +11378,7 @@ foo
 !! end
 
 !! test
-BUG 41: Template parameters shown as broken links
+T2041: Template parameters shown as broken links
 !! wikitext
 {{{parameter}}}
 !! html
@@ -11203,17 +11388,23 @@ BUG 41: Template parameters shown as broken links
 
 !! test
 Template with targets containing wikilinks
+!! options
+parsoid=wt2html
 !! wikitext
 {{[[foo]]}}
 
 {{[[{{echo|foo}}]]}}
 
 {{{{echo|[[foo}}]]}}
-!! html
+!! html/php
 <p>{{<a href="/wiki/Foo" title="Foo">foo</a>}}
 </p><p>{{<a href="/wiki/Foo" title="Foo">foo</a>}}
 </p><p>{{[[foo}}]]
 </p>
+!! html/parsoid
+<p>{{<a rel="mw:WikiLink" href="./Foo" title="Foo">foo</a>}}</p>
+<p>{{<a typeof="mw:ExpandedAttrs" rel="mw:WikiLink" href="./Foo" title="Foo" data-mw='{"attribs":[[{"txt":"href"},{"html":"&lt;span about=\"#mwt3\" typeof=\"mw:Transclusion\" data-parsoid=&#39;{\"pi\":[[{\"k\":\"1\"}]],\"dsr\":[17,29,null,null]}&#39; data-mw=&#39;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"foo\"}},\"i\":0}}]}&#39;>foo&lt;/span>"}]]}'>foo</a>}}</p>
+<p>{{<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[[foo}}]]"}},"i":0}}]}'>[[foo}}]]</span></p>
 !! end
 
 !! article
@@ -11441,7 +11632,7 @@ Template:Includeonly section
 !!endarticle
 
 !! test
-Bug 6563: Edit link generation for section shown by <includeonly>
+T8563: Edit link generation for section shown by <includeonly>
 !! wikitext
 {{includeonly section}}
 !! html
@@ -11452,7 +11643,7 @@ Bug 6563: Edit link generation for section shown by <includeonly>
 
 # Uses same input as the contents of [[Template:Includeonly section]]
 !! test
-Bug 6563: Section extraction for section shown by <includeonly>
+T8563: Section extraction for section shown by <includeonly>
 !! options
 section=T-2
 !! wikitext
@@ -11465,7 +11656,7 @@ section=T-2
 !! end
 
 !! test
-Bug 6563: Edit link generation for section suppressed by <includeonly>
+T8563: Edit link generation for section suppressed by <includeonly>
 !! wikitext
 <includeonly>
 ==Includeonly section==
@@ -11477,7 +11668,7 @@ Bug 6563: Edit link generation for section suppressed by <includeonly>
 !! end
 
 !! test
-Bug 6563: Section extraction for section suppressed by <includeonly>
+T8563: Section extraction for section suppressed by <includeonly>
 !! options
 section=1
 !! wikitext
@@ -11664,6 +11855,326 @@ parsoid
 
 !!end
 
+###
+### Preprocessor precedence tests
+### See: https://www.mediawiki.org/wiki/Preprocessor_ABNF
+###
+##{{[[-{{{{{{[[Foo|bar}}]]}-}}}}}]]
+!! test
+Preprocessor precedence 1: link is rightmost opening
+!! wikitext
+{{[[Foo|bar}}]]
+
+But close-brace is not a valid character in a link title:
+{{[[Foo}}|bar]]
+
+However, we can still tell this was handled as a link in the preprocessor:
+{{echo|[[Foo}}|bar]]|bat}}
+!! html
+<p>{{<a href="/wiki/Foo" title="Foo">bar}}</a>
+</p><p>But close-brace is not a valid character in a link title:
+{{[[Foo}}|bar]]
+</p><p>However, we can still tell this was handled as a link in the preprocessor:
+[[Foo}}|bar]]
+</p>
+!! end
+
+!! test
+Preprocessor precedence 2: template is rightmost opening
+!! options
+language=zh
+!! wikitext
+-{{echo|foo}-}}-
+!! html
+<p>-foo}--
+</p>
+!! end
+
+!! test
+Preprocessor precedence 3: language converter is rightmost opening
+!! options
+language=zh
+!! wikitext
+{{echo|hi}}
+
+{{-{R|echo|hi}}}-
+
+[[-{R|raw]]}-
+!! html
+<p>hi
+</p><p>{{echo|hi}}
+</p><p>[[raw]]
+</p>
+!! end
+
+!! test
+Preprocessor precedence 4: left-most angle bracket
+!! options
+language=zh
+!! wikitext
+<!--{raw}-->
+!! html
+!! end
+
+!! article
+Template:Precedence5
+!! text
+{{{{{1}}}}}
+!! endarticle
+
+!! test
+Preprocessor precedence 5: tplarg takes precedence over template
+!! wikitext
+{{Precedence5|Bullet}}
+!! html
+<ul><li> Bar</li></ul>
+
+!! end
+
+!! test
+Preprocessor precedence 6: broken link is rightmost opening
+!! wikitext
+{{echo|[[Foo}}
+
+{{echo|[[Foo|bar|bat=baz}}
+!! html
+<p>{{echo|[[Foo}}
+</p><p>{{echo|[[Foo|bar|bat=baz}}
+</p>
+!! end
+
+# This next test exposes a difference between PHP and Parsoid:
+# Given [[Foo|{{echo|Bar]]x}}y]]z:
+# 1) Both PHP and Parsoid ignore the `]]` inside the `echo` in the
+# "preprocessor" stage.  The `{{echo` extends until the `x}}`, and the
+# outer `[[Foo` extends until the `y]]`
+# 2a) But then the PHP preprocessor emits `[[Foo|Bar]]xy]]z` as an
+# intermediate result (after template expansion), and link processing
+# happens on this intermediate result, which moves the wikilink
+# boundary leftward to `[[Foo|Bar]]`
+# 2b) Parsoid works in a single step, so it's going to keep the
+# wikilink as extending to the `y]]`
+# 3a) Then PHP does linktrail processing which slurps up the trailing
+# `xy` inside the link.
+# 3b) Parsoid will do linktrail processing to slurp up the trailing
+# `z` inside the link.
+# This is "correct" behavior.  Parsoid's basic worldview is that the
+# `]]` inside the template shouldn't be allowed to leak out to affect
+# the surrounding wikilink.  PHP may match Parsoid (in the future)
+# if you use {{#balance}} (T114445).
+
+!! test
+Preprocessor precedence 7: broken template is rightmost opening
+!! wikitext
+[[Foo|{{echo|Bar]]
+
+[[Foo|{{echo|Bar]]-x}}-y]]-z
+
+Careful: linktrails can move the end of the wikilink:
+[[Foo|{{echo|y']]a}}l]]l
+!! html
+<p><a href="/wiki/Foo" title="Foo">{{echo|Bar</a>
+</p><p><a href="/wiki/Foo" title="Foo">Bar</a>-x-y]]-z
+</p><p>Careful: linktrails can move the end of the wikilink:
+<a href="/wiki/Foo" title="Foo">y'al</a>]]l
+</p>
+!! end
+
+!! test
+Preprocessor precedence 8: broken language converter is rightmost opening
+!! options
+language=zh
+!! wikitext
+[[Foo-{R|raw]]
+!! html
+<p>[[Foo-{R|raw]]
+</p>
+!! end
+
+!! article
+Template:Preprocessor_precedence_9
+!! text
+;4: {{{{1}}}}
+;5: {{{{{2}}}}}
+;6: {{{{{{3}}}}}}
+;7: {{{{{{{4}}}}}}}
+!! endarticle
+
+!! test
+Preprocessor precedence 9: groups of braces
+!! wikitext
+{{Preprocessor precedence 9|Four|Bullet|1|2}}
+!! html
+<dl><dt>4</dt>
+<dd> {Four}</dd>
+<dt>5</dt>
+<dd> </dd></dl>
+<ul><li> Bar</li></ul>
+<dl><dt>6</dt>
+<dd> Four</dd>
+<dt>7</dt>
+<dd> {Bullet}</dd></dl>
+
+!! end
+
+!! article
+Template:Preprocessor_precedence_10
+!! text
+;1: -{R|raw}-
+;2: -{{Bullet}}-
+;3: -{{{1}}}-
+;4: -{{{{2}}}}-
+;5: -{{{{{3}}}}}-
+;6: -{{{{{{4}}}}}}-
+;7: -{{{{{{{5}}}}}}}-
+!! endarticle
+
+!! test
+Preprocessor precedence 10: groups of braces with leading dash
+!! options
+language=zh
+!! wikitext
+{{Preprocessor precedence 10|Three|raw2|Bullet|1|2}}
+!! html
+<dl><dt>1</dt>
+<dd> raw</dd>
+<dt>2</dt>
+<dd> -</dd></dl>
+<ul><li> Bar-</li></ul>
+<dl><dt>3</dt>
+<dd> -Three-</dd>
+<dt>4</dt>
+<dd> raw2</dd>
+<dt>5</dt>
+<dd> -</dd></dl>
+<ul><li> Bar-</li></ul>
+<dl><dt>6</dt>
+<dd> -Three-</dd>
+<dt>7</dt>
+<dd> raw2</dd></dl>
+
+!! end
+
+!! test
+Preprocessor precedence 11: found during visual diff testing
+!! wikitext
+{{#tag:span|-{{#tag:span|-{{echo|x}}}}}}
+
+{{echo|-{{echo|-{{echo|x}}}}}}
+
+{{echo|-{{echo|x}}}}
+!! html
+<p><span>-<span>-x</span></span>
+</p><p>--x
+</p><p>-x
+</p>
+!! end
+
+!! test
+Preprocessor precedence 12: broken language converter closed by brace.
+!! wikitext
+This form breaks the template, which is unfortunate:
+* {{echo|foo-{bar}bat}}
+
+But if the broken language converter markup is inside an extension
+tag, nothing bad happens:
+* <nowiki>foo-{bar}bat</nowiki>
+* {{echo|<nowiki>foo-{bar}bat</nowiki>}}
+* <pre>foo-{bar}bat</pre>
+* {{echo|<pre>foo-{bar}bat</pre>}}
+
+<tag>foo-{bar}bat</tag>
+{{echo|<tag>foo-{bar}bat</tag>}}
+
+!! html+tidy
+<p>This form breaks the template, which is unfortunate:</p>
+<ul>
+<li>{{echo|foo-{bar}bat}}</li>
+</ul>
+<p>But if the broken language converter markup is inside an extension tag, nothing bad happens:</p>
+<ul>
+<li>foo-{bar}bat</li>
+<li>foo-{bar}bat</li>
+<li>
+<pre>
+foo-{bar}bat
+</pre></li>
+<li>
+<pre>
+foo-{bar}bat
+</pre></li>
+</ul>
+<pre>
+'foo-{bar}bat'
+array (
+)
+</pre>
+<pre>
+'foo-{bar}bat'
+array (
+)
+</pre>
+!! end
+
+!! test
+Preprocessor precedence, 13: broken language converter in external link
+!! wikitext
+* [http://example.com/-{foo Example in URL]
+* [http://example.com Example in -{link} description]
+* {{echo|[http://example.com/-{foo Breaks template, however]}}
+!! html+tidy
+<ul>
+<li><a rel="nofollow" class="external text" href="http://example.com/-{foo">Example in URL</a></li>
+<li><a rel="nofollow" class="external text" href="http://example.com">Example in -{link} description</a></li>
+<li>{{echo|<a rel="nofollow" class="external text" href="http://example.com/-{foo">Breaks template, however</a>}}</li>
+</ul>
+!! end
+
+!! test
+Preprocessor precedence, 14: broken language converter in comment
+!! wikitext
+* <!--{{foo}}--> ...should be ok
+* <!---{{foo}}--> ...extra dashes
+* {{echo|foo<!-- -{bar} -->bat}} ...should be ok
+!! html+tidy
+<ul>
+<li>...should be ok</li>
+<li>...extra dashes</li>
+<li>foobat ...should be ok</li>
+</ul>
+!! end
+
+!! test
+Preprocessor precedence, 15: broken brace markup in headings
+!! wikitext
+__NOTOC__ __NOEDITSECTION__
+===1 foo[bar 1===
+1
+===2 foo[[bar 2===
+2
+===3 foo{bar 3===
+3
+===4 foo{{bar 4===
+4
+===5 foo{{{bar 5===
+5
+===6 foo-{bar 6===
+6
+!! html+tidy
+<h3><span class="mw-headline" id="1_foo.5Bbar_1">1 foo[bar 1</span></h3>
+<p>1</p>
+<h3><span class="mw-headline" id="2_foo.5B.5Bbar_2">2 foo[[bar 2</span></h3>
+<p>2</p>
+<h3><span class="mw-headline" id="3_foo.7Bbar_3">3 foo{bar 3</span></h3>
+<p>3</p>
+<h3><span class="mw-headline" id="4_foo.7B.7Bbar_4">4 foo{{bar 4</span></h3>
+<p>4</p>
+<h3><span class="mw-headline" id="5_foo.7B.7B.7Bbar_5">5 foo{{{bar 5</span></h3>
+<p>5</p>
+<h3><span class="mw-headline" id="6_foo-.7Bbar_6">6 foo-{bar 6</span></h3>
+<p>6</p>
+!! end
+
 ###
 ### Token Stream Patcher tests
 ###
@@ -12240,11 +12751,11 @@ Templates: HTML Tables: 5. Proper fostering of categories from inside
 parsoid=wt2html,wt2wt
 !! wikitext
 <table>[[Category:foo1]]<tr><td>foo</td></tr></table>
-<!--Two categories (Bug 50330)-->
+<!--Two categories (T52330)-->
 <table>[[Category:bar1]][[Category:bar2]]<tr><td>foo</td></tr></table>
 !! html
 <link rel="mw:PageProp/Category" href="./Category:Foo1"><table><tbody><tr><td>foo</td></tr></tbody></table>
-<!--Two categories (Bug 50330)-->
+<!--Two categories (T52330)-->
 <link rel="mw:PageProp/Category" href="./Category:Bar1"><link rel="mw:PageProp/Category" href="./Category:Bar2"><table><tbody><tr><td>foo</td></tr></tbody></table>
 !!end
 
@@ -12556,7 +13067,7 @@ Templates: Ugly templates: 4. newline-only template parameter inconsistency
 </p>
 !! end
 
-# Bug 64017 -- ugly wikitext with fostered content generates two template ranges that
+# T66017 -- ugly wikitext with fostered content generates two template ranges that
 # have a true overlap (T1-start - T2-start - T1-end - T2-end).
 !! test
 Templates: Ugly templates: 5. Template encapsulation test: Non-trivial overlap of template ranges is properly handled
@@ -12570,7 +13081,7 @@ Templates: Ugly templates: 5. Template encapsulation test: Non-trivial overlap o
 </table>
 !! end
 
-# Bug 64017 -- ugly wikitext with fostered content generates two template ranges
+# T66017 -- ugly wikitext with fostered content generates two template ranges
 # that are "identical" and generate nesting cycles in the algorithm
 !! test
 Templates: Ugly templates: 6. Template encapsulation test: Cyclical nesting of template ranges is properly handled
@@ -12661,7 +13172,7 @@ pst
 MediaWiki
 !! end
 
-# This is bug 89, which I fixed. -- wtm
+# This is T2089, which I fixed. -- wtm
 !! test
 pre-save transform: subst: templates with parameters
 !! options
@@ -12679,7 +13190,7 @@ Template:nowikitest
 !! endarticle
 
 !! test
-pre-save transform: nowiki in subst (bug 1188)
+pre-save transform: nowiki in subst (T3188)
 !! options
 pst
 !! wikitext
@@ -12695,7 +13206,7 @@ This template has <!-- a comment --> in it.
 !! endarticle
 
 !! test
-pre-save transform: comment in subst (bug 1936)
+pre-save transform: comment in subst (T3936)
 !! options
 pst
 !! wikitext
@@ -12744,7 +13255,7 @@ Template:dangerous
 !!endarticle
 
 !!test
-(confirming safety of fix for subst bug 1936)
+(confirming safety of fix for subst T3936)
 !! wikitext
 {{Template:dangerous}}
 !! html
@@ -12753,7 +13264,7 @@ Template:dangerous
 !! end
 
 !! test
-pre-save transform: comment containing gallery (bug 5024)
+pre-save transform: comment containing gallery (T7024)
 !! options
 pst
 !! wikitext
@@ -12783,7 +13294,7 @@ pst
 !!end
 
 !! test
-pre-save transform: <noinclude> in subst (bug 3298)
+pre-save transform: <noinclude> in subst (T5298)
 !! options
 pst
 !! wikitext
@@ -12793,7 +13304,7 @@ Foobar
 !! end
 
 !! test
-pre-save transform: <onlyinclude> in subst (bug 3298)
+pre-save transform: <onlyinclude> in subst (T5298)
 !! options
 pst
 !! wikitext
@@ -12815,7 +13326,7 @@ Template:SafeSubstTest
 !! endarticle
 
 !! test
-bug 22297: safesubst: works during PST
+T24297: safesubst: works during PST
 !! options
 pst
 !! wikitext
@@ -12825,7 +13336,7 @@ FoobarFoobar
 !! end
 
 !! test
-bug 22297: safesubst: works during normal parse
+T24297: safesubst: works during normal parse
 !! wikitext
 {{SafeSubstTest}}
 !! html
@@ -12983,7 +13494,7 @@ pst title=[[Ns:Somearticle (IGNORED), Context]]
 !! end
 
 !! test
-pre-save transform: context links ("pipe trick") with full-width parens and no space (Japanese and Chinese style, bug 30149)
+pre-save transform: context links ("pipe trick") with full-width parens and no space (Japanese and Chinese style, T32149)
 !! options
 pst
 !! wikitext
@@ -13003,7 +13514,7 @@ pst
 !! end
 
 !! test
-pre-save transform: context links ("pipe trick") with full-width parens and space (Japanese and Chinese style, bug 30149)
+pre-save transform: context links ("pipe trick") with full-width parens and space (Japanese and Chinese style, T32149)
 !! options
 pst
 !! wikitext
@@ -13023,7 +13534,7 @@ pst
 !! end
 
 !! test
-pre-save transform: context links ("pipe trick") with parens and no space (Korean style, bug 30149)
+pre-save transform: context links ("pipe trick") with parens and no space (Korean style, T32149)
 !! options
 pst
 !! wikitext
@@ -13043,7 +13554,7 @@ pst
 !! end
 
 !! test
-pre-save transform: context links ("pipe trick") with commas (bug 21660)
+pre-save transform: context links ("pipe trick") with commas (T23660)
 !! options
 pst
 !! wikitext
@@ -13062,6 +13573,17 @@ pst
 [[:Bar:Article (context),context|Article]]
 !! end
 
+!! test
+Parsoid: backwards pipe trick
+!! wikitext
+[[|'''bar''']]
+!! html/php
+<p>[[|<b>bar</b>]]
+</p>
+!! html/parsoid
+<p>[[|<b>bar</b>]]</p>
+!! end
+
 !! test
 pre-save transform: trim trailing empty lines
 !! options
@@ -13094,7 +13616,7 @@ pst
 
 
 !! test
-pre-save transform: Signature expansion in nowiki tags (bug 93)
+pre-save transform: Signature expansion in nowiki tags (T2093)
 !! options
 pst disabled
 !! wikitext
@@ -13217,7 +13739,7 @@ msg
 !! end
 
 !! test
-message transform: <noinclude> in transcluded template (bug 4926)
+message transform: <noinclude> in transcluded template (T6926)
 !! options
 msg
 !! wikitext
@@ -13227,7 +13749,7 @@ Foobar
 !! end
 
 !! test
-message transform: <onlyinclude> in transcluded template (bug 4926)
+message transform: <onlyinclude> in transcluded template (T6926)
 !! options
 msg
 !! wikitext
@@ -13349,7 +13871,7 @@ Image with caption
 !! end
 
 !! test
-Image with caption, bug 53312 #1
+Image with caption, T55312 #1
 !! wikitext
 [[File:Foobar.jpg|right|Caption page stuff]]
 !! html/php
@@ -13360,7 +13882,7 @@ Image with caption, bug 53312 #1
 !! end
 
 !! test
-Image with caption, bug 53312 #2
+Image with caption, T55312 #2
 !! wikitext
 [[File:Foobar.jpg|right|Caption page=]]
 !! html/php
@@ -13371,7 +13893,7 @@ Image with caption, bug 53312 #2
 !! end
 
 !! test
-Image with caption, bug 53312 #3
+Image with caption, T55312 #3
 !! wikitext
 [[File:Foobar.jpg|right|Caption page=stuff]]
 !! html/php
@@ -13382,7 +13904,7 @@ Image with caption, bug 53312 #3
 !! end
 
 !! test
-Allow empty links in image captions (Bug 60753)
+Allow empty links in image captions (T62753)
 !! options
 thumbsize=220
 !! wikitext
@@ -13544,7 +14066,7 @@ Image with multiple widths -- use last
 !! end
 
 !! test
-Image with multiple alignments -- use first (bug 48664)
+Image with multiple alignments -- use first (T50664)
 !! options
 thumbsize=220
 !! wikitext
@@ -13579,7 +14101,7 @@ Image with width attribute at different positions
 
 # a sad bit of backward-compatibility
 !! test
-Image with size specified with pxpx (bug 13500, 51628)
+Image with size specified with pxpx (T15500, T53628)
 !! options
 parsoid=wt2html,wt2wt,html2html
 !! wikitext
@@ -13604,7 +14126,7 @@ Image with link parameter, wiki target
 <p><span class="mw-default-size" typeof="mw:Image"><a href="./Main_Page"><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
 
-# parsoid bug 49293 (part 1)
+# parsoid T51293 (part 1)
 !! test
 Image with link parameter, URL target
 !! wikitext
@@ -13616,7 +14138,7 @@ Image with link parameter, URL target
 <p><span class="mw-default-size" typeof="mw:Image"><a href="http://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
 
-# parsoid bug 49293 (part 2)
+# parsoid T51293 (part 2)
 !! test
 Image with link parameter, protocol-less URL target
 !! wikitext
@@ -13741,7 +14263,7 @@ Manually-specified thumbnail image
 !! options
 thumbsize=220
 !! wikitext
-[[File:Foobar.jpg|thumb=Thumb.png|Title]]
+[[File:Foobar.jpg|thumbnail=Thumb.png|Title]]
 !! html/php
 <div class="thumb tright"><div class="thumbinner" style="width:137px;"><a href="/wiki/File:Foobar.jpg"><img alt="" src="http://example.com/images/e/ea/Thumb.png" width="135" height="135" class="thumbimage" /></a>  <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>Title</div></div></div>
 
@@ -14066,7 +14588,7 @@ Add test with existing image page
 !! end
 
 !! test
-bug 18784  Link to non-existent image page with caption should use caption as link text
+T20784  Link to non-existent image page with caption should use caption as link text
 !! wikitext
 [[:Image:test|caption]]
 !! html
@@ -14151,7 +14673,7 @@ parsoid=wt2html,wt2wt,html2html
 !! end
 
 !! test
-BUG 1887: A ISBN with a thumbnail
+T3887: A ISBN with a thumbnail
 !! wikitext
 [[File:Foobar.jpg|thumb|ISBN 1235467890]]
 !! html/php
@@ -14162,7 +14684,7 @@ BUG 1887: A ISBN with a thumbnail
 !! end
 
 !! test
-BUG 1887: A RFC with a thumbnail
+T3887: A RFC with a thumbnail
 !! wikitext
 [[File:Foobar.jpg|thumb|This is RFC 12354]]
 !! html/php
@@ -14173,7 +14695,7 @@ BUG 1887: A RFC with a thumbnail
 !! end
 
 !! test
-BUG 1887: A mailto link with a thumbnail
+T3887: A mailto link with a thumbnail
 !! wikitext
 [[File:Foobar.jpg|thumb|Please mailto:nobody@example.com]]
 !! html/php
@@ -14183,9 +14705,9 @@ BUG 1887: A mailto link with a thumbnail
 <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>Please <a rel="mw:ExtLink" href="mailto:nobody@example.com">mailto:nobody@example.com</a></figcaption></figure>
 !! end
 
-# Pending resolution to bug 368
+# Pending resolution to T2368
 !! test
-BUG 648: Frameless image caption with a link
+T2648: Frameless image caption with a link
 !! wikitext
 [[File:Foobar.jpg|text with a [[link]] in it]]
 !! html/php
@@ -14196,7 +14718,7 @@ BUG 648: Frameless image caption with a link
 !! end
 
 !! test
-BUG 648: Frameless image caption with a link (suffix)
+T2648: Frameless image caption with a link (suffix)
 !! wikitext
 [[File:Foobar.jpg|text with a [[link]]foo in it]]
 !! html/php
@@ -14207,7 +14729,7 @@ BUG 648: Frameless image caption with a link (suffix)
 !! end
 
 !! test
-BUG 648: Frameless image caption with an interwiki link
+T2648: Frameless image caption with an interwiki link
 !! wikitext
 [[File:Foobar.jpg|text with a [[MeatBall:Link]] in it]]
 !! html/php
@@ -14218,7 +14740,7 @@ BUG 648: Frameless image caption with an interwiki link
 !! end
 
 !! test
-BUG 648: Frameless image caption with a piped interwiki link
+T2648: Frameless image caption with a piped interwiki link
 !! wikitext
 [[File:Foobar.jpg|text with a [[MeatBall:Link|link]] in it]]
 !! html/php
@@ -14268,11 +14790,11 @@ Entities in file name and attributes
 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=7%25_solution.gif" class="new" title="File:7% solution.gif">7% solution</a>
 </p>
 !! html/parsoid
-<p><span class="mw-default-size" typeof="mw:Error mw:Image" data-parsoid='{"optList":[{"ck":"bogus","ak":"manualthumb=7%25 solution.gif"},{"ck":"link","ak":"link=7%25 solution"},{"ck":"caption","ak":"[[7%25 solution]]"}]}' data-mw='{"errors":[{"key":"missing-image","message":"This image does not exist."}],"caption":"&lt;a rel=\"mw:WikiLink\" href=\"./7%25_solution\" title=\"7% solution\" data-parsoid=&#39;{\"stx\":\"simple\",\"a\":{\"href\":\"./7%25_solution\"},\"sa\":{\"href\":\"7%25 solution\"},\"dsr\":[74,91,2,2]}&#39;>7% solution&lt;/a>"}'><a href="./7%25_solution" data-parsoid='{"a":{"href":"./7%25_solution"},"sa":{"href":"link=7%25 solution"}}'><img resource="./File:7%25_solution.gif" src="./Special:FilePath/7%25_solution.gif" height="220" width="220" data-parsoid='{"a":{"resource":"./File:7%25_solution.gif","height":"220","width":"220"},"sa":{"resource":"File:7%25 solution.gif"}}'/></a></span></p>
+<p><span class="mw-default-size" typeof="mw:Error mw:Image" data-parsoid='{"optList":[{"ck":"bogus","ak":"manualthumb=7%25 solution.gif"},{"ck":"link","ak":"link=7%25 solution"},{"ck":"caption","ak":"[[7%25 solution]]"}]}' data-mw='{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}],"caption":"&lt;a rel=\"mw:WikiLink\" href=\"./7%25_solution\" title=\"7% solution\" data-parsoid=&#39;{\"stx\":\"simple\",\"a\":{\"href\":\"./7%25_solution\"},\"sa\":{\"href\":\"7%25 solution\"},\"dsr\":[74,91,2,2]}&#39;>7% solution&lt;/a>"}'><a href="./7%25_solution" data-parsoid='{"a":{"href":"./7%25_solution"},"sa":{"href":"link=7%25 solution"}}'><img resource="./File:7%25_solution.gif" src="./Special:FilePath/7%25_solution.gif" height="220" width="220" data-parsoid='{"a":{"resource":"./File:7%25_solution.gif","height":"220","width":"220"},"sa":{"resource":"File:7%25 solution.gif"}}'/></a></span></p>
 !! end
 
 !! test
-BUG 499: Alt text should have &#1234;, not &amp;1234;
+T2499: Alt text should have &#1234;, not &amp;1234;
 !! wikitext
 [[File:Foobar.jpg|&#9792;]]
 !! html/php
@@ -14356,7 +14878,7 @@ and some more text.]]
 !! end
 
 !! test
-Bug 3090: External links other than http: in image captions
+T5090: External links other than http: in image captions
 !! wikitext
 [[File:Foobar.jpg|thumb|200x200px|This caption has [irc://example.net irc] and [https://example.com Secure] ext links in it.]]
 !! html/php
@@ -14435,7 +14957,7 @@ parsoid=wt2html,wt2wt,html2html
 
 # Note that 'right' is the default alignment, despite the misspelled 'righ' below
 !! test
-Invalid image attributes (bug 62500)
+Invalid image attributes (T64500)
 !! options
 thumbsize=220
 parsoid=wt2html,wt2wt,html2html
@@ -14483,7 +15005,7 @@ wgEnableUploads=0
 <p><a href="/wiki/File:Foobaz.jpg" title="File:Foobaz.jpg">File:Foobaz.jpg</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."}]}'><a href="./File:Foobaz.jpg"><img resource="./File:Foobaz.jpg" src="./Special:FilePath/Foobaz.jpg" height="220" width="220"/></a></span></p>
+<p><span class="mw-default-size" typeof="mw:Error mw:Image" data-mw='{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}]}'><a href="./File:Foobaz.jpg"><img resource="./File:Foobaz.jpg" src="./Special:FilePath/Foobaz.jpg" height="220" width="220"/></a></span></p>
 !! end
 
 # Parsoid-specific testing for images
@@ -14804,7 +15326,7 @@ Parsoid: dot-slash prefixed wikilinks
 !! end
 
 !! test
-Render invalid page names as plain text (bug 51090)
+Render invalid page names as plain text (T53090)
 !! wikitext
 [[./../foo|bar]]
 [[foo�|bar]]
@@ -14816,6 +15338,7 @@ Render invalid page names as plain text (bug 51090)
 [[.]]
 [[..]]
 [[foo././bar]]
+[[foo[http://example.com]xyz]]
 
 [[{{echo|./../foo}}|bar]]
 [[{{echo|foo/.}}|bar]]
@@ -14839,6 +15362,7 @@ Render invalid page names as plain text (bug 51090)
 [[.]]
 [[..]]
 [[foo././bar]]
+[[foo<a rel="nofollow" class="external autonumber" href="http://example.com">[1]</a>xyz]]
 </p><p>[[./../foo|bar]]
 [[foo/.|bar]]
 [[foo/..|bar]]
@@ -14861,7 +15385,8 @@ Render invalid page names as plain text (bug 51090)
 [[foo[bar]]
 [[.]]
 [[..]]
-[[foo././bar]]</p>
+[[foo././bar]]
+[[foo<a rel="mw:ExtLink" href="http://example.com"></a>xyz]]</p>
 
 <p>[[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"./../foo"}},"i":0}}]}'>./../foo</span>|bar]]
 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo/."}},"i":0}}]}'>foo/.</span>|bar]]
@@ -14886,7 +15411,7 @@ Disabled subpages
 !! end
 
 !! test
-BUG 561: {{/Subpage}}
+T2561: {{/Subpage}}
 !! options
 subpage title=[[Page]]
 !! wikitext
@@ -15085,7 +15610,7 @@ Bar
 ##
 ## The whitespace on the empty line is part of the test. Please do not delete
 !! test
-1. Categories and newlines: All preceding newlines should be suppressed (courtesy bug 87)
+1. Categories and newlines: All preceding newlines should be suppressed (courtesy T2087)
 !! options
 parsoid=wt2html
 !! wikitext
@@ -15114,7 +15639,7 @@ This
 ##
 ## The whitespace on the empty line is part of the test. Please do not delete
 !! test
-2. Categories and newlines: All preceding newlines should be suppressed (courtesy bug 87)
+2. Categories and newlines: All preceding newlines should be suppressed (courtesy T2087)
 !! options
 parsoid=wt2html
 !! wikitext
@@ -15310,7 +15835,7 @@ parsoid
 !! end
 
 !! test
-Normalize hrefs properly before testing for invalid link targets (bug 70894)
+Normalize hrefs properly before testing for invalid link targets (T72894)
 !! options
 parsoid=html2wt
 !! html/parsoid
@@ -15327,12 +15852,15 @@ Parsoid: Defaultsort
 <meta property="mw:PageProp/categorydefaultsort" content="Foo"/>
 !! end
 
+# NOTE: mw:ExpandedAttrs is not the best typeof here. mw:Transclusion is better.
+# But, this is a limitation of our representation and is documented in
+# TemplateHandler.js in processSpecialMagicWord
 !! test
 Parsoid: Defaultsort (template-generated)
 !! wikitext
 {{{{echo|DEFAULTSORT}}:Foo}}
 !! html/parsoid
-<meta property="mw:PageProp/categorydefaultsort" content="Foo" about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"pi":[[]]}' data-mw='{"parts":[{"template":{"target":{"wt":"{{echo|DEFAULTSORT}}:Foo"},"params":{},"i":0}}]}'/>
+<meta property="mw:PageProp/categorydefaultsort" content="Foo" about="#mwt3" typeof="mw:ExpandedAttrs" data-parsoid='{"src":"{{{{echo|DEFAULTSORT}}:Foo}}","dsr":[0,26,null,null]}' data-mw='{"attribs":[[{"txt":"content"},{"html":"&lt;span about=\"#mwt1\" typeof=\"mw:Transclusion\" data-parsoid=&#39;{\"pi\":[[{\"k\":\"1\"}]],\"dsr\":[2,22,null,null]}&#39; data-mw=&#39;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"DEFAULTSORT\"}},\"i\":0}}]}&#39;>DEFAULTSORT&lt;/span>:Foo"}]]}'/>
 !! end
 
 ###
@@ -15355,7 +15883,7 @@ es:Alimento fr:Nourriture zh:食品
 !! end
 
 !! test
-Duplicate interlanguage links (bug 24502)
+Duplicate interlanguage links (T26502)
 !! options
 ill
 !! wikitext
@@ -15409,7 +15937,7 @@ Section headings with TOC
 Some text
 ===Another headline===
 !! html
-<div id="toc" class="toc"><div id="toctitle"><h2>Contents</h2></div>
+<div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
 <ul>
 <li class="toclevel-1 tocsection-1"><a href="#Headline_1"><span class="tocnumber">1</span> <span class="toctext">Headline 1</span></a>
 <ul>
@@ -15452,7 +15980,7 @@ __FORCETOC__
 == Headline 2 ==
 == Headline ==
 !! html/php
-<div id="toc" class="toc"><div id="toctitle"><h2>Contents</h2></div>
+<div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
 <ul>
 <li class="toclevel-1 tocsection-1"><a href="#Headline_2"><span class="tocnumber">1</span> <span class="toctext">Headline 2</span></a></li>
 <li class="toclevel-1 tocsection-2"><a href="#Headline"><span class="tocnumber">2</span> <span class="toctext">Headline</span></a></li>
@@ -15483,7 +16011,7 @@ Handling of sections up to level 6 and beyond
 ========= Level 9 Heading=========
 ========== Level 10 Heading==========
 !! html
-<div id="toc" class="toc"><div id="toctitle"><h2>Contents</h2></div>
+<div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
 <ul>
 <li class="toclevel-1 tocsection-1"><a href="#Level_1_Heading"><span class="tocnumber">1</span> <span class="toctext">Level 1 Heading</span></a>
 <ul>
@@ -15536,7 +16064,7 @@ TOC regression (T11764)
 == title 2 ==
 === title 2.1 ===
 !! html
-<div id="toc" class="toc"><div id="toctitle"><h2>Contents</h2></div>
+<div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
 <ul>
 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
 <ul>
@@ -15571,7 +16099,7 @@ TOC for heading containing <span id="..."></span> (T96153)
 __FORCETOC__
 ==<span id="old-anchor"></span>New title==
 !! html/php
-<div id="toc" class="toc"><div id="toctitle"><h2>Contents</h2></div>
+<div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
 <ul>
 <li class="toclevel-1 tocsection-1"><a href="#New_title"><span class="tocnumber">1</span> <span class="toctext">New title</span></a></li>
 </ul>
@@ -15582,7 +16110,7 @@ __FORCETOC__
 !! end
 
 !! test
-TOC with wgMaxTocLevel=3 (bug 6204)
+TOC with wgMaxTocLevel=3 (T8204)
 !! options
 wgMaxTocLevel=3
 !! wikitext
@@ -15593,7 +16121,7 @@ wgMaxTocLevel=3
 == title 2 ==
 === title 2.1 ===
 !! html
-<div id="toc" class="toc"><div id="toctitle"><h2>Contents</h2></div>
+<div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
 <ul>
 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
 <ul>
@@ -15619,7 +16147,7 @@ wgMaxTocLevel=3
 !! end
 
 !! test
-TOC with wgMaxTocLevel=3 and two level four headings (bug 6204)
+TOC with wgMaxTocLevel=3 and two level four headings (T8204)
 !! options
 wgMaxTocLevel=3
 !! wikitext
@@ -15629,7 +16157,7 @@ wgMaxTocLevel=3
 ====Section 1.1.1.1====
 ==Section 2==
 !! html
-<div id="toc" class="toc"><div id="toctitle"><h2>Contents</h2></div>
+<div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
 <ul>
 <li class="toclevel-1 tocsection-1"><a href="#Section_1"><span class="tocnumber">1</span> <span class="toctext">Section 1</span></a>
 <ul>
@@ -15661,7 +16189,7 @@ Resolving duplicate section names
 !! end
 
 !! test
-Resolving duplicate section names with differing case (bug 10721)
+Resolving duplicate section names with differing case (T12721)
 !! wikitext
 == Foo bar ==
 == Foo Bar ==
@@ -15722,7 +16250,7 @@ __TOC__
 === title 1.1 ===
 == title 2 ==
 !! html
-<div id="toc" class="toc"><div id="toctitle"><h2>Contents</h2></div>
+<div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
 <ul>
 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
 <ul>
@@ -15740,7 +16268,7 @@ __TOC__
 !! end
 
 !! test
-BUG 1219 URL next to image (good)
+T3219 URL next to image (good)
 !! wikitext
 http://example.com [[File:Foobar.jpg]]
 !! html/php
@@ -15751,7 +16279,7 @@ http://example.com [[File:Foobar.jpg]]
 !!end
 
 !! test
-Short headings with trailing space should match behavior of Parser::doHeadings (bug 19910)
+Short headings with trailing space should match behavior of Parser::doHeadings (T21910)
 !! wikitext
 === 
 The line above must have a trailing space!
@@ -15768,7 +16296,7 @@ But just in case it doesn't...
 !! end
 
 !! test
-Header with special characters (bug 25462)
+Header with special characters (T27462)
 !! wikitext
 The tooltips shall not show entities to the user (ie. be double escaped)
 
@@ -15789,7 +16317,7 @@ section 5
 !! html
 <p>The tooltips shall not show entities to the user (ie. be double escaped)
 </p>
-<div id="toc" class="toc"><div id="toctitle"><h2>Contents</h2></div>
+<div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
 <ul>
 <li class="toclevel-1 tocsection-1"><a href="#text_.3E_text"><span class="tocnumber">1</span> <span class="toctext">text &gt; text</span></a></li>
 <li class="toclevel-1 tocsection-2"><a href="#text_.3C_text"><span class="tocnumber">2</span> <span class="toctext">text &lt; text</span></a></li>
@@ -15848,7 +16376,7 @@ section 6
 !! html
 <p>Id should not contain + for spaces
 </p>
-<div id="toc" class="toc"><div id="toctitle"><h2>Contents</h2></div>
+<div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
 <ul>
 <li class="toclevel-1 tocsection-1"><a href="#Space_between_Text"><span class="tocnumber">1</span> <span class="toctext">Space between Text</span></a></li>
 <li class="toclevel-1 tocsection-2"><a href="#Space-Entity_between_Text"><span class="tocnumber">2</span> <span class="toctext">Space-Entity&#32;between&#32;Text</span></a></li>
@@ -15894,7 +16422,7 @@ Headers with excess '=' characters
 =''italic'' heading==
 ==''italic'' heading=
 !! html
-<div id="toc" class="toc"><div id="toctitle"><h2>Contents</h2></div>
+<div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
 <ul>
 <li class="toclevel-1 tocsection-1"><a href="#foo.3D"><span class="tocnumber">1</span> <span class="toctext">foo=</span></a></li>
 <li class="toclevel-1 tocsection-2"><a href="#.3Dfoo"><span class="tocnumber">2</span> <span class="toctext">=foo</span></a></li>
@@ -15911,7 +16439,7 @@ Headers with excess '=' characters
 !! end
 
 !! test
-HTML headers vs TOC (bug 23393)
+HTML headers vs TOC (T25393)
 (__NOEDITSECTION__ for clearer output, doesn't matter here)
 !! wikitext
 <h1>Header 1</h1>
@@ -15924,7 +16452,7 @@ HTML headers vs TOC (bug 23393)
 == Header 2.2 ==
 __NOEDITSECTION__
 !! html
-<div id="toc" class="toc"><div id="toctitle"><h2>Contents</h2></div>
+<div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
 <ul>
 <li class="toclevel-1"><a href="#Header_1"><span class="tocnumber">1</span> <span class="toctext">Header 1</span></a>
 <ul>
@@ -15968,7 +16496,7 @@ c3-->
 !! end
 
 !! test
-BUG 1219 URL next to image (broken)
+T3219 URL next to image (broken)
 !! wikitext
 http://example.com[[File:Foobar.jpg]]
 !! html/php
@@ -15979,7 +16507,7 @@ http://example.com[[File:Foobar.jpg]]
 !!end
 
 !! test
-Bug 1186 news: in the middle of text
+T3186 news: in the middle of text
 !! wikitext
 http://en.wikinews.org/wiki/Wikinews:Workplace
 !! html
@@ -16237,10 +16765,10 @@ HTML tag with leading space is parsed as text
 !! end
 
 ###
-### Nesting tests (see bug 41545, 50604, 51081)
+### Nesting tests (see T43545, T52604, T53081)
 ###
 
-# This test case is fixed in Parsoid by domino 1.0.12. (bug 50604)
+# This test case is fixed in Parsoid by domino 1.0.12. (T52604)
 # Note that html2wt is considerably more difficult if we use <b> in
 # the test case, instead of <small>
 !! test
@@ -16252,7 +16780,7 @@ Ensure that HTML adoption agency algorithm is properly implemented.
 </p>
 !! end
 
-# This was bug 41545 in the PHP parser.
+# This was T43545 in the PHP parser.
 # Note that tidy doesn't handle this correctly.
 !! test
 Nesting of <kbd>
@@ -16263,9 +16791,9 @@ Nesting of <kbd>
 </p>
 !! end
 
-# The following cases were bug 51081 in the PHP parser.
+# The following cases were T53081 in the PHP parser.
 # Note that there are some other nestable tags (b, i, etc) which are
-# not covered; see bug 51081 for discussion.
+# not covered; see T53081 for discussion.
 
 # Note that tidy doesn't handle this correctly.
 !! test
@@ -16324,18 +16852,22 @@ Nesting of <bdo>
 Media link
 !! wikitext
 [[Media:Foobar.jpg]]
-!! html
+!! html/php
 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">Media:Foobar.jpg</a>
 </p>
+!! html/parsoid
+<p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" title="Foobar.jpg">Media:Foobar.jpg</a></p>
 !! end
 
 !! test
 Media link with text
 !! wikitext
 [[Media:Foobar.jpg|A neat file to look at]]
-!! html
+!! html/php
 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">A neat file to look at</a>
 </p>
+!! html/parsoid
+<p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" title="Foobar.jpg">A neat file to look at</a></p>
 !! end
 
 # FIXME: this is still bad HTML tag nesting
@@ -16344,36 +16876,44 @@ Media link with text
 Media link with nasty text
 !! wikitext
 [[Media:Foobar.jpg|Safe Link<div style=display:none>" onmouseover="alert(document.cookie)" onfoo="</div>]]
-!! html
+!! html/php
 <a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">Safe Link&lt;div style="display:none"&gt;" onmouseover="alert(document.cookie)" onfoo="&lt;/div&gt;</a>
 
-!! html+tidy
+!! html+php/tidy
 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">Safe Link</a></p>
 <div style="display:none">" onmouseover="alert(document.cookie)" onfoo="</div>
+!! html/parsoid
+<p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" title="Foobar.jpg" data-parsoid='{"autoInsertedEnd":true}'>Safe Link</a></p><div style="display:none" data-parsoid='{"stx":"html"}'><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" title="Foobar.jpg" data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'>" onmouseover="alert(document.cookie)" onfoo="</a></div>
+
 !! end
 
 !! test
-Media link to nonexistent file (bug 1702)
+Media link to nonexistent file (T3702)
 !! wikitext
 [[Media:No such.jpg]]
-!! html
+[[Media:No_such file.jpg]]
+!! html/php
 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=No_such.jpg" class="new" title="No such.jpg">Media:No such.jpg</a>
+<a href="/index.php?title=Special:Upload&amp;wpDestFile=No_such_file.jpg" class="new" title="No such file.jpg">Media:No_such file.jpg</a>
 </p>
+!! html/parsoid
+<p><a rel="mw:MediaLink" href="./Special:FilePath/No_such.jpg" title="No such.jpg" typeof="mw:Error" data-mw='{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}]}' data-parsoid='{"a":{"fileName":"No_such.jpg"},"sa":{"fileName":"No such.jpg"}}'>Media:No such.jpg</a>
+<a rel="mw:MediaLink" href="./Special:FilePath/No_such_file.jpg" title="No such file.jpg" typeof="mw:Error" data-mw='{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}]}' data-parsoid='{"a":{"fileName":"No_such_file.jpg"},"sa":{"fileName":"No_such file.jpg"}}'>Media:No_such file.jpg</a></p>
 !! end
 
 !! test
-Image link to nonexistent file (bug 1850 - good)
+Image link to nonexistent file (T3850 - good)
 !! wikitext
 [[File:No_such.jpg]]
 !! html/php
 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=No_such.jpg" class="new" title="File:No such.jpg">File:No such.jpg</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."}]}'><a href="./File:No_such.jpg"><img resource="./File:No_such.jpg" src="./Special:FilePath/No_such.jpg" height="220" width="220"/></a></span></p>
+<p><span class="mw-default-size" typeof="mw:Error mw:Image" data-mw='{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}]}'><a href="./File:No_such.jpg"><img resource="./File:No_such.jpg" src="./Special:FilePath/No_such.jpg" height="220" width="220"/></a></span></p>
 !! end
 
 !! test
-:Image link to nonexistent file (bug 1850 - bad)
+:Image link to nonexistent file (T3850 - bad)
 !! wikitext
 [[:Image:No such.jpg]]
 !! html/php
@@ -16386,7 +16926,7 @@ Image link to nonexistent file (bug 1850 - good)
 
 
 !! test
-Character reference normalization in link text (bug 1938)
+Character reference normalization in link text (T3938)
 !! wikitext
 [[Main Page|this&that]]
 !! html
@@ -16403,7 +16943,7 @@ The page's name is U+05d0 U+05b7, with non-canonical form U+FB2E
 !! endarticle
 
 !! test
-(bug 19451) Links should refer to the normalized form.
+(T21451) Links should refer to the normalized form.
 !! wikitext
 [[&#xFB2E;]]
 [[&#x5d0;&#x5b7;]]
@@ -16420,7 +16960,7 @@ The page's name is U+05d0 U+05b7, with non-canonical form U+FB2E
 !! end
 
 !! test
-Empty attribute crash test (bug 2067)
+Empty attribute crash test (T4067)
 !! wikitext
 <font color="">foo</font>
 !! html
@@ -16429,7 +16969,7 @@ Empty attribute crash test (bug 2067)
 !! end
 
 !! test
-Empty attribute crash test single-quotes (bug 2067)
+Empty attribute crash test single-quotes (T4067)
 !! wikitext
 <font color=''>foo</font>
 !! html
@@ -16488,7 +17028,7 @@ parsoid=wt2html,html2html
 !! end
 
 !! test
-Bug 2095: link with three closing brackets
+T4095: link with three closing brackets
 !! wikitext
 [[Main Page]]]
 !! html/php
@@ -16499,7 +17039,7 @@ Bug 2095: link with three closing brackets
 !! end
 
 !! test
-Bug 2095: link with pipe and three closing brackets
+T4095: link with pipe and three closing brackets
 !! wikitext
 [[Main Page|link]]]
 !! html/php
@@ -16510,7 +17050,7 @@ Bug 2095: link with pipe and three closing brackets
 !! end
 
 !! test
-Bug 2095: link with pipe and three closing brackets, version 2
+T4095: link with pipe and three closing brackets, version 2
 !! wikitext
 [[Main Page|[http://example.com/]]]
 !! html/php
@@ -16544,7 +17084,7 @@ Template:Div style
 !! endarticle
 
 !! test
-Bug 2304: HTML attribute safety (safe template; regression bug 2309)
+T4304: HTML attribute safety (safe template; regression T4309)
 !! wikitext
 <div title="{{test}}"></div>
 !! html/php
@@ -16556,7 +17096,7 @@ Bug 2304: HTML attribute safety (safe template; regression bug 2309)
 
 # Parsoid has enough context to handle this case
 !! test
-Bug 2304: HTML attribute safety (dangerous template; 2309)
+T4304: HTML attribute safety (dangerous template; 2309)
 !! wikitext
 <div title="{{dangerous attribute}}"></div>
 !! html/php
@@ -16567,7 +17107,7 @@ Bug 2304: HTML attribute safety (dangerous template; 2309)
 !! end
 
 !! test
-Bug 2304: HTML attribute safety (dangerous style template; 2309)
+T4304: HTML attribute safety (dangerous style template; 2309)
 !! wikitext
 <div style="{{dangerous style attribute}}"></div>
 !! html/php
@@ -16578,7 +17118,7 @@ Bug 2304: HTML attribute safety (dangerous style template; 2309)
 !! end
 
 !! test
-Bug 2304: HTML attribute safety (safe parameter; 2309)
+T4304: HTML attribute safety (safe parameter; 2309)
 !! wikitext
 {{div style|width: 200px}}
 !! html/php
@@ -16589,7 +17129,7 @@ Bug 2304: HTML attribute safety (safe parameter; 2309)
 !! end
 
 !! test
-Bug 2304: HTML attribute safety (unsafe parameter; 2309)
+T4304: HTML attribute safety (unsafe parameter; 2309)
 !! wikitext
 {{div style|width: expression(alert(document.cookie))}}
 !! html/php
@@ -16601,7 +17141,7 @@ Bug 2304: HTML attribute safety (unsafe parameter; 2309)
 
 ## Parsoid output here differs; needs investigation.
 !! test
-Bug 2304: HTML attribute safety (unsafe breakout parameter; 2309)
+T4304: HTML attribute safety (unsafe breakout parameter; 2309)
 !! wikitext
 {{div style|"><script>alert(document.cookie)</script>}}
 !! html
@@ -16611,7 +17151,7 @@ Bug 2304: HTML attribute safety (unsafe breakout parameter; 2309)
 
 ## Parsoid output here differs; needs investigation.
 !! test
-Bug 2304: HTML attribute safety (unsafe breakout parameter 2; 2309)
+T4304: HTML attribute safety (unsafe breakout parameter 2; 2309)
 !! wikitext
 {{div style|" ><script>alert(document.cookie)</script>}}
 !! html
@@ -16620,7 +17160,7 @@ Bug 2304: HTML attribute safety (unsafe breakout parameter 2; 2309)
 !! end
 
 !! test
-Bug 2304: HTML attribute safety (link)
+T4304: HTML attribute safety (link)
 !! wikitext
 <div title="[[Main Page]]"></div>
 !! html
@@ -16629,7 +17169,7 @@ Bug 2304: HTML attribute safety (link)
 !! end
 
 !! test
-Bug 2304: HTML attribute safety (italics)
+T4304: HTML attribute safety (italics)
 !! wikitext
 <div title="''foobar''"></div>
 !! html
@@ -16638,7 +17178,7 @@ Bug 2304: HTML attribute safety (italics)
 !! end
 
 !! test
-Bug 2304: HTML attribute safety (bold)
+T4304: HTML attribute safety (bold)
 !! wikitext
 <div title="'''foobar'''"></div>
 !! html
@@ -16647,7 +17187,7 @@ Bug 2304: HTML attribute safety (bold)
 !! end
 
 !! test
-Bug 2304: HTML attribute safety (ISBN)
+T4304: HTML attribute safety (ISBN)
 !! wikitext
 <div title="ISBN 1234567890"></div>
 !! html
@@ -16656,7 +17196,7 @@ Bug 2304: HTML attribute safety (ISBN)
 !! end
 
 !! test
-Bug 2304: HTML attribute safety (RFC)
+T4304: HTML attribute safety (RFC)
 !! wikitext
 <div title="RFC 1234"></div>
 !! html
@@ -16665,7 +17205,7 @@ Bug 2304: HTML attribute safety (RFC)
 !! end
 
 !! test
-Bug 2304: HTML attribute safety (PMID)
+T4304: HTML attribute safety (PMID)
 !! wikitext
 <div title="PMID 1234567890"></div>
 !! html
@@ -16674,7 +17214,7 @@ Bug 2304: HTML attribute safety (PMID)
 !! end
 
 !! test
-Bug 2304: HTML attribute safety (web link)
+T4304: HTML attribute safety (web link)
 !! wikitext
 <div title="http://example.com/"></div>
 !! html
@@ -16683,7 +17223,7 @@ Bug 2304: HTML attribute safety (web link)
 !! end
 
 !! test
-Bug 2304: HTML attribute safety (named web link)
+T4304: HTML attribute safety (named web link)
 !! wikitext
 <div title="[http://example.com/ link]"></div>
 !! html
@@ -16692,7 +17232,7 @@ Bug 2304: HTML attribute safety (named web link)
 !! end
 
 !! test
-Bug 3244: HTML attribute safety (extension; safe)
+T5244: HTML attribute safety (extension; safe)
 !! wikitext
 <div style="<nowiki>background:blue</nowiki>"></div>
 !! html/php
@@ -16703,7 +17243,7 @@ Bug 3244: HTML attribute safety (extension; safe)
 !! end
 
 !! test
-Bug 3244: HTML attribute safety (extension; unsafe)
+T5244: HTML attribute safety (extension; unsafe)
 !! wikitext
 <div style="<nowiki>border-left:expression(alert(document.cookie))</nowiki>"></div>
 !! html/php
@@ -16760,7 +17300,7 @@ MSIE CSS safety test: comment in expression
 !! end
 
 !! test
-CSS safety test (all browsers): vertical tab (bug 55332 / CVE-2013-4567)
+CSS safety test (all browsers): vertical tab (T57332 / CVE-2013-4567)
 !! wikitext
 <p style="font-size: 100px; background-image:url\b(https://www.google.com/images/srpr/logo6w.png)">A</p>
 !! html/php
@@ -16771,7 +17311,7 @@ CSS safety test (all browsers): vertical tab (bug 55332 / CVE-2013-4567)
 !! end
 
 !! test
-MSIE 6 CSS safety test: Fullwidth (bug 55332)
+MSIE 6 CSS safety test: Fullwidth (T57332)
 !! wikitext
 <p style="font-size: 100px; color: expression((title='XSSed'),'red')">A</p>
 <div style="top:EXPRESSION(alert())">B</div>
@@ -16785,7 +17325,7 @@ MSIE 6 CSS safety test: Fullwidth (bug 55332)
 !! end
 
 !! test
-MSIE 6 CSS safety test: IPA extensions (bug 55332)
+MSIE 6 CSS safety test: IPA extensions (T57332)
 !! wikitext
 <div style="background-image:uʀʟ(javascript:alert())">A</div>
 <p style="font-size: 100px; color: expʀessɪoɴ((title='XSSed'),'red')">B</p>
@@ -16799,7 +17339,7 @@ MSIE 6 CSS safety test: IPA extensions (bug 55332)
 !! end
 
 !! test
-MSIE 6 CSS safety test: sup/sub script (bug 55332)
+MSIE 6 CSS safety test: sup/sub script (T57332)
 !! wikitext
 <div style="background-image:url⁽javascript:alert())">A</div>
 <div style="background-image:url₍javascript:alert())">B</div>
@@ -16831,7 +17371,7 @@ style="-o-link:attr(title);-o-link-source:current">X</div>
 !! end
 
 !! test
-MSIE 6 CSS safety test: Repetition markers (bug 55332)
+MSIE 6 CSS safety test: Repetition markers (T57332)
 !! wikitext
 <p style="font-size: 100px; color: expres〱ion((title='XSSed'),'red')">A</p>
 <p style="font-size: 100px; color: expresゝion((title='XSSed'),'red')">B</p>
@@ -16912,7 +17452,7 @@ Template:Identity
 !! endarticle
 
 !! test
-Expansion of multi-line templates in attribute values (bug 6255)
+Expansion of multi-line templates in attribute values (T8255)
 !! wikitext
 <div style="background: {{identity|#00FF00}}">-</div>
 !! html
@@ -16921,20 +17461,20 @@ Expansion of multi-line templates in attribute values (bug 6255)
 !! end
 
 !! test
-Expansion of multi-line templates in attribute values (bug 6255 sanity check)
+Expansion of multi-line templates in attribute values (T8255 sanity check)
 !! wikitext
-<div style="background: 
+<div style="background:
 #00FF00">-</div>
 !! html/php
 <div style="background: #00FF00">-</div>
 
 !! html/parsoid
-<div style="background: 
+<div style="background:
 #00FF00">-</div>
 !! end
 
 !! test
-Expansion of multi-line templates in attribute values (bug 6255 sanity check 2)
+Expansion of multi-line templates in attribute values (T8255 sanity check 2)
 !! wikitext
 <div style="background: &#10;#00FF00">-</div>
 !! html
@@ -17110,7 +17650,7 @@ array (
 !! end
 
 !! test
-Parser hook: argument containing a forward slash (bug 5344)
+Parser hook: argument containing a forward slash (T7344)
 !! wikitext
 <tag filename="/tmp/bla"></tag>
 !! html/php
@@ -17127,7 +17667,7 @@ array (
 
 ## Don't expect parsoid to rt this form.
 !! test
-Parser hook: empty input using terminated empty elements (bug 2374)
+Parser hook: empty input using terminated empty elements (T4374)
 !! options
 parsoid=wt2html,html2html
 !! wikitext
@@ -17147,7 +17687,7 @@ array (
 ## </tag> should be output literally since there is no matching tag that begins it
 ## Don't expect parsoid to rt this form.
 !! test
-Parser hook: basic arguments using terminated empty elements (bug 2374)
+Parser hook: basic arguments using terminated empty elements (T4374)
 !! options
 parsoid=wt2html
 !! wikitext
@@ -17311,7 +17851,7 @@ Sanitizer: Escaping of spaces, multibyte characters, colons & other stuff in id=
 # In HTML5, the restrictions are that id must contain at least one character,
 # and must not contain any space characters.
 !! test
-Sanitizer: Validating the contents of the id attribute (bug 4515)
+Sanitizer: Validating the contents of the id attribute (T6515)
 !! options
 disabled
 !! wikitext
@@ -17322,7 +17862,7 @@ Something ...
 
 # In HTML5, id must be unique amongst all the ids in the element's home subtree.
 !! test
-Sanitizer: Validating id attribute uniqueness (bug 4515, bug 6301)
+Sanitizer: Validating id attribute uniqueness (T6515, T8301)
 !! options
 disabled
 !! wikitext
@@ -17347,16 +17887,16 @@ Sanitizer: Validating that <meta> and <link> work, but only for Microdata
 <p>    <meta itemprop="hello" content="world" />
        &lt;meta http-equiv="refresh" content="5"&gt;
        <meta itemprop="hello" content="5" />
-</p>
        <link itemprop="hello" href="http&#58;//example.org" />
        &lt;link rel="stylesheet" href="<a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>"&gt;
        <link itemprop="hello" href="http&#58;//example.org" />
+</p>
 </div>
 
 !! end
 
 !! test
-Language converter: output gets cut off unexpectedly (bug 5757)
+Language converter: output gets cut off unexpectedly (T7757)
 !! options
 language=zh
 !! wikitext
@@ -17376,15 +17916,13 @@ all additional text is vanished
 !! end
 
 !! test
-Self closed html pairs (bug 5487)
-!! options
+Self closed html pairs (T7487)
 !! wikitext
 <center><font id="bug" />Centered text</center>
 <div><font id="bug2" />In div text</div>
-!! html
-<center>&lt;font id="bug" /&gt;Centered text</center>
-<div>&lt;font id="bug2" /&gt;In div text</div>
-
+!! html+tidy
+<center><font id="bug"></font>Centered text</center>
+<div><font id="bug2"></font>In div text</div>
 !! end
 
 #
@@ -17401,7 +17939,7 @@ C'est grave !
 !! end
 
 !! test
-Punctuation: CSS !important (bug 11874)
+Punctuation: CSS !important (T13874)
 !! wikitext
 <div style="width:50% !important">important</div>
 !! html
@@ -17410,7 +17948,7 @@ Punctuation: CSS !important (bug 11874)
 !!end
 
 !! test
-Punctuation: CSS ! important (bug 11874; with space after)
+Punctuation: CSS ! important (T13874; with space after)
 !! wikitext
 <div style="width:50% ! important">important</div>
 !! html
@@ -17419,7 +17957,7 @@ Punctuation: CSS ! important (bug 11874; with space after)
 !!end
 
 !! test
-HTML bullet list, closed tags (bug 5497)
+HTML bullet list, closed tags (T7497)
 !! wikitext
 <ul>
 <li>One</li>
@@ -17440,7 +17978,7 @@ HTML bullet list, closed tags (bug 5497)
 !! end
 
 !! test
-HTML bullet list, unclosed tags (bug 5497)
+HTML bullet list, unclosed tags (T7497)
 !! wikitext
 <ul>
 <li>One
@@ -17460,7 +17998,7 @@ HTML bullet list, unclosed tags (bug 5497)
 !! end
 
 !! test
-HTML ordered list, closed tags (bug 5497)
+HTML ordered list, closed tags (T7497)
 !! wikitext
 <ol>
 <li>One</li>
@@ -17481,7 +18019,7 @@ HTML ordered list, closed tags (bug 5497)
 !! end
 
 !! test
-HTML ordered list, unclosed tags (bug 5497)
+HTML ordered list, unclosed tags (T7497)
 !! options
 !! wikitext
 <ol>
@@ -17502,7 +18040,7 @@ HTML ordered list, unclosed tags (bug 5497)
 !! end
 
 !! test
-HTML nested bullet list, closed tags (bug 5497)
+HTML nested bullet list, closed tags (T7497)
 !! wikitext
 <ul>
 <li>One</li>
@@ -17537,7 +18075,7 @@ HTML nested bullet list, closed tags (bug 5497)
 !! end
 
 !! test
-HTML nested bullet list, open tags (bug 5497)
+HTML nested bullet list, open tags (T7497)
 !! wikitext
 <ul>
 <li>One
@@ -17574,7 +18112,7 @@ HTML nested bullet list, open tags (bug 5497)
 !! end
 
 !! test
-HTML nested ordered list, closed tags (bug 5497)
+HTML nested ordered list, closed tags (T7497)
 !! wikitext
 <ol>
 <li>One</li>
@@ -17599,7 +18137,7 @@ HTML nested ordered list, closed tags (bug 5497)
 !! end
 
 !! test
-HTML nested ordered list, open tags (bug 5497)
+HTML nested ordered list, open tags (T7497)
 !! wikitext
 <ol>
 <li>One
@@ -17646,9 +18184,9 @@ HTML ordered list item with parameters oddity
 
 !! end
 
-# parsoid doesn't explicitly mark autonumbered links, see bug 53505
+# parsoid doesn't explicitly mark autonumbered links, see T55505
 !!test
-bug 5918: autonumbering
+T7918: autonumbering
 !! wikitext
 [http://first/] [http://second] [ftp://ftp]
 
@@ -17702,7 +18240,7 @@ Fuzz testing: Parser14
 http://__TOC__
 !! html
 <h2><span class="mw-headline" id="onmouseover.3D">onmouseover=</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: onmouseover=">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
-http://<div id="toc" class="toc"><div id="toctitle"><h2>Contents</h2></div>
+http://<div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
 <ul>
 <li class="toclevel-1 tocsection-1"><a href="#onmouseover.3D"><span class="tocnumber">1</span> <span class="toctext">onmouseover=</span></a></li>
 </ul>
@@ -17713,7 +18251,7 @@ http://<div id="toc" class="toc"><div id="toctitle"><h2>Contents</h2></div>
 <h2><span class="mw-headline" id="onmouseover.3D">onmouseover=</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: onmouseover=">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
 <p>http://</p>
 <div id="toc" class="toc">
-<div id="toctitle">
+<div class="toctitle">
 <h2>Contents</h2>
 </div>
 <ul>
@@ -17838,8 +18376,8 @@ MOVE YOUR MOUSE CURSOR OVER THIS TEXT
 
 !! html/parsoid
 <p data-parsoid='{"fostered":true,"autoInsertedEnd":true}'>{{{|
-<u class="|" about="#mwt2" typeof="mw:ExpandedAttrs" data-parsoid='{"stx":"html","a":{"{{{{SSSll!!!!!!!VVVV)]]][[Special:*xxxxxxx-->&lt;noinclude>}}}}":null},"sa":{"{{{{SSSll!!!!!!!VVVV)]]][[Special:*xxxxxxx-->&lt;noinclude>}}}}":""},"autoInsertedEnd":true}' data-mw='{"attribs":[[{"txt":"{{{{SSSll!!!!!!!VVVV)]]][[Special:*xxxxxxx-->}}}}","html":"{&lt;span about=\"#mwt1\" typeof=\"mw:Param\" data-parsoid=&#39;{\"pi\":[[]],\"dsr\":[21,79,null,null]}&#39; data-mw=&#39;{\"parts\":[{\"templatearg\":{\"target\":{\"wt\":\"SSSll!!!!!!!VVVV)]]][[Special:*xxxxxxx-->&amp;lt;noinclude>\"},\"params\":{},\"i\":0}}]}&#39;>{{{SSSll!!!!!!!VVVV)]]][[Special:*xxxxxxx-->}}}&lt;/span>}"},{"html":""}]]}'>
-<br style="onmouseover='alert(document.cookie);' " data-parsoid='{"stx":"html","selfClose":true}'/></u></p><p data-parsoid='{"fostered":true,"autoInsertedEnd":true}'><u class="|" about="#mwt2" typeof="mw:ExpandedAttrs" data-parsoid='{"stx":"html","a":{"{{{{SSSll!!!!!!!VVVV)]]][[Special:*xxxxxxx-->&lt;noinclude>}}}}":null},"sa":{"{{{{SSSll!!!!!!!VVVV)]]][[Special:*xxxxxxx-->&lt;noinclude>}}}}":""},"autoInsertedEnd":true,"autoInsertedStart":true}' data-mw='{"attribs":[[{"txt":"{{{{SSSll!!!!!!!VVVV)]]][[Special:*xxxxxxx-->}}}}","html":"{&lt;span about=\"#mwt1\" typeof=\"mw:Param\" data-parsoid=&#39;{\"pi\":[[]],\"dsr\":[21,79,null,null]}&#39; data-mw=&#39;{\"parts\":[{\"templatearg\":{\"target\":{\"wt\":\"SSSll!!!!!!!VVVV)]]][[Special:*xxxxxxx-->&amp;lt;noinclude>\"},\"params\":{},\"i\":0}}]}&#39;>{{{SSSll!!!!!!!VVVV)]]][[Special:*xxxxxxx-->}}}&lt;/span>}"},{"html":""}]]}'>MOVE YOUR MOUSE CURSOR OVER THIS TEXT</u></p><table data-parsoid='{"autoInsertedEnd":true}'>
+<u class="|" data-parsoid='{"stx":"html","a":{"{{{{SSSll!!!!!!!VVVV)]]][[Special:*xxxxxxx--":null},"sa":{"{{{{SSSll!!!!!!!VVVV)]]][[Special:*xxxxxxx--":""},"autoInsertedEnd":true}'><meta typeof="mw:Includes/NoInclude" data-parsoid='{"src":"&lt;noinclude>"}'/>}}}} >
+<br style="onmouseover='alert(document.cookie);' " data-parsoid='{"stx":"html","selfClose":true}'/></u></p><p data-parsoid='{"fostered":true,"autoInsertedEnd":true}'><u class="|" data-parsoid='{"stx":"html","a":{"{{{{SSSll!!!!!!!VVVV)]]][[Special:*xxxxxxx--":null},"sa":{"{{{{SSSll!!!!!!!VVVV)]]][[Special:*xxxxxxx--":""},"autoInsertedEnd":true,"autoInsertedStart":true}'>MOVE YOUR MOUSE CURSOR OVER THIS TEXT</u></p><table data-parsoid='{"autoInsertedEnd":true}'>
 
 
 
@@ -17855,7 +18393,7 @@ MOVE YOUR MOUSE CURSOR OVER THIS TEXT
 # <li class="&#124;&#124;">
 # }}}blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b>
 !!test
-Fuzz testing: Parser25 (bug 6055)
+Fuzz testing: Parser25 (T8055)
 !! wikitext
 {{{
 | 
@@ -17892,7 +18430,7 @@ http://example.com<nowiki>junk</nowiki>
 <p><a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a><span typeof="mw:Nowiki">junk</span></p>
 !! end
 
-!!test
+!! test
 Fuzz testing: URL adjacent extension (no space, dirty; pre)
 !! wikitext
 http://example.com<pre>junk</pre>
@@ -17905,10 +18443,10 @@ http://example.com<pre>junk</pre>
 junk
 </pre>
 !! html/parsoid
-<p><a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a></p><pre data-parsoid='{"stx":"html"}'>junk</pre>
-!!end
+<p><a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a></p><pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"junk"}}'>junk</pre>
+!! end
 
-!!test
+!! test
 Fuzz testing: image with bogus manual thumbnail
 !! wikitext
 [[Image:foobar.jpg|thumbnail= ]]
@@ -17916,20 +18454,22 @@ Fuzz testing: image with bogus manual thumbnail
 <div class="thumb tright"><div class="thumbinner" style="width:182px;">Error creating thumbnail:   <div class="thumbcaption"></div></div></div>
 
 !! html/parsoid
-<figure class="mw-default-size" typeof="mw:Error mw:Image/Thumb" data-parsoid='{"optList":[{"ck":"manualthumb","ak":"thumbnail= "}]}' data-mw='{"errors":[{"key":"missing-thumbnail","message":"This thumbnail does not exist.","params":{"name":""}}],"thumb":""}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{}}'><img resource="./File:Foobar.jpg" src="./Special:FilePath/" height="220" width="220" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"220","width":"220"},"sa":{"resource":"Image:foobar.jpg"}}'/></a></figure>
-!!end
+<figure class="mw-default-size" typeof="mw:Error mw:Image/Thumb" data-parsoid='{"optList":[{"ck":"manualthumb","ak":"thumbnail= "}]}' data-mw='{"errors":[{"key":"apierror-invalidtitle","message":"Invalid thumbnail title.","params":{"name":""}}],"thumb":""}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{"href":"Image:foobar.jpg"}}'><img resource="./File:Foobar.jpg" src="./Special:FilePath/Foobar.jpg" height="220" width="220" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"220","width":"220"},"sa":{"resource":"Image:foobar.jpg"}}'/></a></figure>
+!! end
 
 !! test
-Fuzz testing: encoded newline in generated HTML replacements (bug 6577)
+Fuzz testing: encoded newline in generated HTML replacements (T8577)
 !! wikitext
 <pre dir="&#10;"></pre>
-!! html
+!! html/php
 <pre dir="&#10;"></pre>
 
+!! html/parsoid
+<pre typeof="mw:Extension/pre" about="#mwt2" dir="&amp;#10;" data-mw='{"name":"pre","attrs":{"dir":"&amp;#10;"},"body":{"extsrc":""}}'></pre>
 !! end
 
 !! test
-Parsing optional HTML elements (Bug 6171)
+Parsing optional HTML elements (T8171)
 !! options
 !! wikitext
 <table>
@@ -17951,7 +18491,7 @@ Parsing optional HTML elements (Bug 6171)
 !! end
 
 !! test
-Correct handling of <td>, <tr> (Bug 6171)
+Correct handling of <td>, <tr> (T8171)
 !! options
 !! wikitext
 <table>
@@ -18047,7 +18587,7 @@ Special page transclusion
 !! end
 
 !! test
-Special page transclusion twice (bug 5021)
+Special page transclusion twice (T7021)
 !! options
 !! wikitext
 {{Special:Prefixindex/Xyzzyx}}
@@ -18428,7 +18968,7 @@ section=2
 ==b==
 !! end
 
-# Formerly testing for bug 2587, now resolved by the use of unmarked sections
+# Formerly testing for T4587, now resolved by the use of unmarked sections
 # instead of respecting commented sections
 !! test
 Section extraction prefixed by comment (section 1)
@@ -18452,7 +18992,7 @@ section=2
 
 !!end
 
-# Formerly testing for bug 2607, now resolved by the use of unmarked sections
+# Formerly testing for T4607, now resolved by the use of unmarked sections
 # instead of respecting HTML-style headings
 !! test
 Section extraction, mixed wiki and html (section 1)
@@ -18487,7 +19027,7 @@ two
 !! end
 
 
-# Formerly testing for bug 3342
+# Formerly testing for T5342
 !! test
 Section extraction, heading surrounded by <noinclude>
 !! options
@@ -18499,7 +19039,7 @@ section=1
 ==marked==
 !!end
 
-# Test behavior of bug 19910
+# Test behavior of T21910
 !! test
 Sectiion with all-equals
 !! options
@@ -18847,7 +19387,7 @@ xxx
 !! end
 
 !! test
-Section replacement test with initial whitespace (bug 13728)
+Section replacement test with initial whitespace (T15728)
 !! options
 replace=2,"xxx"
 !! wikitext
@@ -18862,7 +19402,7 @@ xxx
 
 
 !! test
-Section extraction, heading followed by pre with 20 spaces (bug 6398)
+Section extraction, heading followed by pre with 20 spaces (T8398)
 !! options
 section=1
 !! wikitext
@@ -18874,7 +19414,7 @@ section=1
 !! end
 
 !! test
-Section extraction, heading followed by pre with 19 spaces (bug 6398 sanity check)
+Section extraction, heading followed by pre with 19 spaces (T8398 sanity check)
 !! options
 section=1
 !! wikitext
@@ -18887,7 +19427,7 @@ section=1
 
 
 !! test
-Section extraction, <pre> around bogus header (bug 10309)
+Section extraction, <pre> around bogus header (T12309)
 !! options
 section=2
 !! wikitext
@@ -18904,7 +19444,7 @@ stuff
 !! end
 
 !! test
-Section replacement, <pre> around bogus header (bug 10309)
+Section replacement, <pre> around bogus header (T12309)
 !! options
 replace=2,"xxx"
 !! wikitext
@@ -19004,9 +19544,8 @@ Special:Search page linking.
 | is not a magic word here but | is still a magic word here
 </p>
 !! html/parsoid
-<p><span about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"pi":[[]]}' data-mw='{"parts":[{"template":{"target":{"wt":"!","href":"./Template:!"},"params":{},"i":0}}]}'>|</span> is a magic word there and <span about="#mwt2" typeof="mw:Transclusion" data-parsoid='{"pi":[[]]}' data-mw='{"parts":[{"template":{"target":{"wt":"!","href":"./Template:!"},"params":{},"i":0}}]}'>|</span> is still a magic word here
-| is not a magic word here but <span about="#mwt3" typeof="mw:Transclusion" data-parsoid='{"pi":[[]]}' data-mw='{"parts":[{"template":{"target":{"wt":"!","href":"./Template:!"},"params":{},"i":0}}]}'>|</span> is still a magic word here</p>
-
+<p><span about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"pi":[[]]}' data-mw='{"parts":[{"template":{"target":{"wt":"!","function":"!"},"params":{},"i":0}}]}'>|</span> is a magic word there and <span about="#mwt2" typeof="mw:Transclusion" data-parsoid='{"pi":[[]]}' data-mw='{"parts":[{"template":{"target":{"wt":"!","function":"!"},"params":{},"i":0}}]}'>|</span> is still a magic word here
+| is not a magic word here but <span about="#mwt3" typeof="mw:Transclusion" data-parsoid='{"pi":[[]]}' data-mw='{"parts":[{"template":{"target":{"wt":"!","function":"!"},"params":{},"i":0}}]}'>|</span> is still a magic word here</p>
 !! end
 
 !! test
@@ -19063,6 +19602,27 @@ title=[[Parser test]]
 !! end
 ### Note: Above tests excludes the "{{NUMBEROFADMINS}}" magic word because it generates a MySQL error when included.
 
+!! test
+Gallery with valid attributes
+!! wikitext
+<gallery type="123" summary="345">
+File:File:Foobar.jpg
+</gallery>
+!! html/php
+<ul class="gallery mw-gallery-traditional" type="123">
+               <li class="gallerybox" style="width: 155px"><div style="width: 155px">
+                       <div class="thumb" style="height: 150px;">File:Foobar.jpg</div>
+                       <div class="gallerytext">
+                       </div>
+               </div></li>
+</ul>
+
+!! html/parsoid
+<ul class="gallery mw-gallery-traditional" type="123" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{"type":"123","summary":"345"},"body":{"extsrc":"\nFile:File:Foobar.jpg\n"}}'>
+<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span style="vertical-align: middle; display: inline-block;">File:File:Foobar.jpg</span></div><div class="gallerytext"></div></li>
+</ul>
+!! end
+
 ## Parsoid thinks the "centre" here is a property, not a caption.
 !! test
 Gallery
@@ -19608,23 +20168,73 @@ File:Test.png
 !! end
 
 !! test
-HTML Hex character encoding (spells the word "JavaScript")
+Gallery with class and style attributes
 !! options
-parsoid=wt2html,wt2wt,html2html
+parsoid={
+  "nativeGallery": true
+}
 !! wikitext
-&#x4A;&#x061;&#x0076;&#x00061;&#x000053;&#x0000063;&#114;&#x0000069;&#00000112;&#x0000000074;
+<gallery class="center" style="text-align: center;">
+File:Foobar.jpg
+</gallery>
 !! html/php
-<p>&#x4a;&#x61;&#x76;&#x61;&#x53;&#x63;&#114;&#x69;&#112;&#x74;
-</p>
-!! html/php+tidy
-<p>JavaScript</p>
+<ul class="gallery mw-gallery-traditional center" style="text-align: center;">
+               <li class="gallerybox" style="width: 155px"><div style="width: 155px">
+                       <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div>
+                       <div class="gallerytext">
+                       </div>
+               </div></li>
+</ul>
+
 !! html/parsoid
-<p><span typeof="mw:Entity">J</span><span typeof="mw:Entity">a</span><span typeof="mw:Entity">v</span><span typeof="mw:Entity">a</span><span typeof="mw:Entity">S</span><span typeof="mw:Entity">c</span><span typeof="mw:Entity">r</span><span typeof="mw:Entity">i</span><span typeof="mw:Entity">p</span><span typeof="mw:Entity">t</span></p>
+<ul class="gallery mw-gallery-traditional center" style="text-align: center;" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{"class":"center","style":"text-align: center;"},"body":{}}'>
+<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span typeof="mw:Image" style="vertical-align: middle; display: inline-block;"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></span></div><div class="gallerytext"></div></li>
+</ul>
 !! end
 
 !! test
-HTML Hex character encoding bogus encoding (bug 26437 regression check)
-!! wikitext
+Gallery in slideshow mode
+!! options
+parsoid={
+  "nativeGallery": true
+}
+!! wikitext
+<gallery mode="slideshow" showthumbnails="">
+File:Foobar.jpg
+</gallery>
+!! html/php
+<ul class="gallery mw-gallery-slideshow" data-showthumbnails="1">
+               <li class="gallerybox" style="width: 155px"><div style="width: 155px">
+                       <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div>
+                       <div class="gallerytext">
+                       </div>
+               </div></li>
+</ul>
+
+!! html/parsoid
+<ul class="gallery mw-gallery-slideshow" data-showthumbnails="1" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{"mode":"slideshow","showthumbnails":""},"body":{}}'>
+<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px;"><span typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></span></div><div class="gallerytext"></div></li>
+</ul>
+!! end
+
+!! test
+HTML Hex character encoding (spells the word "JavaScript")
+!! options
+parsoid=wt2html,wt2wt,html2html
+!! wikitext
+&#x4A;&#x061;&#x0076;&#x00061;&#x000053;&#x0000063;&#114;&#x0000069;&#00000112;&#x0000000074;
+!! html/php
+<p>&#x4a;&#x61;&#x76;&#x61;&#x53;&#x63;&#114;&#x69;&#112;&#x74;
+</p>
+!! html/php+tidy
+<p>JavaScript</p>
+!! html/parsoid
+<p><span typeof="mw:Entity">J</span><span typeof="mw:Entity">a</span><span typeof="mw:Entity">v</span><span typeof="mw:Entity">a</span><span typeof="mw:Entity">S</span><span typeof="mw:Entity">c</span><span typeof="mw:Entity">r</span><span typeof="mw:Entity">i</span><span typeof="mw:Entity">p</span><span typeof="mw:Entity">t</span></p>
+!! end
+
+!! test
+HTML Hex character encoding bogus encoding (T28437 regression check)
+!! wikitext
 &#xsee;&#XSEE;
 !! html/php
 <p>&amp;#xsee;&amp;#XSEE;
@@ -19762,7 +20372,7 @@ ISBN 1234567890
 !! end
 
 !! test
-Bug 22905: <abbr> followed by ISBN followed by </a>
+T24905: <abbr> followed by ISBN followed by </a>
 !! wikitext
 <abbr>(fr)</abbr> ISBN 2753300917 [http://www.example.com example.com]
 !! html/php
@@ -19865,7 +20475,7 @@ djvu
 <p><a href="/index.php?title=File:LoremIpsum.djvu&amp;page=2" class="image"><img alt="LoremIpsum.djvu" src="http://example.com/images/thumb/5/5f/LoremIpsum.djvu/page2-2480px-LoremIpsum.djvu.jpg" width="2480" height="3508" srcset="http://example.com/images/thumb/5/5f/LoremIpsum.djvu/page2-3720px-LoremIpsum.djvu.jpg 1.5x, http://example.com/images/thumb/5/5f/LoremIpsum.djvu/page2-4960px-LoremIpsum.djvu.jpg 2x" /></a>
 </p>
 !! html/parsoid
-<p><span class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"page","ak":"page=2"}]}'><a href="./File:LoremIpsum.djvu" data-parsoid='{"a":{"href":"./File:LoremIpsum.djvu"},"sa":{}}'><img resource="./File:LoremIpsum.djvu" src="//example.com/images/5/5f/LoremIpsum.djvu" data-file-width="2480" data-file-height="3508" data-file-type="bitmap" height="3508" width="2480" data-parsoid='{"a":{"resource":"./File:LoremIpsum.djvu","height":"3508","width":"2480"},"sa":{"resource":"File:LoremIpsum.djvu"}}'/></a></span></p>
+<p><span class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"page","ak":"page=2"}]}' data-mw='{"page":"2"}'><a href="./File:LoremIpsum.djvu" data-parsoid='{"a":{"href":"./File:LoremIpsum.djvu"},"sa":{"href":"File:LoremIpsum.djvu"}}'><img resource="./File:LoremIpsum.djvu" src="//example.com/images/5/5f/LoremIpsum.djvu" data-file-width="2480" data-file-height="3508" data-file-type="bitmap" height="3508" width="2480" data-parsoid='{"a":{"resource":"./File:LoremIpsum.djvu","height":"3508","width":"2480"},"sa":{"resource":"File:LoremIpsum.djvu"}}'/></a></span></p>
 !! end
 
 !! test
@@ -20123,7 +20733,7 @@ Out-of-order TOC heading levels
 =====5=====
 ==2==
 !! html
-<div id="toc" class="toc"><div id="toctitle"><h2>Contents</h2></div>
+<div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
 <ul>
 <li class="toclevel-1 tocsection-1"><a href="#2"><span class="tocnumber">1</span> <span class="toctext">2</span></a>
 <ul>
@@ -20164,9 +20774,11 @@ ISBN ---
 ISBN with space-delimited number
 !! wikitext
 ISBN 92 9017 032 8
-!! html
+!! html/php
 <p><a href="/wiki/Special:BookSources/9290170328" class="internal mw-magiclink-isbn">ISBN 92 9017 032 8</a>
 </p>
+!! html/parsoid
+<p data-parsoid='{"dsr":[0,18,0,0]}'><a href="./Special:BookSources/9290170328" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink","dsr":[0,18,2,2]}'>ISBN 92 9017 032 8</a></p>
 !! end
 
 
@@ -20188,24 +20800,34 @@ ISBN 123456789
 ISBN 1234567890
 
 ISBN 12345678901
-!! html
+!! html/php
 <p>ISBN 123456789
 </p><p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
 </p><p>ISBN 12345678901
 </p>
+!! html/parsoid
+<p>ISBN 123456789</p>
+
+<p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a></p>
+
+<p>ISBN 12345678901</p>
 !! end
 
 
 !! test
-ISBN with trailing year (bug 8110)
+ISBN with trailing year (T9110)
 !! wikitext
 ISBN 1-234-56789-0 - 2006
 
 ISBN 1 234 56789 0 - 2006
-!! html
+!! html/php
 <p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1-234-56789-0</a> - 2006
 </p><p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1 234 56789 0</a> - 2006
 </p>
+!! html/parsoid
+<p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1-234-56789-0</a> - 2006</p>
+
+<p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1 234 56789 0</a> - 2006</p>
 !! end
 
 
@@ -20246,7 +20868,7 @@ anchorencode deals with templates
 !! end
 
 !! test
-anchorencode encodes like the TOC generator: (bug 18431)
+anchorencode encodes like the TOC generator: (T20431)
 !! wikitext
 === _ +:.3A%3A&&amp;]] ===
 {{anchorencode: _ +:.3A%3A&&amp;]] }}
@@ -20258,7 +20880,7 @@ __NOEDITSECTION__
 !! end
 
 !! test
-Bug 6200: blockquotes and paragraph formatting
+T8200: blockquotes and paragraph formatting
 !! wikitext
 <blockquote>
 foo
@@ -20279,7 +20901,7 @@ bar
 !! end
 
 !! test
-Bug 8293: Use of center tag ruins paragraph formatting
+T10293: Use of center tag ruins paragraph formatting
 !! wikitext
 <center>
 foo
@@ -20321,7 +20943,7 @@ title=[[Dunav]] language=sr
 !! wikitext
 Both [[Dunav]] and [[Дунав]] are names for this river.
 !! html
-<p>Both <strong class="selflink">Dunav</strong> and <strong class="selflink">Дунав</strong> are names for this river.
+<p>Both <a class="mw-selflink selflink">Dunav</a> and <a class="mw-selflink selflink">Дунав</a> are names for this river.
 </p>
 !!end
 
@@ -20338,7 +20960,7 @@ title=[[Duna]] language=sr
 !! wikitext
 [[Дуна]] is not a self-link while [[Duna]] and [[Dуна]] are still self-links.
 !! html
-<p><a href="/wiki/%D0%94%D1%83%D0%BD%D0%B0" title="Дуна">Дуна</a> is not a self-link while <strong class="selflink">Duna</strong> and <strong class="selflink">Dуна</strong> are still self-links.
+<p><a href="/wiki/%D0%94%D1%83%D0%BD%D0%B0" title="Дуна">Дуна</a> is not a self-link while <a class="mw-selflink selflink">Duna</a> and <a class="mw-selflink selflink">Dуна</a> are still self-links.
 </p>
 !! end
 
@@ -20349,7 +20971,7 @@ title=[[Duna]] language=sr
 !! wikitext
 [[Dуна]] is a self-link while [[Dunа#Foo]] and [[Dуна#Foo]] are not self-links.
 !! html
-<p><strong class="selflink">Dуна</strong> is a self-link while <a href="/wiki/%D0%94%D1%83%D0%BD%D0%B0" title="Дуна">Dunа#Foo</a> and <a href="/wiki/%D0%94%D1%83%D0%BD%D0%B0" title="Дуна">Dуна#Foo</a> are not self-links.
+<p><a class="mw-selflink selflink">Dуна</a> is a self-link while <a href="/wiki/%D0%94%D1%83%D0%BD%D0%B0" title="Дуна">Dunа#Foo</a> and <a href="/wiki/%D0%94%D1%83%D0%BD%D0%B0" title="Дуна">Dуна#Foo</a> are not self-links.
 </p>
 !! end
 
@@ -20441,7 +21063,7 @@ blah
 ## This wikitext usage is going to be fairly uncommon in production and
 ## selser will take care of preserving formatting in those scenarios.
 !! test
-Don't convert blue categorylinks to another variant (bug 33210)
+Don't convert blue categorylinks to another variant (T35210)
 !! options
 cat
 language=zh
@@ -20610,7 +21232,7 @@ Should be stripped<span title="Exclamation">!</span>
 !! end
 
 !! test
-Bug 24072: more test on conversion rule for title
+T26072: more test on conversion rule for title
 !! options
 language=zh variant=zh-tw showtitle
 !! wikitext
@@ -20658,6 +21280,28 @@ Raw: -{R|zh:China;zh-tw:Taiwan}-
 </p>
 !! end
 
+!! test
+Nested markup inside raw output of variant escape tags (R flag)
+!! options
+language=zh variant=zh-tw
+!! wikitext
+Nested raw: -{R|nested -{zh:China;zh-tw:Taiwan}- nested}-
+!! html
+<p>Nested raw: nested Taiwan nested
+</p>
+!! end
+
+!! test
+Templates inside raw output of variant escape tags (R flag)
+!! options
+language=zh variant=zh-tw
+!! wikitext
+Nested raw: -{R|nested {{echo|hi}} templates}-
+!! html
+<p>Nested raw: nested hi templates
+</p>
+!! end
+
 !! test
 Strings evaluating false shouldn't be ignored by Language converter (T51072)
 !! options
@@ -20724,9 +21368,6 @@ Nested: -{zh-hans:Hi -{zh-cn:China;zh-sg:Singapore;}-;zh-hant:Hello -{zh-tw:Taiw
 </p>
 !! end
 
-# Since Parsoid is starting to emit canonical wikitext for links,
-# [http://example.com http://example.com] will not RT back to that
-# form anymore.
 !! test
 HTML markups with conversion syntax in attribs, nested in other conversion blocks
 !! options
@@ -20749,6 +21390,9 @@ language=zh variant=zh-cn disabled
 </p>
 !! end
 
+# Since Parsoid is starting to emit canonical wikitext for links,
+# [http://example.com http://example.com] will not RT back to that
+# form anymore.
 !! test
 Proper conversion of text in external links
 !! options
@@ -20825,12 +21469,10 @@ language=sr variant=sr-ec
 </p>
 !! end
 
-# FIXME: This test is currently broken in the PHP parser T153761
 !! test
 T146304: Don't break template parsing if language converter markup is in the parameter.
 !! options
 language=sr variant=sr-ec
-disabled
 !! wikitext
 {{echo|-{R|foo}-}}
 !! html/php
@@ -20976,7 +21618,7 @@ language=sr variant=sr-ec
 !! end
 
 !! test
-Bug 529: Uncovered bullet
+T2529: Uncovered bullet
 !! wikitext
 * Foo {{bullet}}
 !! html
@@ -20992,7 +21634,7 @@ Bug 529: Uncovered bullet
 # To test realistic parsing behavior, apply a tidy-like transformation to both
 # the expected output and your parser's output.
 !! test
-Bug 529: Uncovered bullet leaving empty list, normally removed by tidy
+T2529: Uncovered bullet leaving empty list, normally removed by tidy
 !! wikitext
 ******* Foo {{bullet}}
 !! html
@@ -21002,7 +21644,7 @@ Bug 529: Uncovered bullet leaving empty list, normally removed by tidy
 !! end
 
 !! test
-Bug 529: Uncovered table already at line-start
+T2529: Uncovered table already at line-start
 !! wikitext
 x
 
 !! end
 
 !! test
-Bug 529: Uncovered bullet in parser function result
+T2529: Uncovered bullet in parser function result
 !! wikitext
 * Foo {{lc:{{bullet}} }}
 !! html
@@ -21035,7 +21677,7 @@ Bug 529: Uncovered bullet in parser function result
 !! end
 
 !! test
-Bug 5678: Double-parsed template argument
+T7678: Double-parsed template argument
 !! wikitext
 {{lc:{{{1}}}|hello}}
 !! html
@@ -21044,7 +21686,7 @@ Bug 5678: Double-parsed template argument
 !! end
 
 !! test
-Bug 5678: Double-parsed template invocation
+T7678: Double-parsed template invocation
 !! wikitext
 {{lc:{{paramtest {{!}} param = hello }} }}
 !! html
@@ -21053,7 +21695,7 @@ Bug 5678: Double-parsed template invocation
 !! end
 
 !! test
-Case insensitivity of parser functions for non-ASCII characters (bug 8143)
+Case insensitivity of parser functions for non-ASCII characters (T10143)
 !! options
 language=cs
 title=[[Main Page]]
@@ -21198,9 +21840,9 @@ B</strong>
 </p>
 !! end
 
-# Bug 6200: <blockquote> should behave like <div> with respect to line breaks
+# T8200: <blockquote> should behave like <div> with respect to line breaks
 !! test
-Bug 6200: paragraphs inside blockquotes (no extra line breaks)
+T8200: paragraphs inside blockquotes (no extra line breaks)
 !! wikitext
 <blockquote>Line one
 
@@ -21216,7 +21858,7 @@ Line two</blockquote>
 !! end
 
 !! test
-Bug 6200: paragraphs inside blockquotes (extra line break on open)
+T8200: paragraphs inside blockquotes (extra line break on open)
 !! wikitext
 <blockquote>
 Line one
@@ -21235,7 +21877,7 @@ Line two</blockquote>
 !! end
 
 !! test
-Bug 6200: paragraphs inside blockquotes (extra line break on close)
+T8200: paragraphs inside blockquotes (extra line break on close)
 !! wikitext
 <blockquote>Line one
 
@@ -21255,7 +21897,7 @@ Line two
 !! end
 
 !! test
-Bug 6200: paragraphs inside blockquotes (extra line break on open and close)
+T8200: paragraphs inside blockquotes (extra line break on open and close)
 !! wikitext
 <blockquote>
 Line one
@@ -21360,7 +22002,7 @@ Free external link invading image caption
 !! end
 
 !! test
-Bug 15196: localised external link numbers
+T17196: localised external link numbers
 !! options
 language=fa
 !! wikitext
@@ -21497,7 +22139,7 @@ comment local title=[[Main Page]]
 !!end
 
 !! test
-Edit comment with subpage link (bug 14080)
+Edit comment with subpage link (T16080)
 !! options
 comment
 subpage
@@ -21509,7 +22151,7 @@ Poked at a <a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">/su
 !!end
 
 !! test
-Edit comment with subpage link and link text (bug 14080)
+Edit comment with subpage link and link text (T16080)
 !! options
 comment
 subpage
@@ -21521,7 +22163,7 @@ Poked at a <a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">nea
 !!end
 
 !! test
-Edit comment with bogus subpage link in non-subpage NS (bug 14080)
+Edit comment with bogus subpage link in non-subpage NS (T16080)
 !! options
 comment
 title=[[Subpage test]]
@@ -21597,7 +22239,7 @@ Created page with &quot;&lt;noinclude&gt;<a href="/index.php?title=Category:Requ
 !! end
 
 !! test
-Space normalisation on autocomment (bug 22784)
+Space normalisation on autocomment (T24784)
 !! options
 comment
 title=[[Main Page]]
@@ -21608,7 +22250,7 @@ title=[[Main Page]]
 !! end
 
 !! test
-percent-encoding and + signs in comments (Bug 26410)
+percent-encoding and + signs in comments (T28410)
 !! options
 comment
 !! wikitext
@@ -21617,7 +22259,7 @@ comment
 <a href="/index.php?title=ABC3D%25_%2B%2B&amp;action=edit&amp;redlink=1" class="new" title="ABC3D% ++ (page does not exist)">ABC3D% ++</a> <a href="/index.php?title=ABC3D%25_%2B%2B&amp;action=edit&amp;redlink=1" class="new" title="ABC3D% ++ (page does not exist)">+%20</a>
 !! end
 
-# Parsoid doesn't support this yet: see bug 73581
+# Parsoid doesn't support this yet: see T75581
 # but it *should* omit the 'src' attribute if the image is bad.
 # PHP side of tests was disabled in
 # mediawiki/core:6bd31e7d95161a6e88fa86df60871051da997c3c
@@ -21633,7 +22275,7 @@ Bad images - basic functionality
 !! end
 
 !! test
-Bad images - bug 16039: text after bad image disappears
+Bad images - T18039: text after bad image disappears
 !! wikitext
 Foo bar
 [[File:Bad.jpg]]
@@ -21649,7 +22291,7 @@ Bar foo</p>
 !! end
 
 !! test
-Verify that displaytitle works (bug #22501) no displaytitle
+Verify that displaytitle works (T24501) no displaytitle
 !! options
 showtitle
 !! config
@@ -21664,7 +22306,7 @@ Parser test
 !! end
 
 !! test
-Verify that displaytitle works (bug #22501) RestrictDisplayTitle=false
+Verify that displaytitle works (T24501) RestrictDisplayTitle=false
 !! options
 showtitle
 title=[[Screen]]
@@ -21681,7 +22323,7 @@ whatever
 !! end
 
 !! test
-Verify that displaytitle works (bug #22501) RestrictDisplayTitle=true mismatch
+Verify that displaytitle works (T24501) RestrictDisplayTitle=true mismatch
 !! options
 showtitle
 title=[[Screen]]
@@ -21698,7 +22340,7 @@ Screen
 !! end
 
 !! test
-Verify that displaytitle works (bug #22501) RestrictDisplayTitle=true matching
+Verify that displaytitle works (T24501) RestrictDisplayTitle=true matching
 !! options
 showtitle
 title=[[Screen]]
@@ -21715,7 +22357,7 @@ screen
 !! end
 
 !! test
-Verify that displaytitle works (bug #22501) AllowDisplayTitle=false
+Verify that displaytitle works (T24501) AllowDisplayTitle=false
 !! options
 showtitle
 title=[[Screen]]
@@ -21732,7 +22374,7 @@ Screen
 !! end
 
 !! test
-Verify that displaytitle works (bug #22501) AllowDisplayTitle=false no DISPLAYTITLE
+Verify that displaytitle works (T24501) AllowDisplayTitle=false no DISPLAYTITLE
 !! options
 showtitle
 title=[[Screen]]
@@ -21747,7 +22389,7 @@ Screen
 !! end
 
 !! test
-Verify that displaytitle handles inline CSS styles (bug 26547) - rejected value
+Verify that displaytitle handles inline CSS styles (T28547) - rejected value
 !! options
 showtitle
 title=[[Screen]]
@@ -21764,7 +22406,7 @@ this is not the the title
 !! end
 
 !! test
-Verify that displaytitle handles inline CSS styles (bug 26547) - accepted value
+Verify that displaytitle handles inline CSS styles (T28547) - accepted value
 !! options
 showtitle
 title=[[Screen]]
@@ -21787,7 +22429,7 @@ showindicators
 !! wikitext
 <indicator name=" "></indicator>
 <indicator></indicator>
-!! html
+!! html/php
 <p><span class="error"><strong>Error:</strong> Page status indicators' <code>name</code> attribute must not be empty.</span>
 <span class="error"><strong>Error:</strong> Page status indicators' <code>name</code> attribute must not be empty.</span>
 </p>
@@ -21800,7 +22442,7 @@ showindicators
 !! wikitext
 <indicator name="empty" />
 <indicator name="name"></indicator>
-!! html
+!! html/php
 empty=
 name=
 <p><br />
@@ -21827,7 +22469,7 @@ showindicators
 <indicator name="10">Two
 
 paragraphs</indicator>
-!! html
+!! html/php
 01=hello world
 02=<a href="/wiki/Main_Page" title="Main Page">Main Page</a>
 03=<img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/25px-Foobar.jpg" width="25" height="3" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/38px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/50px-Foobar.jpg 2x" />
@@ -21897,7 +22539,7 @@ preload
 !! end
 
 !! test
-Play a bit with r67090 and bug 3158
+Play a bit with r67090 and T5158
 !! wikitext
 <div style="width:50% !important">&nbsp;</div>
 <div style="width:50%&nbsp;!important">&nbsp;</div>
@@ -21944,7 +22586,7 @@ Strip reserved data attributes
 !! end
 
 !! test
-percent-encoding and + signs in internal links (Bug 26410)
+percent-encoding and + signs in internal links (T28410)
 !! wikitext
 [[User:+%]] [[Page+title%]]
 [[%+]] [[%+|%20]] [[%+ ]] [[%+r]]
@@ -21959,12 +22601,12 @@ percent-encoding and + signs in internal links (Bug 26410)
 !! html/parsoid
 <p><a rel="mw:WikiLink" href="./User:+%25" title="User:+%" data-parsoid='{"stx":"simple","a":{"href":"./User:+%25"},"sa":{"href":"User:+%"}}'>User:+%</a> <a rel="mw:WikiLink" href="./Page+title%25" title="Page+title%" data-parsoid='{"stx":"simple","a":{"href":"./Page+title%25"},"sa":{"href":"Page+title%"}}'>Page+title%</a>
 <a rel="mw:WikiLink" href="./%25+" title="%+" data-parsoid='{"stx":"simple","a":{"href":"./%25+"},"sa":{"href":"%+"}}'>%+</a> <a rel="mw:WikiLink" href="./%25+" title="%+" data-parsoid='{"stx":"piped","a":{"href":"./%25+"},"sa":{"href":"%+"}}'>%20</a> <a rel="mw:WikiLink" href="./%25+" title="%+" data-parsoid='{"stx":"simple","a":{"href":"./%25+"},"sa":{"href":"%+ "}}'>%+ </a> <a rel="mw:WikiLink" href="./%25+r" title="%+r" data-parsoid='{"stx":"simple","a":{"href":"./%25+r"},"sa":{"href":"%+r"}}'>%+r</a>
-<a rel="mw:WikiLink" href="./%25" title="%" data-parsoid='{"stx":"simple","a":{"href":"./%25"},"sa":{"href":"%"}}'>%</a> <a rel="mw:WikiLink" href="./+" title="+" data-parsoid='{"stx":"simple","a":{"href":"./+"},"sa":{"href":"+"}}'>+</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=&#39;{\"stx\":\"simple\",\"a\":{\"href\":\"./Bar\"},\"sa\":{\"href\":\"bar\"},\"dsr\":[94,101,2,2]}&#39;>bar&lt;/a>"}'><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="%" data-parsoid='{"stx":"simple","a":{"href":"./%25"},"sa":{"href":"%"}}'>%</a> <a rel="mw:WikiLink" href="./+" title="+" data-parsoid='{"stx":"simple","a":{"href":"./+"},"sa":{"href":"+"}}'>+</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":"apierror-filedoesnotexist","message":"This image does not exist."}],"caption":"&lt;a rel=\"mw:WikiLink\" href=\"./Bar\" title=\"Bar\" data-parsoid=&#39;{\"stx\":\"simple\",\"a\":{\"href\":\"./Bar\"},\"sa\":{\"href\":\"bar\"},\"dsr\":[94,101,2,2]}&#39;>bar&lt;/a>"}'><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="./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
 
 !! test
-Special characters in embedded file links (bug 27679)
+Special characters in embedded file links (T29679)
 !! wikitext
 [[File:Contains & ampersand.jpg]]
 [[File:Does not exist.jpg|Title with & ampersand]]
@@ -21973,8 +22615,8 @@ Special characters in embedded file links (bug 27679)
 <a href="/index.php?title=Special:Upload&amp;wpDestFile=Does_not_exist.jpg" class="new" title="File:Does not exist.jpg">Title with &amp; ampersand</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."}]}'><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;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>
+<p><span class="mw-default-size" typeof="mw:Error mw:Image" data-mw='{"errors":[{"key":"apierror-filedoesnotexist","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":"apierror-filedoesnotexist","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
@@ -21987,7 +22629,7 @@ Text&apos;s been normalized?
 !! end
 
 !! test
-Bug 19052 U+3000 IDEOGRAPHIC SPACE should terminate free external links
+T21052 U+3000 IDEOGRAPHIC SPACE should terminate free external links
 !! wikitext
 http://www.example.org/ <-- U+3000 (vim: ^Vu3000)
 !! html
@@ -21996,7 +22638,7 @@ http://www.example.org/ <-- U+3000 (vim: ^Vu3000)
 !! end
 
 !! test
-Bug 19052 U+3000 IDEOGRAPHIC SPACE should terminate bracketed external links
+T21052 U+3000 IDEOGRAPHIC SPACE should terminate bracketed external links
 !! wikitext
 [http://www.example.org/ ideograms]
 !! html
@@ -22005,7 +22647,7 @@ Bug 19052 U+3000 IDEOGRAPHIC SPACE should terminate bracketed external links
 !! end
 
 !! test
-Bug 19052 U+3000 IDEOGRAPHIC SPACE should terminate external images links
+T21052 U+3000 IDEOGRAPHIC SPACE should terminate external images links
 !! wikitext
 http://www.example.org/pic.png <-- U+3000 (vim: ^Vu3000)
 !! html
@@ -22033,7 +22675,7 @@ Template:Identical
 !! endarticle
 
 !! test
-Bug 31098 Template which includes system messages which includes the template
+T33098 Template which includes system messages which includes the template
 !! wikitext
 {{Identical}}
 !! html
@@ -22043,7 +22685,7 @@ Bug 31098 Template which includes system messages which includes the template
 !! end
 
 !! test
-Bug31490 Turkish: ucfirst 'blah'
+T33490 Turkish: ucfirst 'blah'
 !! options
 language=tr
 !! wikitext
@@ -22054,7 +22696,7 @@ language=tr
 !! end
 
 !! test
-Bug31490 Turkish: ucfirst 'ix'
+T33490 Turkish: ucfirst 'ix'
 !! options
 language=tr
 !! wikitext
@@ -22065,7 +22707,7 @@ language=tr
 !! end
 
 !! test
-Bug31490 Turkish: lcfirst 'BLAH'
+T33490 Turkish: lcfirst 'BLAH'
 !! options
 language=tr
 !! wikitext
@@ -22076,7 +22718,7 @@ language=tr
 !! end
 
 !! test
-Bug31490 Turkish: ucfırst (with a dotless i)
+T33490 Turkish: ucfırst (with a dotless i)
 !! options
 language=tr
 !! wikitext
@@ -22087,7 +22729,7 @@ language=tr
 !! end
 
 !! test
-Bug31490 ucfırst (with a dotless i) with English language
+T33490 ucfırst (with a dotless i) with English language
 !! options
 language=en
 !! wikitext
@@ -22097,15 +22739,21 @@ language=en
 </p>
 !! end
 
+# Note that Parsoid doesn't emit an explicit TOC.
+# Note also that the html2wt direction tends to emit an extra newline
+# between the __TOC__ magicword and the first heading unless *both*
+# the <meta> and the <h2> have a data-parsoid attribute set (even if
+# it's "{}").
+
 !! test
-Bug 26375: TOC with italics
+T28375: TOC with italics
 !! options
 title=[[Main Page]]
 !! wikitext
 __TOC__
 == ''Lost'' episodes ==
-!! html
-<div id="toc" class="toc"><div id="toctitle"><h2>Contents</h2></div>
+!! html/php
+<div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
 <ul>
 <li class="toclevel-1 tocsection-1"><a href="#Lost_episodes"><span class="tocnumber">1</span> <span class="toctext"><i>Lost</i> episodes</span></a></li>
 </ul>
@@ -22113,17 +22761,20 @@ __TOC__
 
 <h2><span class="mw-headline" id="Lost_episodes"><i>Lost</i> episodes</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Main_Page&amp;action=edit&amp;section=1" title="Edit section: Lost episodes">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
 
+!! html/parsoid
+<meta property="mw:PageProp/toc" data-parsoid='{}'/>
+<h2 data-parsoid='{}'> <i>Lost</i> episodes </h2>
 !! end
 
 !! test
-Bug 26375: TOC with bold
+T28375: TOC with bold
 !! options
 title=[[Main Page]]
 !! wikitext
 __TOC__
 == '''should be bold''' then normal text ==
-!! html
-<div id="toc" class="toc"><div id="toctitle"><h2>Contents</h2></div>
+!! html/php
+<div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
 <ul>
 <li class="toclevel-1 tocsection-1"><a href="#should_be_bold_then_normal_text"><span class="tocnumber">1</span> <span class="toctext"><b>should be bold</b> then normal text</span></a></li>
 </ul>
@@ -22131,17 +22782,20 @@ __TOC__
 
 <h2><span class="mw-headline" id="should_be_bold_then_normal_text"><b>should be bold</b> then normal text</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Main_Page&amp;action=edit&amp;section=1" title="Edit section: should be bold then normal text">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
 
+!! html/parsoid
+<meta property="mw:PageProp/toc" data-parsoid='{}'/>
+<h2 data-parsoid='{}'> <b>should be bold</b> then normal text </h2>
 !! end
 
 !! test
-Bug 33845: Headings become cursive in TOC when they contain an image
+T35845: Headings become cursive in TOC when they contain an image
 !! options
 title=[[Main Page]]
 !! wikitext
 __TOC__
 == Image [[Image:foobar.jpg]] ==
-!! html
-<div id="toc" class="toc"><div id="toctitle"><h2>Contents</h2></div>
+!! html/php
+<div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
 <ul>
 <li class="toclevel-1 tocsection-1"><a href="#Image"><span class="tocnumber">1</span> <span class="toctext">Image</span></a></li>
 </ul>
@@ -22149,17 +22803,20 @@ __TOC__
 
 <h2><span class="mw-headline" id="Image">Image <a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Main_Page&amp;action=edit&amp;section=1" title="Edit section: Image">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
 
+!! html/parsoid
+<meta property="mw:PageProp/toc" data-parsoid='{}'/>
+<h2 data-parsoid='{}'> Image <span class="mw-default-size" typeof="mw:Image"><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> </h2>
 !! end
 
 !! test
-Bug 33845 (2): Headings become bold in TOC when they contain a blockquote
+T35845 (2): Headings become bold in TOC when they contain a blockquote
 !! options
 title=[[Main Page]]
 !! wikitext
 __TOC__
 == <blockquote>Quote</blockquote> ==
-!! html
-<div id="toc" class="toc"><div id="toctitle"><h2>Contents</h2></div>
+!! html/php
+<div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
 <ul>
 <li class="toclevel-1 tocsection-1"><a href="#Quote"><span class="tocnumber">1</span> <span class="toctext">Quote</span></a></li>
 </ul>
@@ -22167,10 +22824,10 @@ __TOC__
 
 <h2><span class="mw-headline" id="Quote"><blockquote>Quote</blockquote></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Main_Page&amp;action=edit&amp;section=1" title="Edit section: Quote">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
 
-!! html+tidy
+!! html/php+tidy
 <p></p>
 <div id="toc" class="toc">
-<div id="toctitle">
+<div class="toctitle">
 <h2>Contents</h2>
 </div>
 <ul>
@@ -22183,6 +22840,9 @@ __TOC__
 <p><span class="mw-headline" id="Quote">Quote</span></p>
 </blockquote>
 <p><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Main_Page&amp;action=edit&amp;section=1" title="Edit section: Quote">edit</a><span class="mw-editsection-bracket">]</span></span></p>
+!! html/parsoid
+<meta property="mw:PageProp/toc" data-parsoid='{}'/>
+<h2 data-parsoid='{}'> <blockquote>Quote</blockquote> </h2>
 !! end
 
 !! test
@@ -22194,8 +22854,8 @@ __TOC__
 == Proof: 2 < 3 ==
 <small>Hanc marginis exiguitas non caperet.</small>
 QED
-!! html
-<div id="toc" class="toc"><div id="toctitle"><h2>Contents</h2></div>
+!! html/php
+<div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
 <ul>
 <li class="toclevel-1 tocsection-1"><a href="#Proof:_2_.3C_3"><span class="tocnumber">1</span> <span class="toctext">Proof: 2 &lt; 3</span></a></li>
 </ul>
@@ -22205,6 +22865,11 @@ QED
 <p><small>Hanc marginis exiguitas non caperet.</small>
 QED
 </p>
+!! html/parsoid
+<meta property="mw:PageProp/toc" data-parsoid='{}'/>
+<h2 data-parsoid='{}'> Proof: 2 &lt; 3 </h2>
+<p><small>Hanc marginis exiguitas non caperet.</small>
+QED</p>
 !! end
 
 !! test
@@ -22214,8 +22879,8 @@ __TOC__
 == <i>Foo</i> <b>Bar</b> ==
 
 == <i>Foo</i> <blockquote>Bar</blockquote> ==
-!! html
-<div id="toc" class="toc"><div id="toctitle"><h2>Contents</h2></div>
+!! html/php
+<div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
 <ul>
 <li class="toclevel-1 tocsection-1"><a href="#Foo_Bar"><span class="tocnumber">1</span> <span class="toctext"><i>Foo</i> <b>Bar</b></span></a></li>
 <li class="toclevel-1 tocsection-2"><a href="#Foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext"><i>Foo</i> Bar</span></a></li>
@@ -22225,10 +22890,10 @@ __TOC__
 <h2><span class="mw-headline" id="Foo_Bar"><i>Foo</i> <b>Bar</b></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: Foo Bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
 <h2><span class="mw-headline" id="Foo_Bar_2"><i>Foo</i> <blockquote>Bar</blockquote></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Edit section: Foo Bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
 
-!! html+tidy
+!! html/php+tidy
 <p></p>
 <div id="toc" class="toc">
-<div id="toctitle">
+<div class="toctitle">
 <h2>Contents</h2>
 </div>
 <ul>
@@ -22243,6 +22908,10 @@ __TOC__
 <p><span class="mw-headline" id="Foo_Bar_2">Bar</span></p>
 </blockquote>
 <p><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Edit section: Foo Bar">edit</a><span class="mw-editsection-bracket">]</span></span></p>
+!! html/parsoid
+<meta property="mw:PageProp/toc" data-parsoid='{}'/>
+<h2 data-parsoid='{}'> <i data-parsoid='{"stx":"html"}'>Foo</i> <b data-parsoid='{"stx":"html"}'>Bar</b> </h2>
+<h2> <i data-parsoid='{"stx":"html"}'>Foo</i> <blockquote>Bar</blockquote> </h2>
 !! end
 
 # Don't expect Parsoid to roundtrip this until the php parser comes closer to
@@ -22257,7 +22926,7 @@ __TOC__
 
 == <sup class="a > b">Evilbye</sup> ==
 !! html/php
-<div id="toc" class="toc"><div id="toctitle"><h2>Contents</h2></div>
+<div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
 <ul>
 <li class="toclevel-1 tocsection-1"><a href="#Hello"><span class="tocnumber">1</span> <span class="toctext"><sup>Hello</sup></span></a></li>
 <li class="toclevel-1 tocsection-2"><a href="#b.22.3EEvilbye"><span class="tocnumber">2</span> <span class="toctext"><sup> b"&gt;Evilbye</sup></span></a></li>
@@ -22287,8 +22956,8 @@ __TOC__
 == <span style="font-style: italic" dir="ltr">All attributes on these span tags must be deleted from the TOC</span> ==
 
 == <span dir="ltr" style="font-style: italic">Attributes after dir on these span tags must be deleted from the TOC</span> ==
-!! html
-<div id="toc" class="toc"><div id="toctitle"><h2>Contents</h2></div>
+!! html/php
+<div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
 <ul>
 <li class="toclevel-1 tocsection-1"><a href="#C.2B.2B"><span class="tocnumber">1</span> <span class="toctext"><span dir="ltr">C++</span></span></a></li>
 <li class="toclevel-1 tocsection-2"><a href="#.D7.96.D7.91.D7.A0.D7.92.21"><span class="tocnumber">2</span> <span class="toctext"><span dir="rtl">זבנג!</span></span></a></li>
@@ -22304,15 +22973,22 @@ __TOC__
 <h2><span class="mw-headline" id="All_attributes_on_these_span_tags_must_be_deleted_from_the_TOC"><span style="font-style: italic" dir="ltr">All attributes on these span tags must be deleted from the TOC</span></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=4" title="Edit section: All attributes on these span tags must be deleted from the TOC">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
 <h2><span class="mw-headline" id="Attributes_after_dir_on_these_span_tags_must_be_deleted_from_the_TOC"><span dir="ltr" style="font-style: italic">Attributes after dir on these span tags must be deleted from the TOC</span></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=5" title="Edit section: Attributes after dir on these span tags must be deleted from the TOC">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
 
+!! html/parsoid
+<meta property="mw:PageProp/toc" data-parsoid='{}'/>
+<h2 data-parsoid='{}'> <span dir="ltr">C++</span> </h2>
+<h2> <span dir="rtl">זבנג!</span> </h2>
+<h2> <span style="font-style: italic">The attributes on these span tags must be deleted from the TOC</span> </h2>
+<h2> <span style="font-style: italic" dir="ltr">All attributes on these span tags must be deleted from the TOC</span> </h2>
+<h2> <span dir="ltr" style="font-style: italic">Attributes after dir on these span tags must be deleted from the TOC</span> </h2>
 !! end
 
 !! test
-Bug 72884: bdi element in ToC
+T74884: bdi element in ToC
 !! wikitext
 __TOC__
 == <bdi>test</bdi> ==
-!! html
-<div id="toc" class="toc"><div id="toctitle"><h2>Contents</h2></div>
+!! html/php
+<div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
 <ul>
 <li class="toclevel-1 tocsection-1"><a href="#test"><span class="tocnumber">1</span> <span class="toctext"><bdi>test</bdi></span></a></li>
 </ul>
@@ -22320,6 +22996,9 @@ __TOC__
 
 <h2><span class="mw-headline" id="test"><bdi>test</bdi></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: test">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
 
+!! html/parsoid
+<meta property="mw:PageProp/toc" data-parsoid='{}'/>
+<h2 data-parsoid='{}'> <bdi>test</bdi> </h2>
 !! end
 
 !! test
@@ -22327,8 +23006,8 @@ T35715: s/strike element in ToC
 !! wikitext
 __TOC__
 == <s>test</s> test <strike>test</strike> ==
-!! html
-<div id="toc" class="toc"><div id="toctitle"><h2>Contents</h2></div>
+!! html/php
+<div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
 <ul>
 <li class="toclevel-1 tocsection-1"><a href="#test_test_test"><span class="tocnumber">1</span> <span class="toctext"><s>test</s> test <strike>test</strike></span></a></li>
 </ul>
@@ -22336,6 +23015,9 @@ __TOC__
 
 <h2><span class="mw-headline" id="test_test_test"><s>test</s> test <strike>test</strike></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: test test test">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
 
+!! html/parsoid
+<meta property="mw:PageProp/toc" data-parsoid='{}'/>
+<h2 data-parsoid='{}'> <s>test</s> test <strike>test</strike> </h2>
 !! end
 
 # Note that the html output does not have the <p></p>, but the
@@ -22346,8 +23028,8 @@ Empty <p> tag in TOC, removed by Sanitizer (T92892)
 !! wikitext
 __TOC__
 == x ==
-!! html
-<div id="toc" class="toc"><div id="toctitle"><h2>Contents</h2></div>
+!! html/php
+<div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
 <ul>
 <li class="toclevel-1 tocsection-1"><a href="#x"><span class="tocnumber">1</span> <span class="toctext">x</span></a></li>
 </ul>
@@ -22355,10 +23037,10 @@ __TOC__
 
 <h2><span class="mw-headline" id="x">x</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: x">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
 
-!! html+tidy
+!! html/php+tidy
 <p></p>
 <div id="toc" class="toc">
-<div id="toctitle">
+<div class="toctitle">
 <h2>Contents</h2>
 </div>
 <ul>
@@ -22367,20 +23049,23 @@ __TOC__
 </div>
 <p></p>
 <h2><span class="mw-headline" id="x">x</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: x">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
+!! html/parsoid
+<meta property="mw:PageProp/toc" data-parsoid='{}'/>
+<h2 data-parsoid='{}'> x </h2>
 !! end
 
 !! article
-MediaWiki:Bug32057
+MediaWiki:T34057
 !! text
 == {{int:headline_sample}} ==
 !! endarticle
 
 !! test
-Bug 32057: Title needed when expanding <h> nodes.
+T34057: Title needed when expanding <h> nodes.
 !! options
 title=[[Main Page]]
 !! wikitext
-{{int:Bug32057}}
+{{int:T34057}}
 !! html
 <h2><span class="mw-headline" id="Headline_text">Headline text</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Main_Page&amp;action=edit&amp;section=1" title="Edit section: Headline text">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
 
@@ -22444,7 +23129,7 @@ language=be-tarask
 !! end
 
 !! test
-Wrong option for formatNum (bug 56199)
+Wrong option for formatNum (T58199)
 !! wikitext
 {{formatnum:1,234.56|Random}}
 {{formatnum:1,234.56|EVERYTHING}}
@@ -22495,7 +23180,7 @@ Strip marker in anchorencode
 !! end
 
 !! test
-nowiki inside link inside heading (bug 18295)
+nowiki inside link inside heading (T20295)
 !! wikitext
 ==[[foo|x<nowiki>y</nowiki>z]]==
 !! html
@@ -22504,7 +23189,7 @@ nowiki inside link inside heading (bug 18295)
 !! end
 
 !! test
-new support for bdi element (bug 31817)
+new support for bdi element (T33817)
 !! wikitext
 <p dir="rtl" lang="he">ולדימיר לנין (ברוסית: <bdi lang="ru">Владимир Ленин</bdi>, 24 באפריל 1870–22 בינואר 1924) הוא מנהיג פוליטי קומוניסטי רוסי.</p>
 !! html
@@ -22531,25 +23216,6 @@ Ignore pipe between table row attributes
 
 !! end
 
-!!test
-Gallery override link with WikiLink (bug 34852)
-!! wikitext
-<gallery>
-File:foobar.jpg|caption|alt=galleryalt|link=InterWikiLink
-</gallery>
-!! html
-<ul class="gallery mw-gallery-traditional">
-               <li class="gallerybox" style="width: 155px"><div style="width: 155px">
-                       <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/InterWikiLink"><img alt="galleryalt" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div>
-                       <div class="gallerytext">
-<p>caption
-</p>
-                       </div>
-               </div></li>
-</ul>
-
-!! end
-
 !!test
 Language parser function
 !! wikitext
@@ -22584,7 +23250,7 @@ Special:Foobar
 !! end
 
 !!test
-Bug 34939 - Case insensitive link parsing ([HttP://])
+T36939 - Case insensitive link parsing ([HttP://])
 !! wikitext
 [HttP://MediaWiki.Org/]
 !! html/php
@@ -22595,7 +23261,7 @@ Bug 34939 - Case insensitive link parsing ([HttP://])
 !! end
 
 !!test
-Bug 34939 - Case insensitive link parsing ([HttP:// title])
+T36939 - Case insensitive link parsing ([HttP:// title])
 !! wikitext
 [HttP://MediaWiki.Org/ MediaWiki]
 !! html
@@ -22604,7 +23270,7 @@ Bug 34939 - Case insensitive link parsing ([HttP:// title])
 !! end
 
 !!test
-Bug 34939 - Case insensitive link parsing (HttP://)
+T36939 - Case insensitive link parsing (HttP://)
 !! wikitext
 HttP://MediaWiki.Org/
 !! html/php
@@ -22666,7 +23332,7 @@ parsoid=wt2html,wt2wt
 #### Parsoid-specific functionality tests
 #### -----------------------------------------------------------------
 
-# Bug 63642/66749: Formatting elt fixup around images is cleaned up.
+# T65642/T68749: Formatting elt fixup around images is cleaned up.
 # We know wt2wt will fail, but we expect selser to pass.
 # Due to the nature of our testing, wt2wt and selser tests will enter the
 # blacklist and we'll catch selser regressions based on changes to the
@@ -22732,573 +23398,6 @@ parsoid=wt2html,wt2wt
 <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
-#### PHP parser.
-#### ----------------------------------------------------------------
-
-!!test
-Ref: 1. ref-location should be replaced with an index span
-!! wikitext
-A <ref>foo</ref>
-B <ref name="x">foo</ref>
-C <ref name="y" />
-<references />
-!! html/parsoid
-<p>A <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="./Main_Page#cite_note-1"><span class="mw-reflink-text">[1]</span></a></span>
-B <span about="#mwt4" class="mw-ref" id="cite_ref-x_2-0" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","body":{"id":"mw-reference-text-cite_note-x-2"},"attrs":{"name":"x"}}'><a href="./Main_Page#cite_note-x-2"><span class="mw-reflink-text">[2]</span></a></span>
-C <span about="#mwt6" class="mw-ref" id="cite_ref-y_3-0" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"name":"y"}}'><a href="./Main_Page#cite_note-y-3"><span class="mw-reflink-text">[3]</span></a></span></p>
-<ol class="mw-references" typeof="mw:Extension/references" about="#mwt8" data-mw='{"name":"references","attrs":{}}'>
-<li about="#cite_note-1" id="cite_note-1"><a href="./Main_Page#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">foo</span></li>
-<li about="#cite_note-x-2" id="cite_note-x-2"><a href="./Main_Page#cite_ref-x_2-0" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-x-2" class="mw-reference-text">foo</span></li>
-<li about="#cite_note-y-3" id="cite_note-y-3"><a href="./Main_Page#cite_ref-y_3-0" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-y-3" class="mw-reference-text"></span></li>
-</ol>
-!!end
-
-!!test
-Ref: 2. ref-tags with identical names should all get the same index
-!! wikitext
-A <ref name="x">foo</ref>
-B <ref name="x" />
-<references />
-!! html/parsoid
-<p>A <span about="#mwt2" class="mw-ref" id="cite_ref-x_1-0" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","body":{"id":"mw-reference-text-cite_note-x-1"},"attrs":{"name":"x"}}'><a href="./Main_Page#cite_note-x-1"><span class="mw-reflink-text">[1]</span></a></span>
-B <span about="#mwt4" class="mw-ref" id="cite_ref-x_1-1" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"name":"x"}}'><a href="./Main_Page#cite_note-x-1"><span class="mw-reflink-text">[1]</span></a></span></p>
-<ol class="mw-references" typeof="mw:Extension/references" about="#mwt6" data-mw='{"name":"references","attrs":{}}'>
-<li about="#cite_note-x-1" id="cite_note-x-1"><span rel="mw:referencedBy"><a href="./Main_Page#cite_ref-x_1-0"><span class="mw-linkback-text">1 </span></a><a href="./Main_Page#cite_ref-x_1-1"><span class="mw-linkback-text">2 </span></a></span> <span id="mw-reference-text-cite_note-x-1" class="mw-reference-text">foo</span></li>
-</ol>
-!!end
-
-!!test
-Ref: 3. spaces in ref-names should be ignored
-!! wikitext
-A <ref name="x">foo</ref>
-B <ref name=" x " />
-C <ref name= x  />
-<references />
-!! html/parsoid
-<p>A <span about="#mwt2" class="mw-ref" id="cite_ref-x_1-0" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","body":{"id":"mw-reference-text-cite_note-x-1"},"attrs":{"name":"x"}}'><a href="./Main_Page#cite_note-x-1"><span class="mw-reflink-text">[1]</span></a></span>
-B <span about="#mwt4" class="mw-ref" id="cite_ref-x_1-1" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"name":"x"}}'><a href="./Main_Page#cite_note-x-1"><span class="mw-reflink-text">[1]</span></a></span>
-C <span about="#mwt6" class="mw-ref" id="cite_ref-x_1-2" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"name":"x"}}'><a href="./Main_Page#cite_note-x-1"><span class="mw-reflink-text">[1]</span></a></span></p>
-<ol class="mw-references" typeof="mw:Extension/references" about="#mwt8" data-mw='{"name":"references","attrs":{}}'>
-<li about="#cite_note-x-1" id="cite_note-x-1"><span rel="mw:referencedBy"><a href="./Main_Page#cite_ref-x_1-0"><span class="mw-linkback-text">1 </span></a><a href="./Main_Page#cite_ref-x_1-1"><span class="mw-linkback-text">2 </span></a><a href="./Main_Page#cite_ref-x_1-2"><span class="mw-linkback-text">3 </span></a></span> <span id="mw-reference-text-cite_note-x-1" class="mw-reference-text">foo</span></li>
-</ol>
-!!end
-
-# NOTE: constructor is a predefined property in JS and constructor as a ref-name can clash with it if not handled properly)
-!!test
-Ref: 4. 'constructor' should be accepted as a valid ref-name
-!! wikitext
-A <ref name="constructor">foo</ref>
-<references />
-!! html/parsoid
-<p>A <span about="#mwt2" class="mw-ref" id="cite_ref-constructor_1-0" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","body":{"id":"mw-reference-text-cite_note-constructor-1"},"attrs":{"name":"constructor"}}'><a href="./Main_Page#cite_note-constructor-1"><span class="mw-reflink-text">[1]</span></a></span></p>
-<ol class="mw-references" typeof="mw:Extension/references" about="#mwt4" data-mw='{"name":"references","attrs":{}}'>
-<li about="#cite_note-constructor-1" id="cite_note-constructor-1"><a href="./Main_Page#cite_ref-constructor_1-0" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-constructor-1" class="mw-reference-text">foo</span></li>
-</ol>
-!!end
-
-!!test
-Ref: 5. body should accept generic wikitext
-!! wikitext
-A <ref>
- This is a '''[[bolded link]]''' and this is a {{echo|transclusion}}
-</ref>
-
-<references />
-!! html/parsoid
-<p>A <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="./Main_Page#cite_note-1"><span class="mw-reflink-text">[1]</span></a></span></p>
-
-<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="./Main_Page#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">This is a <b><a rel="mw:WikiLink" href="./Bolded_link" title="Bolded link">bolded link</a></b> and this is a <span about="#mwt3" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"transclusion"}},"i":0}}]}'>transclusion</span>
-</span></li>
-</ol>
-!!end
-
-!!test
-Ref: 6. indent-pres should not be output in ref-body
-!! wikitext
-A <ref>
- foo
- bar
- baz
-</ref>
-
-<references />
-!! html/parsoid
-<p>A <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="./Main_Page#cite_note-1"><span class="mw-reflink-text">[1]</span></a></span></p>
-
-<ol class="mw-references" typeof="mw:Extension/references" about="#mwt4" data-mw='{"name":"references","attrs":{}}'>
-<li about="#cite_note-1" id="cite_note-1"><a href="./Main_Page#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">foo
- bar
- baz
-</span></li>
-</ol>
-!!end
-
-!!test
-Ref: 7. No p-wrapping in ref-body
-!! wikitext
-A <ref>
-foo
-
-bar
-
-
-baz
-
-
-
-booz
-</ref>
-
-<references />
-!! html/parsoid
-<p>A <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="./Main_Page#cite_note-1"><span class="mw-reflink-text">[1]</span></a></span></p>
-
-<ol class="mw-references" typeof="mw:Extension/references" about="#mwt4" data-mw='{"name":"references","attrs":{}}'>
-<li about="#cite_note-1" id="cite_note-1"><a href="./Main_Page#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">foo
-
-bar
-
-
-baz
-
-
-
-booz
-</span></li>
-</ol>
-!!end
-
-!!test
-Ref: 8. transclusion wikitext has lower precedence
-!! wikitext
-A <ref> foo {{echo|</ref> B C}}
-
-<references />
-!! html/parsoid
-<p>A <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="./Main_Page#cite_note-1"><span class="mw-reflink-text">[1]</span></a></span> B C}}</p>
-<ol class="mw-references" typeof="mw:Extension/references" about="#mwt4" data-mw='{"name":"references","attrs":{}}'>
-<li about="#cite_note-1" id="cite_note-1"><a href="./Main_Page#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">foo {{echo|</span></li>
-</ol>
-!!end
-
-!!test
-Ref: 9. unclosed comments should not leak out of ref-body
-!! wikitext
-A <ref> foo <!--</ref> B C
-<references />
-!! html/parsoid
-<p>A <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="./Main_Page#cite_note-1"><span class="mw-reflink-text">[1]</span></a></span> B C</p>
-<ol class="mw-references" typeof="mw:Extension/references" about="#mwt4" data-mw='{"name":"references","attrs":{}}'>
-<li about="#cite_note-1" id="cite_note-1"><a href="./Main_Page#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">foo <!----></span></li>
-</ol>
-!!end
-
-!!test
-Ref: 10. Unclosed HTML tags should not leak out of ref-body
-!! wikitext
-A <ref> <b> foo </ref> B C
-
-<references />
-!! html/parsoid
-<p>A <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="./Main_Page#cite_note-1"><span class="mw-reflink-text">[1]</span></a></span> B C</p>
-
-
-<ol class="mw-references" typeof="mw:Extension/references" about="#mwt4" data-mw='{"name":"references","attrs":{}}'>
-<li about="#cite_note-1" id="cite_note-1"><a href="./Main_Page#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"><b data-parsoid='{"stx":"html","autoInsertedEnd":true}'> foo </b></span></li>
-</ol>
-!!end
-
-!!test
-Ref: 11. ref-tags acts like an inline element wrt P-wrapping
-!! wikitext
-A <ref>foo</ref> B
-C <ref>bar</ref> D
-<references />
-!! html/parsoid
-<p>A <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="./Main_Page#cite_note-1"><span class="mw-reflink-text">[1]</span></a></span> B
-C <span about="#mwt4" class="mw-ref" id="cite_ref-2" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","body":{"id":"mw-reference-text-cite_note-2"},"attrs":{}}'><a href="./Main_Page#cite_note-2"><span class="mw-reflink-text">[2]</span></a></span> D</p>
-<ol class="mw-references" typeof="mw:Extension/references" about="#mwt6" data-mw='{"name":"references","attrs":{}}'>
-<li about="#cite_note-1" id="cite_note-1"><a href="./Main_Page#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">foo</span></li>
-<li about="#cite_note-2" id="cite_note-2"><a href="./Main_Page#cite_ref-2" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-2" class="mw-reference-text">bar</span></li>
-</ol>
-!!end
-
-!!test
-Ref: 12. ref-tags act as trailing newline migration barrier
-!! wikitext
-<!--the newline at the end of this line moves out of the p tag-->a
-
-b<!--the newline at the end of this line stays inside the p tag--> <ref />
-<ref />
-
-c
-<references />
-!! html/parsoid
-<!--the newline at the end of this line moves out of the p tag--><p>a</p>
-
-
-<p>b<!--the newline at the end of this line stays inside the p tag--> <span about="#mwt2" class="mw-ref" id="cite_ref-1" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{}}'><a href="./Main_Page#cite_note-1"><span class="mw-reflink-text">[1]</span></a></span>
-<span about="#mwt4" class="mw-ref" id="cite_ref-2" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{}}'><a href="./Main_Page#cite_note-2"><span class="mw-reflink-text">[2]</span></a></span></p>
-
-<p>c</p>
-<ol class="mw-references" typeof="mw:Extension/references" about="#mwt6" data-mw='{"name":"references","attrs":{}}'>
-<li about="#cite_note-1" id="cite_note-1"><a href="./Main_Page#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"></span></li>
-<li about="#cite_note-2" id="cite_note-2"><a href="./Main_Page#cite_ref-2" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-2" class="mw-reference-text"></span></li></ol>
-!!end
-
-!!test
-Ref: 13. ref-tags are not SOL-transparent and block indent-pres
-!! wikitext
-<ref>foo</ref> A
-<ref>bar
-</ref> B
-<references />
-!! html/parsoid
-<p><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="./Main_Page#cite_note-1"><span class="mw-reflink-text">[1]</span></a></span> A
-<span about="#mwt4" class="mw-ref" id="cite_ref-2" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","body":{"id":"mw-reference-text-cite_note-2"},"attrs":{}}'><a href="./Main_Page#cite_note-2"><span class="mw-reflink-text">[2]</span></a></span> B</p>
-<ol class="mw-references" typeof="mw:Extension/references" about="#mwt6" data-mw='{"name":"references","attrs":{}}'>
-<li about="#cite_note-1" id="cite_note-1"><a href="./Main_Page#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">foo</span></li>
-<li about="#cite_note-2" id="cite_note-2"><a href="./Main_Page#cite_ref-2" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-2" class="mw-reference-text">bar
-</span></li>
-</ol>
-!!end
-
-## Roundtripping fails because of nowiki'ing
-!! test
-Ref: 14. A nested ref-tag should be emitted as plain text
-!! options
-parsoid=wt2html
-!! wikitext
-<ref>foo <ref>bar</ref> baz</ref>
-
-<references />
-!! html/parsoid
-<p><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="./Main_Page#cite_note-1" style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a></span> baz&lt;/ref></p>
-
-<ol class="mw-references" typeof="mw:Extension/references" about="#mwt4" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><a href="./Main_Page#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 &lt;ref>bar</span></li></ol>
-!! end
-
-!!test
-Ref: 15. ref-tags with identical names should get identical indexes
-!! wikitext
-A1 <ref name="a">foo</ref> A2 <ref name="a" />
-B1 <ref name="b" /> B2 <ref name="b">bar</ref>
-
-<references />
-!! html/parsoid
-<p>A1 <span about="#mwt3" class="mw-ref" id="cite_ref-a_1-0" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","body":{"id":"mw-reference-text-cite_note-a-1"},"attrs":{"name":"a"}}'><a href="./Main_Page#cite_note-a-1"><span class="mw-reflink-text">[1]</span></a></span> A2 <span about="#mwt4" class="mw-ref" id="cite_ref-a_1-1" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"name":"a"}}'><a href="./Main_Page#cite_note-a-1"><span class="mw-reflink-text">[1]</span></a></span>
-B1 <span about="#mwt7" class="mw-ref" id="cite_ref-b_2-0" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"name":"b"}}'><a href="./Main_Page#cite_note-b-2"><span class="mw-reflink-text">[2]</span></a></span> B2 <span about="#mwt8" class="mw-ref" id="cite_ref-b_2-1" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","body":{"id":"mw-reference-text-cite_note-b-2"},"attrs":{"name":"b"}}'><a href="./Main_Page#cite_note-b-2"><span class="mw-reflink-text">[2]</span></a></span></p>
-
-<ol class="mw-references" typeof="mw:Extension/references" about="#mwt10" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-a-1" id="cite_note-a-1"><span rel="mw:referencedBy"><a href="./Main_Page#cite_ref-a_1-0"><span class="mw-linkback-text">1 </span></a><a href="./Main_Page#cite_ref-a_1-1"><span class="mw-linkback-text">2 </span></a></span> <span id="mw-reference-text-cite_note-a-1" class="mw-reference-text">foo</span></li><li about="#cite_note-b-2" id="cite_note-b-2"><span rel="mw:referencedBy"><a href="./Main_Page#cite_ref-b_2-0"><span class="mw-linkback-text">1 </span></a><a href="./Main_Page#cite_ref-b_2-1"><span class="mw-linkback-text">2 </span></a></span> <span id="mw-reference-text-cite_note-b-2" class="mw-reference-text">bar</span></li>
-</ol>
-!!end
-
-## We don't bother wt2wt-ing non-standard whitespace
-!!test
-Ref: 16. Tokenizer should accept non-standard whitespace in <ref> and </ref> tags
-!!options
-parsoid=wt2html
-!! wikitext
-A <ref >foo</ref >
-
-<references />
-!! html/parsoid
-<p>A <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="./Main_Page#cite_note-1"><span class="mw-reflink-text">[1]</span></a></span></p>
-<ol class="mw-references" typeof="mw:Extension/references" about="#mwt4" data-mw='{"name":"references","attrs":{}}'>
-<li about="#cite_note-1" id="cite_note-1"><a href="./Main_Page#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">foo</span></li></ol>
-!!end
-
-!!test
-Ref: 17. Generate valid HTML5 id/about attributes
-!!wikitext
-<ref name="a b">foo</ref>
-<ref name=":0">ve-created name</ref>
-
-<references />
-!!html/parsoid
-<p><span about="#mwt2" class="mw-ref" id="cite_ref-a_b_1-0" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","body":{"id":"mw-reference-text-cite_note-a_b-1"},"attrs":{"name":"a b"}}'><a href="./Main_Page#cite_note-a_b-1" style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a></span>
-<span about="#mwt4" class="mw-ref" id="cite_ref-:0_2-0" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","body":{"id":"mw-reference-text-cite_note-:0-2"},"attrs":{"name":":0"}}'><a href="./Main_Page#cite_note-:0-2" style="counter-reset: mw-Ref 2;"><span class="mw-reflink-text">[2]</span></a></span>
-
-<ol class="mw-references" typeof="mw:Extension/references" about="#mwt6" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-a_b-1" id="cite_note-a_b-1"><a href="./Main_Page#cite_ref-a_b_1-0" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-a_b-1" class="mw-reference-text">foo</span></li><li about="#cite_note-:0-2" id="cite_note-:0-2"><a href="./Main_Page#cite_ref-:0_2-0" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-:0-2" class="mw-reference-text">ve-created name</span></li></ol>
-
-!!end
-
-!!test
-Ref: 18. T58916: Extension attributes should be parsed as plain text
-!!wikitext
-<ref name="{{echo|a}}">foo</ref>
-
-<references />
-!!html/parsoid
-<p><span class="mw-ref" id="cite_ref-.7B.7Becho.7Ca.7D.7D_1-0" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","body":{"id":"mw-reference-text-cite_note-.7B.7Becho.7Ca.7D.7D-1"},"attrs":{"name":"{{echo|a}}"}}'><a href="./Main_Page#cite_note-.7B.7Becho.7Ca.7D.7D-1"><span class="mw-reflink-text">[1]</span></a></span>
-</p>
-
-<ol class="mw-references" typeof="mw:Extension/references" about="#mwt4" data-mw='{"name":"references","attrs":{}}'>
-<li about="#cite_note-.7B.7Becho.7Ca.7D.7D-1" id="cite_note-.7B.7Becho.7Ca.7D.7D-1"><a href="./Main_Page#cite_ref-.7B.7Becho.7Ca.7D.7D_1-0" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-.7B.7Becho.7Ca.7D.7D-1" class="mw-reference-text">foo</span></li>
-</ol>
-!!end
-
-!!test
-Ref: 19. ref-tags with identical name encodings should get identical indexes
-!! wikitext
-1 <ref name="a & b">foo</ref> 2 <ref name="a &amp; b" />
-
-<references />
-!! html/parsoid
-<p>1 <span about="#mwt3" class="mw-ref" id="cite_ref-a_.26_b_1-0" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","body":{"id":"mw-reference-text-cite_note-a_.26_b-1"},"attrs":{"name":"a &amp; b"}}'><a href="./Main_Page#cite_note-a_.26_b-1"><span class="mw-reflink-text">[1]</span></a></span> 2 <span about="#mwt4" class="mw-ref" id="cite_ref-a_.26_b_1-1" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"name":"a &amp;amp; b"}}'><a href="./Main_Page#cite_note-a_.26_b-1"><span class="mw-reflink-text">[1]</span></a></span>
-</p>
-<ol class="mw-references" typeof="mw:Extension/references" about="#mwt6" data-mw='{"name":"references","attrs":{}}'>
-<li about="#cite_note-a_.26_b-1" id="cite_note-a_.26_b-1"><span rel="mw:referencedBy"><a href="./Main_Page#cite_ref-a_.26_b_1-0"><span class="mw-linkback-text">1 </span></a><a href="./Main_Page#cite_ref-a_.26_b_1-1"><span class="mw-linkback-text">2 </span></a></span> <span id="mw-reference-text-cite_note-a_.26_b-1" class="mw-reference-text">foo</span></li>
-</ol>
-!!end
-
-!!test
-Ref: 20. ref-tags with identical names but different content should keep it
-!! wikitext
-A <ref name="foo">Foo one</ref>
-B <ref name="foo">Foo two</ref>
-C <ref name="foo" />
-
-<references />
-!! html/parsoid
-<p>A <span about="#mwt2" class="mw-ref" id="cite_ref-foo_1-0" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","body":{"id":"mw-reference-text-cite_note-foo-1"},"attrs":{"name":"foo"}}'><a href="./Main_Page#cite_note-foo-1"><span class="mw-reflink-text">[1]</span></a></span>
-B <span about="#mwt4" class="mw-ref" id="cite_ref-foo_1-1" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","body":{"html":"Foo two"},"attrs":{"name":"foo"}}'><a href="./Main_Page#cite_note-foo-1"><span class="mw-reflink-text">[1]</span></a></span>
-C <span about="#mwt6" class="mw-ref" id="cite_ref-foo_1-2" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"name":"foo"}}'><a href="./Main_Page#cite_note-foo-1"><span class="mw-reflink-text">[1]</span></a></span></p>
-
-<ol class="mw-references" typeof="mw:Extension/references" about="#mwt8" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-foo-1" id="cite_note-foo-1"><span rel="mw:referencedBy"><a href="./Main_Page#cite_ref-foo_1-0"><span class="mw-linkback-text">1 </span></a><a href="./Main_Page#cite_ref-foo_1-1"><span class="mw-linkback-text">2 </span></a><a href="./Main_Page#cite_ref-foo_1-2"><span class="mw-linkback-text">3 </span></a></span> <span id="mw-reference-text-cite_note-foo-1" class="mw-reference-text">Foo one</span></li>
-</ol>
-!!end
-
-!!test
-References: 1. references tag without any refs should be handled properly
-!! wikitext
-<references />
-!! html/parsoid
-<ol class="mw-references" typeof="mw:Extension/references" about="#mwt2" data-mw='{"name":"references","attrs":{}}'></ol>
-!!end
-
-!!test
-References: 2. references tag with group only outputs references from that group
-!! wikitext
-A <ref group="a">foo</ref>
-B <ref group="b">bar</ref>
-C <ref>baz</ref>
-
-<references group="a" />
-<references />
-<references group="b" />
-!! html/parsoid
-<p>A <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":{"group":"a"}}'><a href="./Main_Page#cite_note-1" data-mw-group="a"><span class="mw-reflink-text">[a 1]</span></a></span>
-B <span about="#mwt4" class="mw-ref" id="cite_ref-2" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","body":{"id":"mw-reference-text-cite_note-2"},"attrs":{"group":"b"}}'><a href="./Main_Page#cite_note-2" data-mw-group="b"><span class="mw-reflink-text">[b 1]</span></a></span>
-C <span class="mw-ref" id="cite_ref-3" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","body":{"id":"mw-reference-text-cite_note-3"},"attrs":{}}'><a href="./Main_Page#cite_note-3"><span class="mw-reflink-text">[1]</span></a></span></p>
-
-<ol class="mw-references" typeof="mw:Extension/references" about="#mwt8" data-mw-group="a" data-mw='{"name":"references","attrs":{"group":"a"}}'>
-<li about="#cite_note-1" id="cite_note-1"><a href="./Main_Page#cite_ref-1" data-mw-group="a" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-1" class="mw-reference-text">foo</span></li>
-</ol>
-<ol class="mw-references" typeof="mw:Extension/references" about="#mwt10" data-mw='{"name":"references","attrs":{}}'>
-<li about="#cite_note-3" id="cite_note-3"><a href="./Main_Page#cite_ref-3" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-3" class="mw-reference-text">baz</span></li>
-</ol>
-<ol class="mw-references" typeof="mw:Extension/references" about="#mwt12" data-mw-group="b" data-mw='{"name":"references","attrs":{"group":"b"}}'>
-<li about="#cite_note-2" id="cite_note-2"><a href="./Main_Page#cite_ref-2" data-mw-group="b" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-2" class="mw-reference-text">bar</span></li>
-</ol>
-!!end
-
-!!test
-References: 3. ref list should be cleared after processing references
-!! wikitext
-A <ref>foo</ref>
-
-<references />
-
-B <ref>bar</ref>
-
-<references />
-!! html/parsoid
-<p>A <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="./Main_Page#cite_note-1"><span class="mw-reflink-text">[1]</span></a></span></p>
-
-<ol class="mw-references" typeof="mw:Extension/references" about="#mwt4" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><a href="./Main_Page#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">foo</span></li>
-</ol>
-
-<p>B <span about="#mwt6" class="mw-ref" id="cite_ref-2" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","body":{"id":"mw-reference-text-cite_note-2"},"attrs":{}}'><a href="./Main_Page#cite_note-2"><span class="mw-reflink-text">[1]</span></a></span></p>
-
-<ol class="mw-references" typeof="mw:Extension/references" about="#mwt8" data-mw='{"name":"references","attrs":{}}'>
-<li about="#cite_note-2" id="cite_note-2"><a href="./Main_Page#cite_ref-2" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-2" class="mw-reference-text">bar</span></li>
-</ol>
-!!end
-
-!!test
-References: 4. only referenced group should be cleared after processing references
-!! wikitext
-A <ref group="a">afoo</ref>
-B <ref>bfoo</ref>
-
-<references group="a" />
-
-C <ref>cfoo</ref>
-
-<references />
-!! html/parsoid
-<p>A <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":{"group":"a"}}'><a href="./Main_Page#cite_note-1" data-mw-group="a"><span class="mw-reflink-text">[a 1]</span></a></span>
-B <span about="#mwt4" class="mw-ref" id="cite_ref-2" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","body":{"id":"mw-reference-text-cite_note-2"},"attrs":{}}'><a href="./Main_Page#cite_note-2"><span class="mw-reflink-text">[1]</span></a></span></p>
-
-<ol class="mw-references" typeof="mw:Extension/references" about="#mwt6" data-mw-group="a" data-mw='{"name":"references","attrs":{"group":"a"}}'><li about="#cite_note-1" id="cite_note-1"><a href="./Main_Page#cite_ref-1" data-mw-group="a" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-1" class="mw-reference-text">afoo</span></li>
-</ol>
-
-<p>C <span about="#mwt8" class="mw-ref" id="cite_ref-3" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","body":{"id":"mw-reference-text-cite_note-3"},"attrs":{}}'><a href="./Main_Page#cite_note-3"><span class="mw-reflink-text">[2]</span></a></span></p>
-
-<ol class="mw-references" typeof="mw:Extension/references" about="#mwt10" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-2" id="cite_note-2"><a href="./Main_Page#cite_ref-2" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-2" class="mw-reference-text">bfoo</span></li><li about="#cite_note-3" id="cite_note-3"><a href="./Main_Page#cite_ref-3" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-3" class="mw-reference-text">cfoo</span></li>
-</ol>
-!!end
-
-## Don't expect this to rt since we're dropping content
-!! test
-References: 5. ref tags in references should be processed while ignoring all other content
-!! options
-parsoid=wt2html,html2html
-!! wikitext
-A <ref name="a" />
-B <ref name="b">bar</ref>
-
-<references>
-<ref name="a">foo</ref>
-This should just get lost.
-</references>
-!! html/parsoid
-<p>A <span about="#mwt2" class="mw-ref" id="cite_ref-a_1-0" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"name":"a"}}'><a href="./Main_Page#cite_note-a-1"><span class="mw-reflink-text">[1]</span></a></span>
-B <span about="#mwt4" class="mw-ref" id="cite_ref-b_2-0" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","body":{"id":"mw-reference-text-cite_note-b-2"},"attrs":{"name":"b"}}'><a href="./Main_Page#cite_note-b-2"><span class="mw-reflink-text">[2]</span></a></span></p>
-
-
-<ol class="mw-references" typeof="mw:Extension/references" about="#mwt6" data-mw='{"name":"references","attrs":{},"body":{"html":"\n&lt;span about=\"#mwt8\" class=\"mw-ref\" rel=\"dc:references\" typeof=\"mw:Extension/ref\" data-parsoid=&#39;{\"dsr\":[59,82,14,6]}&#39; data-mw=&#39;{\"name\":\"ref\",\"body\":{\"id\":\"mw-reference-text-cite_note-a-1\"},\"attrs\":{\"name\":\"a\"}}&#39;>&lt;a href=\"./Main_Page#cite_note-a-1\" style=\"counter-reset: mw-Ref 1;\" data-parsoid=\"{}\">&lt;span class=\"mw-reflink-text\" data-parsoid=\"{}\">[1]&lt;/span>&lt;/a>&lt;/span>\n"}}'><li about="#cite_note-a-1" id="cite_note-a-1"><a href="./Main_Page#cite_ref-a_1-0" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-a-1" class="mw-reference-text">foo</span></li><li about="#cite_note-b-2" id="cite_note-b-2"><a href="./Main_Page#cite_ref-b_2-0" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-b-2" class="mw-reference-text">bar</span></li>
-</ol>
-!! end
-
-!! test
-References: 6. <references /> from a transclusion
-!! wikitext
-<ref>Foo</ref> {{echo|<references />}}
-!! html/parsoid
-<p><span about="#mwt3" 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="./Main_Page#cite_note-1"><span class="mw-reflink-text">[1]</span></a></span></p> <ol class="mw-references" typeof="mw:Extension/references mw:Transclusion" about="#mwt4" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;references />"}},"i":0}}]}'><li about="#cite_note-1" id="cite_note-1"><a href="./Main_Page#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">Foo</span></li>
-</ol>
-!! end
-
-!! test
-References: 7. Multiple references tags (one without and one with nested refs) should be correctly handled
-!! wikitext
-A <ref>foo bar for a</ref>
-B <ref group="X" name="b" />
-
-<references />
-
-<references group="X">
-<ref name="b">foo</ref>
-</references>
-!! html/parsoid
-<p>A <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="./Main_Page#cite_note-1"><span class="mw-reflink-text">[1]</span></a></span>
-B <span about="#mwt4" class="mw-ref" id="cite_ref-b_2-0" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"group":"X","name":"b"}}'><a href="./Main_Page#cite_note-b-2" data-mw-group="X"><span class="mw-reflink-text">[X 1]</span></a></span>
-</p>
-
-<ol class="mw-references" typeof="mw:Extension/references" about="#mwt6" data-mw='{"name":"references","attrs":{}}'>
-<li about="#cite_note-1" id="cite_note-1"><a href="./Main_Page#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">foo bar for a</span></li>
-</ol>
-
-<ol class="mw-references" typeof="mw:Extension/references" about="#mwt8" data-mw-group="X" data-mw='{"name":"references","attrs":{"group":"X"},"body":{"html":"\n&lt;span about=\"#mwt10\" class=\"mw-ref\" rel=\"dc:references\" typeof=\"mw:Extension/ref\" data-parsoid=&#39;{\"dsr\":[96,119,14,6]}&#39; data-mw=&#39;{\"name\":\"ref\",\"body\":{\"id\":\"mw-reference-text-cite_note-b-2\"},\"attrs\":{\"name\":\"b\"}}&#39;>&lt;a href=\"./Main_Page#cite_note-b-2\" style=\"counter-reset: mw-Ref 1;\" data-mw-group=\"X\" data-parsoid=\"{}\">&lt;span class=\"mw-reflink-text\" data-parsoid=\"{}\">[X 1]&lt;/span>&lt;/a>&lt;/span>\n"}}'>
-<li about="#cite_note-b-2" id="cite_note-b-2"><a href="./Main_Page#cite_ref-b_2-0" data-mw-group="X" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-b-2" class="mw-reference-text">foo</span></li>
-</ol>
-!! end
-
-!! test
-References: 8. T88019: Remove <meta>s from templates inside <ref> that's itself inside a template
-!! wikitext
-X{{echo|<ref>foo {{echo|<b>bar</b>}} and {{echo|baz}} boo</ref>}}
-<references />
-!! html/parsoid
-<p>X<span about="#mwt2" 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 {{echo|&lt;b>bar&lt;/b>}} and {{echo|baz}} boo&lt;/ref>"}},"i":0}}]}'><a href="./Main_Page#cite_note-1"><span class="mw-reflink-text">[1]</span></a></span></p>
-<ol class="mw-references" typeof="mw:Extension/references" about="#mwt7" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><a href="./Main_Page#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">foo <b data-parsoid='{"stx":"html"}'>bar</b> and baz boo</span></li>
-</ol>
-!!end
-
-# This test only works in wt2html now as the <references /> are always generated
-# unless selser is active. Once T72722 is fixed, we should add a changes test
-# here to ensure that unrelated changes don't add the new <references />
-# when selser is active.
-!! test
-References: 9. Generate missing references list at the end
-!! wikitext
-A <ref>foo</ref>
-B <ref group="inexistent">bar</ref>
-!! html/parsoid
-<p>A <span 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="./Main_Page#cite_note-1"><span class="mw-reflink-text">[1]</span></a></span> B <span class="mw-ref" id="cite_ref-2" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","body":{"id":"mw-reference-text-cite_note-2"},"attrs":{"group":"inexistent"}}'><a href="./Main_Page#cite_note-2" data-mw-group="inexistent"><span class="mw-reflink-text">[inexistent 1]</span></a></span></p>
-<ol class="mw-references" typeof="mw:Extension/references" about="#mwt5" data-mw='{"name":"references","attrs":{},"autoGenerated":true}'>
-<li about="#cite_note-1" id="cite_note-1"><a href="./Main_Page#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">foo</span></li>
-</ol>
-<ol class="mw-references" typeof="mw:Extension/references" about="#mwt6" data-mw-group="inexistent" data-mw='{"name":"references","attrs":{"group":"inexistent"},"autoGenerated":true}'>
-<li about="#cite_note-2" id="cite_note-2"><a href="./Main_Page#cite_ref-2" data-mw-group="inexistent" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-2" class="mw-reference-text">bar</span></li>
-</ol>
-!! end
-
-!! test
-References: 10. New <references/> shouldn't be added for unrelated edits.
-!! options
-parsoid={
-  "modes": ["selser"],
-  "changes": [["#x", "remove"]],
-  "selser": "noauto"
-}
-!! wikitext
-Unrelated text<span id="x"> that's going to disappear</span>.
-A <ref>foo</ref>
-!! wikitext/edited
-Unrelated text.
-A <ref>foo</ref>
-!!end
-
-!! test
-Entities in ref name
-!! wikitext
-<ref name="test &amp; me">hi</ref>
-<references />
-!! html/parsoid
-<p><span about="#mwt2" class="mw-ref" id="cite_ref-test_.26_me_1-0" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","body":{"id":"mw-reference-text-cite_note-test_.26_me-1"},"attrs":{"name":"test &amp;amp; me"}}'><a href="./Main_Page#cite_note-test_.26_me-1"><span class="mw-reflink-text">[1]</span></a></span></p>
-<ol class="mw-references" typeof="mw:Extension/references" about="#mwt4" data-mw='{"name":"references","attrs":{}}'>
-<li about="#cite_note-test_.26_me-1" id="cite_note-test_.26_me-1"><a href="./Main_Page#cite_ref-test_.26_me_1-0" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-test_.26_me-1" class="mw-reference-text">hi</span></li>
-</ol>
-!! end
-
-## The output here may look funny, but it's what the php parser will do.  The
-## unclosed references tag becomes escaped text, and then a new references
-## tag is auto-generated.  The test is wt2html only because it roundtrips with
-## nowiki tags, and the auto-generated references tag is only dropped in
-## rtTestMode.
-!! test
-Generate references for unclosed references tag
-!! options
-parsoid=wt2html
-!! wikitext
-a<ref>foo</ref>
-
-<references>
-!! html/parsoid
-<p>a<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="./Main_Page#cite_note-1" style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a></span></p>
-
-<p>&lt;references></p>
-<ol class="mw-references" typeof="mw:Extension/references" about="#mwt3" data-mw='{"name":"references","attrs":{},"autoGenerated":true}'><li about="#cite_note-1" id="cite_note-1"><a href="./Main_Page#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">foo</span></li></ol>
-!! end
-
-!! test
-New reference serializes on its own line
-!! options
-parsoid=wt2wt,html2wt
-!! wikitext
-foo
-<references />
-!! html/parsoid
-foo<ol class="mw-references" typeof="mw:Extension/references" about="#mwt2" data-mw='{"name":"references","attrs":{}}'></ol>
-!! end
-
 #### ----------------------------------------------------------------
 #### Parsoid-only testing of Parsoid's impl of LST
 #### Not implemented yet, see
@@ -23326,14 +23425,12 @@ parsoid={
 ## recognized as an extension tag w/o a native handler.
 !! test
 LST Sections: Newfangled approach
-!! options
-parsoid={ "suppressErrors": true }
 !! wikitext
 <section begin="2011-05-16" />
 <section end="2014-04-10 (MW 1.23wmf22)" />
 !! html/parsoid
-<p><span typeof="mw:Extension/section" about="#mwt1" data-parsoid='{"stx":"html","selfClose":true,"src":"&lt;section begin=\"2011-05-16\" />","tagWidths":[30,0]}'>&lt;section begin="2011-05-16" /></span>
-<span typeof="mw:Extension/section" about="#mwt2" data-parsoid='{"stx":"html","selfClose":true,"src":"&lt;section end=\"2014-04-10 (MW 1.23wmf22)\" />","tagWidths":[43,0]}'>&lt;section end="2014-04-10 (MW 1.23wmf22)" /></span></p>
+<p><span typeof="mw:Error mw:Extension/section" about="#mwt1" data-mw='{"name":"section","attrs":{"begin":"2011-05-16"},"body":null,"errors":[{"key":"mw-api-extexpand-error","message":"Could not expand extension source."}]}'>&lt;section begin="2011-05-16" /></span>
+<span typeof="mw:Error mw:Extension/section" about="#mwt2" data-mw='{"name":"section","attrs":{"end":"2014-04-10 (MW 1.23wmf22)"},"body":null,"errors":[{"key":"mw-api-extexpand-error","message":"Could not expand extension source."}]}'>&lt;section end="2014-04-10 (MW 1.23wmf22)" /></span></p>
 !! end
 
 #--------- Test stripping of empty nodes in template content ----------
@@ -24360,7 +24457,8 @@ Links 4. ExtLinks: Escapes needed
 parsoid=html2wt
 !! html/parsoid
 <p><a rel="mw:ExtLink" href="http://google.com">[google]</a>
-<a rel="mw:ExtLink" href="http://google.com">google]</a></p>
+<a rel="mw:ExtLink" href="http://google.com">google]</a>
+<a rel="mw:ExtLink" href="http://google.com">goog] le</a></p>
 <p>[http://google.com]</p>
 <p>[http://google.com google]</p>
 <p>[<a rel="mw:ExtLink" href="http://google.com">http://google.com</a>]</p>
@@ -24368,6 +24466,7 @@ parsoid=html2wt
 !! wikitext
 [http://google.com <nowiki>[google]</nowiki>]
 [http://google.com <nowiki>google]</nowiki>]
+[http://google.com <nowiki>goog] le</nowiki>]
 
 <nowiki>[http://google.com]</nowiki>
 
@@ -24379,6 +24478,7 @@ parsoid=html2wt
 !! html/php
 <p><a rel="nofollow" class="external text" href="http://google.com">[google]</a>
 <a rel="nofollow" class="external text" href="http://google.com">google]</a>
+<a rel="nofollow" class="external text" href="http://google.com">goog] le</a>
 </p><p>[http://google.com]
 </p><p>[http://google.com google]
 </p><p>[<a rel="nofollow" class="external free" href="http://google.com">http://google.com</a>]
@@ -24404,7 +24504,7 @@ parsoid=html2wt
 !! end
 
 !! test
-Links 6. Add <nowiki/>s between text-nodes and url-links when required (bug 64300)
+Links 6. Add <nowiki/>s between text-nodes and url-links when required (T66300)
 !! options
 parsoid=html2wt
 !! html/parsoid
@@ -24439,7 +24539,7 @@ http://example.com(x<nowiki/>)
 !! end
 
 !! test
-Links 7a. Don't add spurious <nowiki/>s between text-nodes and url-links (bug 64300)
+Links 7a. Don't add spurious <nowiki/>s between text-nodes and url-links (T66300)
 !! options
 parsoid=html2wt
 !! html/parsoid
 !! end
 
 !! test
-Links 7b. Don't add spurious <nowiki/>s between text-nodes and url-links (bug 64300)
+Links 7b. Don't add spurious <nowiki/>s between text-nodes and url-links (T66300)
 !! options
 parsoid=html2wt
 !! html/parsoid
@@ -24490,7 +24590,7 @@ http://example.com.,;:!?\
 !! end
 
 !! test
-Links 8. Add <nowiki/>s between text-nodes and RFC-links when required (bug 64300)
+Links 8. Add <nowiki/>s between text-nodes and RFC-links when required (T66300)
 !! options
 parsoid=html2wt
 !! html/parsoid
@@ -24504,7 +24604,7 @@ X<nowiki/>RFC 123<nowiki/>y
 !! end
 
 !! test
-Links 9. Don't add spurious <nowiki/>s between text-nodes and RFC-links (bug 64300)
+Links 9. Don't add spurious <nowiki/>s between text-nodes and RFC-links (T66300)
 !! options
 parsoid=html2wt
 !! html/parsoid
@@ -24524,7 +24624,7 @@ RFC 123&foo
 !! end
 
 !! test
-Links 10. Add <nowiki/>s between text-nodes and PMID-links when required (bug 64300)
+Links 10. Add <nowiki/>s between text-nodes and PMID-links when required (T66300)
 !! options
 parsoid=html2wt
 !! html/parsoid
@@ -24538,7 +24638,7 @@ X<nowiki/>PMID 123<nowiki/>y
 !! end
 
 !! test
-Links 11. Don't add spurious <nowiki/>s between text-nodes and PMID-links (bug 64300)
+Links 11. Don't add spurious <nowiki/>s between text-nodes and PMID-links (T66300)
 !! options
 parsoid=html2wt
 !! html/parsoid
@@ -24558,7 +24658,7 @@ PMID 123&foo
 !! end
 
 !! test
-Links 12. Add <nowiki/>s between text-nodes and ISBN-links when required (bug 64300)
+Links 12. Add <nowiki/>s between text-nodes and ISBN-links when required (T66300)
 !! options
 parsoid=html2wt
 !! html/parsoid
@@ -24573,7 +24673,7 @@ a<nowiki/>ISBN 1234567890<nowiki/>b
 !! end
 
 !! test
-Links 13. Don't add spurious <nowiki/>s between text-nodes and ISBN-links (bug 64300)
+Links 13. Don't add spurious <nowiki/>s between text-nodes and ISBN-links (T66300)
 !! options
 parsoid=html2wt
 !! html/parsoid
@@ -24722,7 +24822,7 @@ parsoid=html2wt
 !! test
 4. No escaping needed
 !! options
-options=html2wt
+parsoid=html2wt
 !! html/parsoid
 <p>'<span><i>bar</i></span>'
 '<span><b>bar</b></span>'
@@ -24859,7 +24959,7 @@ parsoid=html2wt
 !! test
 4. Leading whitespace in indent-pre suppressing contexts should not be escaped
 !! options
-options=html2wt
+parsoid=html2wt
 !! html/parsoid
  <figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption>caption</figcaption></figure>
 !! wikitext
@@ -25019,7 +25119,7 @@ parsoid=html2wt
 
 ## The quote-char in the input is necessary for triggering the bug
 !! test
-(Bug 52035) Nowiki-escaping should not get tripped by " :" in text
+(T54035) Nowiki-escaping should not get tripped by " :" in text
 !! options
 parsoid=html2wt
 !! html/parsoid
@@ -25706,7 +25806,7 @@ parsoid=wt2html
 </table>
 !!end
 
-# Parsoid only for bug 64747
+# Parsoid only for T66747
 !! test
 Properly encapsulate empty-content transclusions in fosterable positions
 !! wikitext
@@ -25716,7 +25816,7 @@ Properly encapsulate empty-content transclusions in fosterable positions
 }}
 </table>
 !! html/parsoid
-<table about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":["&lt;table>\n",{"template":{"target":{"wt":"#if:","function":"#if"},"params":{"1":{"wt":"\n&lt;td>foo&lt;/td>\n"}},"i":0}},"\n&lt;/table>"]}' data-parsoid='{"stx":"html","pi":[[{"k":"1"}]]}'>
+<table about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":["&lt;table>\n",{"template":{"target":{"wt":"#if:","function":"if"},"params":{"1":{"wt":"\n&lt;td>foo&lt;/td>\n"}},"i":0}},"\n&lt;/table>"]}' data-parsoid='{"stx":"html","pi":[[{"k":"1"}]]}'>
 
 </table>
 !! end
@@ -25802,7 +25902,7 @@ http://en.wikipedia.org/wiki/Foobar
 
 # 'mi' is a localinterwiki prefix as well as a language
 !! test
-Serialize interwiki links pointing to the current wiki as plain wiki links (bug 65869)
+Serialize interwiki links pointing to the current wiki as plain wiki links (T67869)
 !! options
 parsoid=html2wt
 !! html/parsoid
@@ -25954,7 +26054,7 @@ parsoid={
 !!end
 
 !! test
-Image: Modifying alignment of an image (bug 48665)
+Image: Modifying alignment of an image (T50665)
 !! options
 parsoid={
   "modes": ["wt2wt"],
@@ -25970,7 +26070,7 @@ parsoid={
 !! end
 
 !! test
-Image: Modifying mw-default-size of an frameless image (bug 62805)
+Image: Modifying mw-default-size of an frameless image (T64805)
 !! options
 parsoid={
   "modes": ["wt2wt"],
@@ -25985,7 +26085,7 @@ parsoid={
 !! end
 
 !! test
-Image: Modifying valign of an image (bug 49221)
+Image: Modifying valign of an image (T51221)
 !! options
 parsoid={
   "modes": ["wt2wt"],
@@ -26001,7 +26101,7 @@ parsoid={
 !! end
 
 !! test
-Image: Modifying alt attribute of an image (bug 56400)
+Image: Modifying alt attribute of an image (T58400)
 !! options
 parsoid={
   "modes": ["wt2wt"],
@@ -26031,7 +26131,7 @@ parsoid={
 !!end
 
 !! test
-Image: empty alt attribute (bug 48924)
+Image: empty alt attribute (T50924)
 !! options
 parsoid
 !! wikitext
@@ -26041,7 +26141,7 @@ parsoid
 !! end
 
 !! test
-Image: new attributes should be serialized in wiki's language for RTL languages (bug 51852)
+Image: new attributes should be serialized in wiki's language for RTL languages (T53852)
 !! options
 parsoid=html2wt
 language=ar
@@ -26646,7 +26746,7 @@ parsoid={
 #------------------------------
 
 !!test
-Bug 54262: New entities
+T56262: New entities
 !! options
 parsoid=html2wt
 !! html/parsoid
@@ -26788,7 +26888,7 @@ WTS of autolinks with escapes (editing)
 parsoid={
   "modes": ["wt2wt"],
   "changes": [
-    [ "meta", "remove" ]
+    [ "span", "remove" ]
   ]
 }
 !! wikitext
@@ -27162,6 +27262,16 @@ parsoid=html2wt
 [http://test.com][[one]] two three
 !! end
 
+!! test
+Catch regression when unpacking misnested links
+!! options
+parsoid=wt2html
+!! wikitext
+{{echo|hi}}[http://example.com [[ho]]]
+!! html/parsoid
+<p><span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"hi"}},"i":0}}]}'>hi</span><a rel="mw:ExtLink" href="http://example.com"></a><a rel="mw:WikiLink" href="./Ho" title="Ho" data-parsoid='{"misnested":true}'>ho</a></p>
+!! end
+
 !! test
 Use data-parsoid.firstWikitextNode to compute newline constraints for template content
 !! options
@@ -27213,6 +27323,20 @@ parsoid= {
 # Tests spec'ing wikitext serialization norms |
 # --------------------------------------------
 
+!! test
+Serialize multi-line indent-pre starting with wikitext syntax
+!! options
+parsoid=html2wt
+!! html/parsoid
+<pre>* 1
+** 2
+* 3</pre>
+!! wikitext
+ * 1
+ ** 2
+ * 3
+!! end
+
 !! test
 1. Categories should always be serialized on their own line
 !! options
 |}
 !! end
 
+!! test
+Anchor without href scenarios
+!! options
+parsoid={ "modes": ["html2wt"], "suppressErrors": true }
+!! html/parsoid
+<a class="bc"></a>
+<a class="no">dice</a>
+<a name="foo"></a>
+!! wikitext
+
+dice
+<span name="foo"></span>
+!! end
+
 # -----------------------------------------------------------------
 # End of section for Parsoid-only html2wt tests for serialization
 # of new content