Merge "Parser: Don't generate an external link on "http://)" and similar"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Wed, 5 Aug 2015 20:12:29 +0000 (20:12 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 5 Aug 2015 20:12:29 +0000 (20:12 +0000)
1  2 
tests/parser/parserTests.txt

@@@ -160,22 -160,6 +160,22 @@@ Template:table_attribs_
  |</noinclude>style="color:red;"||Bar
  !! endarticle
  
 +!! article
 +Template:table_attribs_6
 +!! text
 +style="background: <nowiki>
 +
 +
 +red;</nowiki>" |
 +!! endarticle
 +
 +!! article
 +Template:table_attribs_7
 +!! text
 +<noinclude>
 +|</noinclude>style{{=}}"background:&#35;f9f9f9;"|Foo<ref>foo</ref>
 +!! endarticle
 +
  !! article
  Template:table_header_cells
  !! text
@@@ -1330,7 -1314,7 +1330,7 @@@ Non-word characters don't terminate ta
  Non-word characters are valid in extension tags (T19663)
  !! wikitext
  <tåg>tåg</tåg>
 -!! html
 +!! html/php
  <pre>
  'tåg'
  array (
  
  !! test
  Isolated close tags should be treated as literal text (bug 52760)
 +!! options
 +parsoid=wt2html
  !! wikitext
  </b>
  
  <s.foo>s</s>
 -!! html+tidy
 +!! html/php+tidy
 +<p>&lt;s.foo&gt;s</p>
 +!! html/parsoid
  <p>&lt;s.foo&gt;s</p>
  !! end
  
@@@ -1383,11 -1363,9 +1383,11 @@@ Bare pipe character from a template (bu
  <nowiki> unordered list
  !! wikitext
  <nowiki>* This is not an unordered list item.</nowiki>
 -!! html
 +!! html/php
  <p>* This is not an unordered list item.
  </p>
 +!! html/parsoid
 +<p><span typeof="mw:Nowiki">* This is not an unordered list item.</span></p>
  !! end
  
  !! test
@@@ -1400,7 -1378,7 +1400,7 @@@ sed abit
  
  :and a colon
  </nowiki>
 -!! html
 +!! html/php
  <p>Lorem ipsum dolor
  
  sed abit.
  :and a colon
  
  </p>
 +!! html/parsoid
 +<p><span typeof="mw:Nowiki">Lorem ipsum dolor
 +
 +sed abit.
 +  sed nullum.
 +
 +:and a colon
 +</span></p>
  !! end
  
  !! test
@@@ -1430,7 -1400,7 +1430,7 @@@ nowiki 
  
  *There is not nowiki.
  *There is <nowiki>nowiki</nowiki>.
 -!! html
 +!! html/php
  <dl><dd>There is not nowiki.</dd>
  <dd>There is nowiki.</dd></dl>
  <ol><li>There is not nowiki.</li>
  <ul><li>There is not nowiki.</li>
  <li>There is nowiki.</li></ul>
  
 +!! html/parsoid
 +<dl><dd data-parsoid='{}'>There is not nowiki.</dd>
 +<dd data-parsoid='{}'>There is <span typeof="mw:Nowiki">nowiki</span>.</dd></dl>
 +
 +<ol><li data-parsoid='{}'>There is not nowiki.</li>
 +<li data-parsoid='{}'>There is <span typeof="mw:Nowiki">nowiki</span>.</li></ol>
 +
 +<ul><li data-parsoid='{}'>There is not nowiki.</li>
 +<li data-parsoid='{}'>There is <span typeof="mw:Nowiki">nowiki</span>.</li></ul>
  !! end
  
  !! test
@@@ -1475,7 -1436,7 +1475,7 @@@ parsoid=html2w
  !! html
  <p>* &lt;/nowiki&gt; tag</p>
  !! wikitext
 -<nowiki>* &lt;/nowiki&gt;</nowiki> tag
 +<nowiki>*</nowiki> <nowiki>&lt;/nowiki&gt;</nowiki> tag
  !! end
  
  !! test
@@@ -2262,7 -2223,7 +2262,7 @@@ Entities inside <pre
  </nowiki>
  </pre>
  
 -!! html
 +!! html/php
  <pre>
  &lt;nowiki&gt;
  </pre>
  
  &lt;/pre&gt;
  </p>
 +!! html/parsoid
 +<pre data-parsoid='{"stx":"html","strippedNL":true}'>&lt;nowiki>
 +</pre>
 +<p><span typeof="mw:Placeholder" data-parsoid='{"src":"&lt;/nowiki>"}'>&lt;/nowiki></span>
 +&lt;/pre></p>
 +
 +<p><span typeof="mw:Nowiki">
 +&lt;pre>
 +&lt;nowiki>
 +&lt;/pre>
 +</span>
 +&lt;/pre></p>
  !! end
  
  !! test
@@@ -3448,7 -3397,7 +3448,7 @@@ HTML-pre: 3: other wikitex
  '' no-italic ''
  [[ NoLink ]]
  </pre>
 -!! html
 +!! html/php
  <pre>
  * foo
  # bar
  [[ NoLink ]]
  </pre>
  
 +!! html/parsoid
 +<pre data-parsoid='{"stx":"html","strippedNL":true}'>* foo
 +# bar
 += no-h =
 +'' no-italic ''
 +[[ NoLink ]]
 +</pre>
  !!end
  
  ###
@@@ -4294,17 -4236,6 +4294,17 @@@ Definition Lists: colons occurring in t
  </dl>
  </dd>
  </dl>
 +!! html/parsoid
 +<dl><dt>a</dt><dd data-parsoid='{"stx":"row"}'>b</dd>
 +<dt><b>a:b</b></dt>
 +<dt><i data-parsoid='{"stx":"html"}'>a:b</i></dt>
 +<dt><span data-parsoid='{"stx":"html"}'>a:b</span></dt>
 +<dt><div data-parsoid='{"stx":"html"}'>a:b</div></dt>
 +<dt><div data-parsoid='{"stx":"html","autoInsertedEnd":true}'>a</div></dt>
 +<dd>b</dd>
 +<dt><span about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"1","spc":["","","",""]}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"a:b"}},"i":0}}]}'>a:b</span></dt>
 +<dt><i about="#mwt2" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"1","spc":["","","",""]}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&#39;&#39;a:b&#39;&#39;"}},"i":0}}]}'>a:b</i>
 +<dl><dt><dl><dt><i>a:b</i></dt></dl></dt></dl></dt></dl>
  !! end
  
  !! test
@@@ -4625,6 -4556,25 +4625,25 @@@ http://example.com/url_with_entity&#60
  <a rel="mw:ExtLink" href="http://example.com/url_with_entity&lt;">http://example.com/url_with_entity&lt;</a></p>
  !! end
  
+ !! test
+ External links: Lone protocols are never linked (T105697)
+ !! wikitext
+ http://
+ http://;
+ (http://)
+ bitcoin:
+ bitcoin:;
+ (bitcoin:)
+ !! html
+ <p>http://
+ http://;
+ (http://)
+ bitcoin:
+ bitcoin:;
+ (bitcoin:)
+ </p>
+ !! end
  !! test
  External links: No preceding word characters allowed (bug 65278)
  !! wikitext
@@@ -6232,21 -6182,6 +6251,21 @@@ Indented table markup mixed with indent
  </tbody></table>
  !! end
  
 +## Edge case fix to prevent future regressions
 +!! test
 +T107652: <ref>s in templates that also generate table cell attributes should be rendered properly
 +!! wikitext
 +{|
 +|{{table_attribs_7}}
 +|}
 +<references />
 +!! html/parsoid
 +<table>
 +<tbody><tr><td style="background:#f9f9f9;" typeof="mw:Transclusion" about="#mwt1" data-mw='{"parts":["|",{"template":{"target":{"wt":"table_attribs_7","href":"./Template:Table_attribs_7"},"params":{},"i":0}}]}'>Foo<span class="mw-ref" id="cite_ref-1" rel="dc:references" data-mw='{"name":"ref","body":{"id":"mw-reference-text-cite_note-1"},"attrs":{}}'><a href="#cite_note-1" style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a></span></td></tr>
 +</tbody></table>
 +<ol class="mw-references" typeof="mw:Extension/references" about="#mwt5" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><a href="#cite_ref-1" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-1" class="mw-reference-text" data-parsoid="{}">foo</span></li></ol>
 +!! end
 +
  !! test
  Table with row followed by newlines and table heading
  !! wikitext
@@@ -9716,15 -9651,6 +9735,15 @@@ __NOEDITSECTION_
  <meta property="mw:PageProp/noeditsection" data-parsoid='{"magicSrc":"__NOEDITSECTION__"}'/>
  !! end
  
 +!!test
 +__proto__ is treated as normal wikitext (T105997)
 +!!wikitext
 +__proto__
 +!!html
 +<p>__proto__
 +</p>
 +!!end
 +
  ###
  ### Magic links
  ###
@@@ -10309,7 -10235,7 +10328,7 @@@ File:Foobar.jp
  msgnw keyword
  !! wikitext
  {{msgnw:MSGNW test}}
 -!! html
 +!! html/php
  <p>&#39;&#39;None&#39;&#39; of &#39;&#39;&#39;this&#39;&#39;&#39; should be 
  &#42; interpreted
  &#32;but rather passed unmodified
@@@ -11097,25 -11023,6 +11116,25 @@@ Templates: Support for templates genera
  </tbody></table>
  !! end
  
 +# T107622
 +!! test
 +4. Entities and nowikis inside templated attributes should be handled correctly inside templated tables
 +!! wikitext
 +{|
 +| {{table_attribs_6}} hi
 +|}
 +!! html/php
 +<table>
 +<tr>
 +<td style="background: red;"> hi
 +</td></tr></table>
 +
 +!! html/parsoid
 +<table>
 +<tbody><tr><td style="background:  red;" typeof="mw:Transclusion" about="#mwt1" data-parsoid='{"autoInsertedEnd":true,"pi":[[]]}' data-mw='{"parts":["| ",{"template":{"target":{"wt":"table_attribs_6","href":"./Template:Table_attribs_6"},"params":{},"i":0}}," hi"]}'> hi</td></tr>
 +</tbody></table>
 +!! end
 +
  !!test
  Templates: HTML Tables: 1. Generating start of a HTML table
  !! wikitext
@@@ -11580,40 -11487,41 +11599,40 @@@ Parser Functions: 2. Nested use (only o
  !! test
  pre-save transform: subst:
  !! options
 -PST
 +pst
  !! wikitext
  {{subst:test}}
 -!! html
 +!! html/php
  This is a test template
  !! end
  
  !! test
  pre-save transform: normal template
  !! options
 -PST
 +pst
  !! wikitext
  {{test}}
 -!! html
 +!! html/php
  {{test}}
  !! end
  
  !! test
  pre-save transform: nonexistent template
  !! options
 -PST
 +pst
  !! wikitext
  {{thistemplatedoesnotexist}}
 -!! html
 +!! html/php
  {{thistemplatedoesnotexist}}
  !! end
  
 -
  !! test
  pre-save transform: subst magic variables
  !! options
 -PST
 +pst
  !! wikitext
  {{subst:SITENAME}}
 -!! html
 +!! html/php
  MediaWiki
  !! end
  
@@@ -11624,7 -11532,7 +11643,7 @@@ pre-save transform: subst: templates wi
  pst
  !! wikitext
  {{subst:paramtest|param="something else"}}
 -!! html
 +!! html/php
  This is a test template with parameter "something else"
  !! end
  
@@@ -11640,10 -11548,11 +11659,10 @@@ pre-save transform: nowiki in subst (bu
  pst
  !! wikitext
  {{subst:nowikitest}}
 -!! html
 +!! html/php
  <nowiki>'''not wiki'''</nowiki>
  !! end
  
 -
  !! article
  Template:commenttest
  !! text
@@@ -11656,7 -11565,7 +11675,7 @@@ pre-save transform: comment in subst (b
  pst
  !! wikitext
  {{subst:commenttest}}
 -!! html
 +!! html/php
  This template has <!-- a comment --> in it.
  !! end
  
@@@ -11666,7 -11575,7 +11685,7 @@@ pre-save transform: unclosed ta
  pst noxml
  !! wikitext
  <nowiki>'''not wiki'''
 -!! html
 +!! html/php
  <nowiki>'''not wiki'''
  !! end
  
@@@ -11676,7 -11585,7 +11695,7 @@@ pre-save transform: mixed tag cas
  pst noxml
  !! wikitext
  <NOwiki>'''not wiki'''</noWIKI>
 -!! html
 +!! html/php
  <NOwiki>'''not wiki'''</noWIKI>
  !! end
  
@@@ -11686,7 -11595,7 +11705,7 @@@ pre-save transform: unclosed comment i
  pst noxml
  !! wikitext
  wiki<nowiki>nowiki<!--nowiki</nowiki>wiki
 -!! html
 +!! html/php
  wiki<nowiki>nowiki<!--nowiki</nowiki>wiki
  !!end
  
@@@ -11714,7 -11623,7 +11733,7 @@@ pre-save transform: comment containing 
  pst
  !! wikitext
  <!-- <gallery>data</gallery> -->
 -!! html
 +!! html/php
  <!-- <gallery>data</gallery> -->
  !!end
  
@@@ -11724,7 -11633,7 +11743,7 @@@ pre-save transform: comment containing 
  pst
  !! wikitext
  <!-- <tag>data</tag> -->
 -!! html
 +!! html/php
  <!-- <tag>data</tag> -->
  !!end
  
@@@ -11734,7 -11643,7 +11753,7 @@@ pre-save transform: comment containing 
  pst
  !! wikitext
  <!-- <nowiki>data</nowiki> -->
 -!! html
 +!! html/php
  <!-- <nowiki>data</nowiki> -->
  !!end
  
@@@ -11744,7 -11653,7 +11763,7 @@@ pre-save transform: <noinclude> in subs
  pst
  !! wikitext
  {{subst:Includes}}
 -!! html
 +!! html/php
  Foobar
  !! end
  
@@@ -11754,7 -11663,7 +11773,7 @@@ pre-save transform: <onlyinclude> in su
  pst
  !! wikitext
  {{subst:Includes2}}
 -!! html
 +!! html/php
  Foo
  !! end
  
@@@ -11776,7 -11685,7 +11795,7 @@@ bug 22297: safesubst: works during PS
  pst
  !! wikitext
  {{subst:SafeSubstTest}}{{safesubst:SubstTest}}
 -!! html
 +!! html/php
  FoobarFoobar
  !! end
  
  [[|Article (context)]]
  [[Bar:X (Y) Z|]]
  [[:Bar:X (Y) Z|]]
 -!! html
 +!! html/php
  [[Article (context)|Article]]
  [[Bar:Article|Article]]
  [[:Bar:Article|Article]]
  [[:interwiki:Article|]]
  [[interwiki:Bar:Article|]]
  [[:interwiki:Bar:Article|]]
 -!! html
 +!! html/php
  [[interwiki:Article|Article]]
  [[:interwiki:Article|Article]]
  [[interwiki:Bar:Article|Bar:Article]]
@@@ -11846,7 -11755,7 +11865,7 @@@ pre-save transform: context links ("pip
  pst title=[[Somearticle (context)]]
  !! wikitext
  [[|Article]]
 -!! html
 +!! html/php
  [[Article (context)|Article]]
  !! end
  
@@@ -11858,7 -11767,7 +11877,7 @@@ pst title=[[Someplace, Somewhere]
  [[|Otherplace]]
  [[Otherplace, Elsewhere|]]
  [[Otherplace, Elsewhere, Anywhere|]]
 -!! html
 +!! html/php
  [[Otherplace, Somewhere|Otherplace]]
  [[Otherplace, Elsewhere|Otherplace]]
  [[Otherplace, Elsewhere, Anywhere|Otherplace]]
@@@ -11871,7 -11780,7 +11890,7 @@@ pst title=[[Someplace (IGNORED), Somewh
  !! wikitext
  [[|Otherplace]]
  [[Otherplace (place), Elsewhere|]]
 -!! html
 +!! html/php
  [[Otherplace, Somewhere|Otherplace]]
  [[Otherplace (place), Elsewhere|Otherplace]]
  !! end
@@@ -11883,7 -11792,7 +11902,7 @@@ pst title=[[Who, me? (context)]
  !! wikitext
  [[|Yes, you.]]
  [[Me, Myself, and I (1937 song)|]]
 -!! html
 +!! html/php
  [[Yes, you. (context)|Yes, you.]]
  [[Me, Myself, and I (1937 song)|Me, Myself, and I]]
  !! end
@@@ -11894,7 -11803,7 +11913,7 @@@ pre-save transform: context links ("pip
  pst title=[[Ns:Somearticle]]
  !! wikitext
  [[|Article]]
 -!! html
 +!! html/php
  [[Ns:Article|Article]]
  !! end
  
@@@ -11904,7 -11813,7 +11923,7 @@@ pre-save transform: context links ("pip
  pst title=[[Ns:Somearticle (context)]]
  !! wikitext
  [[|Article]]
 -!! html
 +!! html/php
  [[Ns:Article (context)|Article]]
  !! end
  
@@@ -11914,7 -11823,7 +11933,7 @@@ pre-save transform: context links ("pip
  pst title=[[Ns:Somearticle, Context, Whatever]]
  !! wikitext
  [[|Article]]
 -!! html
 +!! html/php
  [[Ns:Article, Context, Whatever|Article]]
  !! end
  
@@@ -11924,7 -11833,7 +11943,7 @@@ pre-save transform: context links ("pip
  pst title=[[Ns:Somearticle, Context (context)]]
  !! wikitext
  [[|Article]]
 -!! html
 +!! html/php
  [[Ns:Article (context)|Article]]
  !! end
  
@@@ -11934,7 -11843,7 +11953,7 @@@ pre-save transform: context links ("pip
  pst title=[[Ns:Somearticle (IGNORED), Context]]
  !! wikitext
  [[|Article]]
 -!! html
 +!! html/php
  [[Ns:Article, Context|Article]]
  !! end
  
  [[|Article(context)]]
  [[Bar:X(Y)Z|]]
  [[:Bar:X(Y)Z|]]
 -!! html
 +!! html/php
  [[Article(context)|Article]]
  [[Bar:Article(context)|Article]]
  [[:Bar:Article(context)|Article]]
  [[|Article (context)]]
  [[Bar:X (Y) Z|]]
  [[:Bar:X (Y) Z|]]
 -!! html
 +!! html/php
  [[Article (context)|Article]]
  [[Bar:Article (context)|Article]]
  [[:Bar:Article (context)|Article]]
  [[|Article(context)]]
  [[Bar:X(Y)Z|]]
  [[:Bar:X(Y)Z|]]
 -!! html
 +!! html/php
  [[Article(context)|Article]]
  [[Bar:Article(context)|Article]]
  [[:Bar:Article(context)|Article]]
  [[Bar:Article (context),context|]]
  [[:Bar:Article (context), context|]]
  [[:Bar:Article (context),context|]]
 -!! html
 +!! html/php
  [[Article (context), context|Article]]
  [[Article (context),context|Article]]
  [[Bar:Article (context), context|Article]]
@@@ -12028,7 -11937,7 +12047,7 @@@ Empty lines are trimme
  
  
  
 -!! html
 +!! html/php
  Empty lines are trimmed
  !! end
  
  * <noinclude>~~~</noinclude>
  * <includeonly>~~~</includeonly>
  * <onlyinclude>~~~</onlyinclude>
 -!! html
 +!! html/php
  * [[Special:Contributions/127.0.0.1|127.0.0.1]]
  * <noinclude>[[Special:Contributions/127.0.0.1|127.0.0.1]]</noinclude>
  * <includeonly>[[Special:Contributions/127.0.0.1|127.0.0.1]]</includeonly>
@@@ -12072,7 -11981,7 +12091,7 @@@ As well as inside noinclude/onlyinclud
  
  But not inside includeonly
  <includeonly>{{subst:Foo}}</includeonly>
 -!! html
 +!! html/php
  Shall not expand:
  
  <nowiki>~~~~</nowiki>
@@@ -15722,7 -15631,7 +15741,7 @@@ evil <math>-wiki-tags without Extension
  Parser hook: empty input
  !! wikitext
  <tag></tag>
 -!! html
 +!! html/php
  <pre>
  ''
  array (
  Parser hook: empty input using terminated empty elements
  !! wikitext
  <tag/>
 -!! html
 +!! html/php
  <pre>
  NULL
  array (
  Parser hook: empty input using terminated empty elements (space before)
  !! wikitext
  <tag />
 -!! html
 +!! html/php
  <pre>
  NULL
  array (
  Parser hook: basic input
  !! wikitext
  <tag>input</tag>
 -!! html
 +!! html/php
  <pre>
  'input'
  array (
  Parser hook: case insensitive
  !! wikitext
  <TAG>input</TAG>
 -!! html
 +!! html/php
  <pre>
  'input'
  array (
  Parser hook: case insensitive, redux
  !! wikitext
  <TaG>input</TAg>
 -!! html
 +!! html/php
  <pre>
  'input'
  array (
@@@ -15804,7 -15713,7 +15823,7 @@@ Parser hook: nested tag
  noxml
  !! wikitext
  <tag><tag></tag></tag>
 -!! html
 +!! html/php
  <pre>
  '<tag>'
  array (
  Parser hook: basic arguments
  !! wikitext
  <tag width=200 height = "100" depth = '50' square></tag>
 -!! html
 +!! html/php
  <pre>
  ''
  array (
  Parser hook: argument containing a forward slash (bug 5344)
  !! wikitext
  <tag filename='/tmp/bla'></tag>
 -!! html
 +!! html/php
  <pre>
  ''
  array (
  Parser hook: empty input using terminated empty elements (bug 2374)
  !! wikitext
  <tag foo=bar/>text
 -!! html
 +!! html/php
  <pre>
  NULL
  array (
@@@ -15865,7 -15774,7 +15884,7 @@@ Parser hook: basic arguments using term
  <tag width=200 height = "100" depth = '50' square/>
  other stuff
  </tag>
 -!! html
 +!! html/php
  <pre>
  NULL
  array (
@@@ -15889,7 -15798,7 +15908,7 @@@ Parser hook: static parser hook not ins
  !! wikitext
  <statictag>hello, world</statictag>
  <statictag action=flush/>
 -!! html
 +!! html/php
  <p>hello, world
  </p>
  !! end
@@@ -15900,7 -15809,7 +15919,7 @@@ Parser hook: static parser hook inside 
  !! wikitext
  <!-- <statictag>hello, world</statictag> -->
  <statictag action=flush/>
 -!! html
 +!! html/php
  <p><br />
  </p>
  !! end
@@@ -15959,24 -15868,20 +15978,24 @@@ Sanitizer: Closing of open but not clos
  
  !! test
  Sanitizer: Closing of closed but not open tags
 +!! options
 +parsoid=wt2html
  !! wikitext
  </s>
 -!! html
 -<p>&lt;/s&gt;
 -</p>
 +!! html/php+tidy
 +!! html/parsoid
  !! end
  
  !! test
  Sanitizer: Closing of closed but not open table tags
 +!! options
 +parsoid=wt2html
  !! wikitext
  Table not started</td></tr></table>
 -!! html
 -<p>Table not started&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
 -</p>
 +!! html/php+tidy
 +<p>Table not started</p>
 +!! html/parsoid
 +<p>Table not started</p>
  !! end
  
  !! test
@@@ -16775,7 -16680,7 +16794,7 @@@ star
  ===bc===
  ==c==
  ===ca===
 -!! html
 +!! html/php
  start
  !! end
  
@@@ -16795,7 -16700,7 +16814,7 @@@ star
  ===bc===
  ==c==
  ===ca===
 -!! html
 +!! html/php
  ==a==
  ===aa===
  ====aaa====
@@@ -16817,7 -16722,7 +16836,7 @@@ star
  ===bc===
  ==c==
  ===ca===
 -!! html
 +!! html/php
  ===aa===
  ====aaa====
  !! end
@@@ -16838,7 -16743,7 +16857,7 @@@ star
  ===bc===
  ==c==
  ===ca===
 -!! html
 +!! html/php
  ====aaa====
  !! end
  
@@@ -16858,7 -16763,7 +16877,7 @@@ star
  ===bc===
  ==c==
  ===ca===
 -!! html
 +!! html/php
  ==b==
  ===ba===
  ===bb===
@@@ -16882,7 -16787,7 +16901,7 @@@ star
  ===bc===
  ==c==
  ===ca===
 -!! html
 +!! html/php
  ===ba===
  !! end
  
@@@ -16902,7 -16807,7 +16921,7 @@@ star
  ===bc===
  ==c==
  ===ca===
 -!! html
 +!! html/php
  ===bb===
  ====bba====
  !! end
@@@ -16923,7 -16828,7 +16942,7 @@@ star
  ===bc===
  ==c==
  ===ca===
 -!! html
 +!! html/php
  ====bba====
  !! end
  
@@@ -16943,7 -16848,7 +16962,7 @@@ star
  ===bc===
  ==c==
  ===ca===
 -!! html
 +!! html/php
  ===bc===
  !! end
  
@@@ -16963,7 -16868,7 +16982,7 @@@ star
  ===bc===
  ==c==
  ===ca===
 -!! html
 +!! html/php
  ==c==
  ===ca===
  !! end
@@@ -16984,7 -16889,7 +17003,7 @@@ star
  ===bc===
  ==c==
  ===ca===
 -!! html
 +!! html/php
  ===ca===
  !! end
  
@@@ -17004,7 -16909,7 +17023,7 @@@ star
  ===bc===
  ==c==
  ===ca===
 -!! html
 +!! html/php
  !! end
  
  !! test
@@@ -17015,7 -16920,7 +17034,7 @@@ section=
  ==a==
  ==bogus== not a legal section
  ==b==
 -!! html
 +!! html/php
  ==a==
  ==bogus== not a legal section
  !! end
@@@ -17028,7 -16933,7 +17047,7 @@@ section=
  ==a==
  ==bogus== not a legal section
  ==b==
 -!! html
 +!! html/php
  ==b==
  !! end
  
@@@ -17040,7 -16945,7 +17059,7 @@@ section=
  ==a==
  ==b== <!-- -->
  ==c==
 -!! html
 +!! html/php
  ==a==
  !! end
  
@@@ -17052,7 -16957,7 +17071,7 @@@ section=
  ==a==
  ==b== <!-- -->
  ==c==
 -!! html
 +!! html/php
  ==b== <!-- -->
  !! end
  
@@@ -17064,7 -16969,7 +17083,7 @@@ section=
  ==a==
  ==bogus== <nowiki>not a legal section</nowiki>
  ==b==
 -!! html
 +!! html/php
  ==a==
  ==bogus== <nowiki>not a legal section</nowiki>
  !! end
@@@ -17077,10 -16982,11 +17096,10 @@@ section=
  ==a==
  ==bogus== <nowiki>not a legal section</nowiki>
  ==b==
 -!! html
 +!! html/php
  ==b==
  !! end
  
 -
  # Formerly testing for bug 2587, now resolved by the use of unmarked sections
  # instead of respecting commented sections
  !! test
@@@ -17090,7 -16996,7 +17109,7 @@@ section=
  !! wikitext
  <!-- -->==sec1==
  ==sec2==
 -!! html
 +!! html/php
  ==sec2==
  !!end
  
@@@ -17101,10 -17007,11 +17120,10 @@@ section=
  !! wikitext
  <!-- -->==sec1==
  ==sec2==
 -!! html
 +!! html/php
  
  !!end
  
 -
  # Formerly testing for bug 2607, now resolved by the use of unmarked sections
  # instead of respecting HTML-style headings
  !! test
@@@ -17118,7 -17025,7 +17137,7 @@@ unmarke
  one
  ==2==
  two
 -!! html
 +!! html/php
  ==1==
  one
  !! end
@@@ -17134,7 -17041,7 +17153,7 @@@ unmarke
  one
  ==2==
  two
 -!! html
 +!! html/php
  ==2==
  two
  !! end
@@@ -17148,7 -17055,7 +17167,7 @@@ section=
  !! wikitext
  <noinclude>==unmarked==</noinclude>
  ==marked==
 -!! html
 +!! html/php
  ==marked==
  !!end
  
@@@ -17163,7 -17070,7 +17182,7 @@@ The line above must have a trailing spa
  === <!--
  --> <!-- -->
  But just in case it doesn't...
 -!! html
 +!! html/php
  === <!--
  --> <!-- -->
  But just in case it doesn't...
@@@ -17185,7 -17092,7 +17204,7 @@@ star
  ===bc===
  ==c==
  ===ca===
 -!! html
 +!! html/php
  xxx
  
  ==a==
@@@ -17216,7 -17123,7 +17235,7 @@@ star
  ===bc===
  ==c==
  ===ca===
 -!! html
 +!! html/php
  start
  xxx
  
@@@ -17245,7 -17152,7 +17264,7 @@@ star
  ===bc===
  ==c==
  ===ca===
 -!! html
 +!! html/php
  start
  ==a==
  xxx
@@@ -17275,7 -17182,7 +17294,7 @@@ star
  ===bc===
  ==c==
  ===ca===
 -!! html
 +!! html/php
  start
  ==a==
  ===aa===
@@@ -17306,7 -17213,7 +17325,7 @@@ star
  ===bc===
  ==c==
  ===ca===
 -!! html
 +!! html/php
  start
  ==a==
  ===aa===
@@@ -17333,7 -17240,7 +17352,7 @@@ star
  ===bc===
  ==c==
  ===ca===
 -!! html
 +!! html/php
  start
  ==a==
  ===aa===
@@@ -17364,7 -17271,7 +17383,7 @@@ star
  ===bc===
  ==c==
  ===ca===
 -!! html
 +!! html/php
  start
  ==a==
  ===aa===
@@@ -17394,7 -17301,7 +17413,7 @@@ star
  ===bc===
  ==c==
  ===ca===
 -!! html
 +!! html/php
  start
  ==a==
  ===aa===
@@@ -17425,7 -17332,7 +17444,7 @@@ star
  ===bc===
  ==c==
  ===ca===
 -!! html
 +!! html/php
  start
  ==a==
  ===aa===
@@@ -17456,7 -17363,7 +17475,7 @@@ star
  ===bc===
  ==c==
  ===ca===
 -!! html
 +!! html/php
  start
  ==a==
  ===aa===
@@@ -17485,7 -17392,7 +17504,7 @@@ star
  ===bc===
  ==c==
  ===ca===
 -!! html
 +!! html/php
  start
  ==a==
  ===aa===
@@@ -17507,7 -17414,7 +17526,7 @@@ replace=2,"xxx
   Preformatted initial line
  ==a==
  ===a===
 -!! html
 +!! html/php
   Preformatted initial line
  ==a==
  xxx
@@@ -17521,7 -17428,7 +17540,7 @@@ section=
  !! wikitext
  ==a==
                      a
 -!! html
 +!! html/php
  ==a==
                      a
  !! end
@@@ -17533,7 -17440,7 +17552,7 @@@ section=
  !! wikitext
  ==a==
                     a
 -!! html
 +!! html/php
  ==a==
                     a
  !! end
@@@ -17551,7 -17458,7 +17570,7 @@@ noxml section=
  
  == Section Two ==
  stuff
 -!! html
 +!! html/php
  == Section Two ==
  stuff
  !! end
@@@ -17568,7 -17475,7 +17587,7 @@@ noxml replace=2,"xxx
  
  == Section Two ==
  stuff
 -!! html
 +!! html/php
  == Section One ==
  <pre>
  =======
  !! end
  
  
 -
  !! test
  Handling of &#x0A; in URLs
  !! wikitext
@@@ -18364,7 -18272,7 +18383,7 @@@ Don't fall for the self-closing di
  MSGNW magic word
  !! wikitext
  {{MSGNW:msg}}
 -!! html
 +!! html/php
  <p>&#91;&#91;:Template:Msg&#93;&#93;
  </p>
  !! end
@@@ -19797,7 -19705,7 +19816,7 @@@ wgAllowDisplayTitle=tru
  wgRestrictDisplayTitle=false
  !! wikitext
  this is not the the title
 -!! html
 +!! html/php
  Parser test
  <p>this is not the the title
  </p>
@@@ -19814,7 -19722,7 +19833,7 @@@ wgRestrictDisplayTitle=fals
  !! wikitext
  this is not the the title
  {{DISPLAYTITLE:whatever}}
 -!! html
 +!! html/php
  whatever
  <p>this is not the the title
  </p>
@@@ -19831,7 -19739,7 +19850,7 @@@ wgRestrictDisplayTitle=tru
  !! wikitext
  this is not the the title
  {{DISPLAYTITLE:whatever}}
 -!! html
 +!! html/php
  Screen
  <p>this is not the the title
  </p>
@@@ -19848,7 -19756,7 +19867,7 @@@ wgRestrictDisplayTitle=tru
  !! wikitext
  this is not the the title
  {{DISPLAYTITLE:screen}}
 -!! html
 +!! html/php
  screen
  <p>this is not the the title
  </p>
@@@ -19864,7 -19772,7 +19883,7 @@@ wgAllowDisplayTitle=fals
  !! wikitext
  this is not the the title
  {{DISPLAYTITLE:screen}}
 -!! html
 +!! html/php
  Screen
  <p>this is not the the title
  <a href="/index.php?title=Template:DISPLAYTITLE:screen&amp;action=edit&amp;redlink=1" class="new" title="Template:DISPLAYTITLE:screen (page does not exist)">Template:DISPLAYTITLE:screen</a>
@@@ -19880,7 -19788,7 +19899,7 @@@ title=[[Screen]
  wgAllowDisplayTitle=false
  !! wikitext
  this is not the the title
 -!! html
 +!! html/php
  Screen
  <p>this is not the the title
  </p>
@@@ -19897,7 -19805,7 +19916,7 @@@ wgRestrictDisplayTitle=tru
  !! wikitext
  this is not the the title
  {{DISPLAYTITLE:<span style="display: none;">s</span>creen}}
 -!! html
 +!! html/php
  <span style="/* attempt to bypass $wgRestrictDisplayTitle */">s</span>creen
  <p>this is not the the title
  </p>
@@@ -19914,7 -19822,7 +19933,7 @@@ wgRestrictDisplayTitle=tru
  !! wikitext
  this is not the the title
  {{DISPLAYTITLE:<span style="color: red;">s</span>creen}}
 -!! html
 +!! html/php
  <span style="color: red;">s</span>creen
  <p>this is not the the title
  </p>
@@@ -20002,7 -19910,7 +20021,7 @@@ preload: check <noinclude> and <include
  preload
  !! wikitext
  Hello <noinclude>cruel</noinclude><includeonly>kind</includeonly> world.
 -!! html
 +!! html/php
  Hello kind world.
  !! end
  
@@@ -20012,7 -19920,7 +20031,7 @@@ preload: check <onlyinclude
  preload
  !! wikitext
  Goodbye <onlyinclude>Hello world</onlyinclude>
 -!! html
 +!! html/php
  Hello world
  !! end
  
@@@ -20022,7 -19930,7 +20041,7 @@@ preload: can pass tags through if we wa
  preload
  !! wikitext
  <includeonly><</includeonly>includeonly>Hello world<includeonly><</includeonly>/includeonly>
 -!! html
 +!! html/php
  <includeonly>Hello world</includeonly>
  !! end
  
@@@ -20032,7 -19940,7 +20051,7 @@@ preload: check that it doesn't try to d
  preload
  !! wikitext
  * <!-- Hello --> ''{{world}}'' {{<includeonly>subst:</includeonly>How are you}}{{ {{{|safesubst:}}} #if:1|2|3}}
 -!! html
 +!! html/php
  * <!-- Hello --> ''{{world}}'' {{subst:How are you}}{{ {{{|safesubst:}}} #if:1|2|3}}
  !! end
  
@@@ -20864,30 -20772,6 +20883,30 @@@ parsoid=wt2html,wt2w
  <small><figure class="mw-halign-right" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/300px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="34" width="300"/></a></figure></small>
  !! end
  
 +!! test
 +3. Bad treebuilder fixup of formatting elt is cleaned up
 +!! options
 +parsoid=wt2html,wt2wt
 +!! wikitext
 +<small>'''foo[[File:Foobar.jpg|thumb|caption]]bar'''</small>
 +!! html/parsoid
 +<p><small><b>foo</b></small></p>
 +<figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption><small><b>caption</b></small></figcaption></figure>
 +<p><small><b>bar</b></small></p>
 +!! end
 +
 +!! test
 +4. Bad treebuilder fixup of formatting elt is cleaned up: formatting tags around captionless images are ignored
 +!! options
 +parsoid=wt2html,wt2wt
 +!! wikitext
 +'''<small>[[Image:Foobar.jpg|right|300px]]</small>'''
 +!! html/parsoid
 +<p><b><small></small></b></p>
 +<figure class="mw-halign-right" typeof="mw:Image"><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/300px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="34" width="300"/></a></figure>
 +<p></p>
 +!! end
 +
  #### ----------------------------------------------------------------
  #### Parsoid-only testing of Parsoid's impl of <ref> and <references>
  #### tags. Parsoid's output for these tags differs from that of the
@@@ -21741,6 -21625,8 +21760,6 @@@ Headings: 5. Empty heading
  
  !! test
  Headings: 6a. Heading chars in SOL context (with trailing spaces)
 -!! options
 -parsoid
  !! wikitext
  <nowiki>=a=</nowiki>
  
  <nowiki>=a=</nowiki>  
  
  <nowiki>=a=</nowiki>  
 -!! html
 -<p>=a=</p>
 -<p>=a= </p>
 -<p>=a=        </p>
 -<p>=a=        </p>
 +!! html/php
 +<p>=a=
 +</p><p>=a= 
 +</p><p>=a=    
 +</p><p>=a=    
 +</p>
 +!! html/parsoid
 +<p><span typeof="mw:Nowiki">=a=</span></p>
 +
 +<p><span typeof="mw:Nowiki">=a=</span></p> 
 +
 +<p><span typeof="mw:Nowiki">=a=</span></p>    
 +
 +<p><span typeof="mw:Nowiki">=a=</span></p>    
  !!end
  
  !! test
  Headings: 6b. Heading chars in SOL context (with trailing newlines)
 -!! options
 -parsoid
  !! wikitext
  <nowiki>=a=
  b</nowiki>
@@@ -21779,65 -21658,48 +21798,65 @@@ b</nowiki
  
  <nowiki>=a=    
  b</nowiki>
 -!! html
 +!! html/php
  <p>=a=
 -b</p>
 -<p>=a= 
 -b</p>
 -<p>=a=        
 -b</p>
 -<p>=a=         
 -b</p>
 +b
 +</p><p>=a= 
 +b
 +</p><p>=a=    
 +b
 +</p><p>=a=     
 +b
  </p>
 +!! html/parsoid
 +<p><span typeof="mw:Nowiki">=a=
 +b</span></p>
 +
 +<p><span typeof="mw:Nowiki">=a= 
 +b</span></p>
 +
 +<p><span typeof="mw:Nowiki">=a=       
 +b</span></p>
 +
 +<p><span typeof="mw:Nowiki">=a=        
 +b</span></p>
  !!end
  
  !! test
  Headings: 6c. Heading chars in SOL context (leading newline break)
 -!! options
 -parsoid
  !! wikitext
  a
  <nowiki>=b=</nowiki>
 -!! html
 +!! html/php
 +<p>a
 +=b=
 +</p>
 +!! html/parsoid
  <p>a
 -=b=</p>
 +<span typeof="mw:Nowiki">=b=</span>
  !!end
  
  !! test
  Headings: 6d. Heading chars in SOL context (with interspersed comments)
 -!! options
 -parsoid
  !! wikitext
  <!--c0--><nowiki>=a=</nowiki>
  
  <!--c1--><nowiki>=a=</nowiki> <!--c2-->        <!--c3-->
 -!! html
 -<p><!--c0-->=a=</p>
 -<p><!--c1-->=a= <!--c2-->      <!--c3--></p>
 +!! html/php
 +<p>=a=
 +</p><p>=a=     
 +</p>
 +!! html/parsoid
 +<!--c0--><p><span typeof="mw:Nowiki">=a=</span></p>
 +
 +<!--c1--><p><span typeof="mw:Nowiki">=a=</span></p> <!--c2-->  <!--c3-->
  !!end
  
  !! test
  Headings: 6d. Heading chars in SOL context (No escaping needed)
  !! options
  parsoid=html2wt
 -!! html
 +!! html/parsoid
  =a=<div>b</div>
  !! wikitext
  =a=<div>b</div>
  Headings: 7. Insert a newline between new content and headings
  !! options
  parsoid=html2wt
 -!! html
 +!! html/parsoid
  <h2>NEW</h2>
  <p>new</p>
 -<h2 data-parsoid='{"dsr":[0,5,2,2]}'>A</h2>
 -<p data-parsoid='{"dsr":[6,7,0,0]}'>a</p>
 +<h2 data-parsoid='{}'>A</h2>
 +<p data-parsoid='{}'>a</p>
  !! wikitext
  == NEW ==
  new
@@@ -21880,17 -21742,11 +21899,17 @@@ Lists: 0. Outside nest
  <nowiki>#</nowiki>foo
  
  <nowiki>;Foo:</nowiki>bar
 -!! html
 +!! html/php
  <p>*foo
  </p><p>#foo
  </p><p>;Foo:bar
  </p>
 +!! html/parsoid
 +<p><span typeof="mw:Nowiki">*</span>foo</p>
 +
 +<p><span typeof="mw:Nowiki">#</span>foo</p>
 +
 +<p><span typeof="mw:Nowiki">;Foo:</span>bar</p>
  !!end
  
  !! test
@@@ -23561,9 -23417,9 +23580,9 @@@ Improperly nested inline or quotes tag
  !!test
  Encapsulate protected attributes from wt
  !! wikitext
 -<div typeof="mw:placeholder stuff" data-parsoid="weird" data-parsoid-other="no" about="time" rel="mw:true">foo</div>
 +<div typeof="mw:placeholder stuff" data-mw="whoo" data-parsoid="weird" data-parsoid-other="no" about="time" rel="mw:true">foo</div>
  !! html/parsoid
 -<body><div data-x-typeof="mw:placeholder stuff" data-x-data-parsoid="weird" data-x-data-parsoid-other="no" data-x-about="time" data-x-rel="mw:true">foo</div>
 +<body><div data-x-typeof="mw:placeholder stuff" data-x-data-mw="whoo" data-x-data-parsoid="weird" data-x-data-parsoid-other="no" data-x-about="time" data-x-rel="mw:true">foo</div>
  </body>
  !!end
  
@@@ -24278,43 -24134,9 +24297,43 @@@ parsoid=html2w
  !! end
  
  !! test
 -Headings: Force sol-transparent links and behavior switches to serialize before/after
 +1. Headings: Force sol-transparent links and behavior switches to serialize before/after
  !! options
 -parsoid=html2wt
 +parsoid={
 +  "modes": ["html2wt"],
 +  "scrubWikitext": false
 +}
 +!! html
 +<h2>hello there<link href="Category:A1" rel="mw:PageProp/Category" /></h2>
 +<h2><link href="Category:A2" rel="mw:PageProp/Category" />hi pal</h2>
 +
 +<h2><!--foo-->  <link href="Category:A3" rel="mw:PageProp/Category" />   how goes it</h2>
 +<h2>it goes well   <link href="Category:A4" rel="mw:PageProp/Category" />  <!--bar--></h2>
 +
 +<h2 data-parsoid='{}'>howdy<link href="Category:A5" rel="mw:PageProp/Category" /></h2>
 +
 +<h2><meta property="mw:PageProp/toc" /> ok</h2>
 +!! wikitext
 +== hello there [[Category:A1]]  ==
 +
 +==  [[Category:A2]] hi pal ==
 +
 +== <!--foo-->   [[Category:A3]]    how goes it ==
 +
 +== it goes well    [[Category:A4]]  <!--bar-->  ==
 +
 +==howdy [[Category:A5]] ==
 +
 +==  __TOC__  ok ==
 +!! end
 +
 +!! test
 +2. Headings: Force sol-transparent links and behavior switches to serialize before/after
 +!! options
 +parsoid={
 +  "modes": ["html2wt"],
 +  "scrubWikitext": true
 +}
  !! html
  <h2>hello there<link href="Category:A1" rel="mw:PageProp/Category" /></h2>
  <h2><link href="Category:A2" rel="mw:PageProp/Category" />hi pal</h2>
@@@ -24349,10 -24171,7 +24368,10 @@@ __TOC_
  !! test
  Headings: Don't hoist metas that come from templates
  !! options
 -parsoid=html2wt
 +parsoid={
 +  "modes": ["html2wt"],
 +  "scrubWikitext": true
 +}
  !! html
  <h2><span about="#mwt1" typeof="mw:Transclusion" data-parsoid="{}" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo [[Category:Foo]]"}},"i":0}}]}'>foo </span><link rel="mw:PageProp/Category" href="./Category:Foo" about="#mwt1" data-parsoid="{}" /></h2>
  !! wikitext
  !! test
  Headings: Category in ref isn't hoisted
  !! options
 -parsoid=html2wt
 +parsoid={
 +  "modes": ["html2wt"],
 +  "scrubWikitext": true
 +}
  !! html
  <h2> foo <span about="#mwt2" class="reference" id="cite_ref-1" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","body":{"id":"mw-reference-text-cite_note-1"},"attrs":{}}'><a href="#cite_note-1">[1]</a></span> </h2>
  
  baz</li>
  <li>foo <b>bar</b>
  baz</li></ul>
 +
 +<dl><dt>hi
 +ho </dt><dd data-parsoid='{"stx":"row"}'> hi
 +ho</dd></dl>
 +
 +<dl><dd> <table>
 +<tbody><tr><td> ha
 +ha
 +ha</td></tr>
 +</tbody></table></dd></dl>
  !! wikitext
  == testing 123 ==
  
@@@ -24495,14 -24301,6 +24514,14 @@@ there</ref> =
  
  * foo bar baz
  * foo '''bar''' baz
 +
 +; hi ho : hi ho
 +
 +: {|
 +| ha
 +ha
 +ha
 +|}
  !! end
  
  !! test
@@@ -24830,31 -24628,6 +24849,31 @@@ x<nowiki/>http://cscott.net<nowiki/>
  x<nowiki/>http://cscott.net<nowiki/>x
  !! end
  
 +!! test
 +WTS of edited autolink-like text (T103364)
 +!! options
 +parsoid={
 +  "modes": ["wt2wt"],
 +  "changes": [
 +    [ "span[typeof]", "removeAttr", "typeof" ]
 +  ]
 +}
 +!! wikitext
 +Not a link: <nowiki>http://example.com</nowiki>.
 +!! wikitext/edited
 +Not a link: <span><nowiki>http://example.com</nowiki></span>.
 +!! end
 +
 +!! test
 +WTS of newly-authored autolink-like text (T103364)
 +!! options
 +parsoid=html2wt
 +!! html/parsoid
 +<p>http://example.com is not a link.</p>
 +!! wikitext
 +<nowiki>http://example.com is not a link.</nowiki>
 +!! end
 +
  !! test
  Edited Redirect link should emit a non-piped wikitext link
  !! options
@@@ -25013,7 -24786,7 +25032,7 @@@ parsoid=html2w
  !! end
  
  !! test
 -Headings: Add space before/after == (T53744)
 +1. Headings: Add space before/after == (T53744)
  !! options
  parsoid=html2wt
  !! html
  <h2> bar</h2>
  <h2>baz </h2>
  <h2><span> baz</span></h2>
 -
 -<!-- Even after hoisted content -->
 -<h2> <link href="Category:A2" rel="mw:PageProp/Category" />ok</h2>
  !! wikitext
  == foo ==
  
  == baz ==
  
  == <span> baz</span> ==
 +!! end
  
 -<!-- Even after hoisted content -->
 +!! test
 +2. Headings: Add space before/after == even after hoisted content
 +!! options
 +parsoid={
 +  "modes": ["html2wt"],
 +  "scrubWikitext": true
 +}
 +!! html
 +<h2> <link href="Category:A2" rel="mw:PageProp/Category" />ok</h2>
 +!! wikitext
   [[Category:A2]]
  
  == ok ==
@@@ -25112,11 -24878,8 +25131,11 @@@ parsoid=
  }
  !! html
  <p> hi</p>
 +<p>    hello</p>
  !! wikitext
  hi
 +
 +hello
  !! end
  
  !! test
  parsoid=html2wt
  !! html
  <p> hi</p>
 +<p>    hello</p>
  !! wikitext
  <nowiki> </nowiki>hi
 +
 +<nowiki> </nowiki>   hello
 +!! end
 +
 +!! test
 +3. Indent Pre Nowiki: suppress whitespace after newlines in new paragraph or table cell
 +!! options
 +parsoid={
 +  "modes": ["html2wt"],
 +  "scrubWikitext": true
 +}
 +!! html/parsoid
 +<p>Foo
 + bar
 +baz</p>
 +
 +<table><tr><td>Foo
 + bar
 + baz bang</td></tr></table>
 +
 +<p><!--boo--> foo
 + bar</p>
 +
 +<p> foo
 + bar<span>boo</span></p>
 +!! wikitext
 +Foo
 +bar
 +baz
 +
 +{|
 +|Foo
 +bar
 +baz bang
 +|}
 +
 +<!--boo-->foo
 +bar
 +
 +foo
 +bar<span>boo</span>
 +!! end
 +
 +!! test
 +1. New links that end in spaces
 +!! options
 +parsoid={
 +  "modes": ["html2wt"],
 +  "scrubWikitext": false
 +}
 +!! html
 +<p><a rel="mw:WikiLink" href="./Berlin" title="Berlin">Berlin </a>is the capital of Germany.</p>
 +<p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo </a><b>bar</b></p>
 +!! wikitext
 +[[Berlin ]]<nowiki/>is the capital of Germany.
 +
 +[[Foo ]]'''bar'''
 +!! end
 +
 +!! test
 +2. New links that end in spaces
 +!! options
 +parsoid={
 +  "modes": ["html2wt"],
 +  "scrubWikitext": true
 +}
 +!! html
 +<p><a rel="mw:WikiLink" href="./Berlin" title="Berlin">Berlin </a>is the capital of Germany.</p>
 +<p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo </a><b>bar</b></p>
 +!! wikitext
 +[[Berlin]] is the capital of Germany.
 +
 +[[Foo]] '''bar'''
 +!! end
 +
 +!! test
 +3. Existing links that end in spaces
 +!! options
 +parsoid={
 +  "modes": ["html2wt"],
 +  "scrubWikitext": true
 +}
 +!! html
 +<p><a rel="mw:WikiLink" href="./Berlin" title="Berlin" data-parsoid='{"stx":"simple","a":{"href":"./Berlin"},"sa":{"href":"Berlin "}}'>Berlin </a>is the capital of Germany.</p>
 +
 +<p><a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{"stx":"simple","a":{"href":"./Foo"},"sa":{"href":"Foo "}}'>Foo </a><b>bar</b></p>
 +!! wikitext
 +[[Berlin ]]<nowiki/>is the capital of Germany.
 +
 +[[Foo ]]'''bar'''
  !! end
  
  # ---------------------------------------------------