# We don't need to run these tests in integrated mode as well.
!! options
version=2
!! end

!!article
Bar
!!text
abcd
!!endarticle

!! article
Template:1x
!! text
{{{1}}}
!! endarticle

# We need the span in the wikilink so that the link text is
# processed as a DOMFragment which then triggers the regression
# we are testing in this file
!!article
Template:RegressionTest
!!text
[[Bar|<span>bar</span>]]
!!endarticle

# Regression test -- ensure that nested pipeline TSR information
# doesn't leak onto the top-level pipeline during DSR computation.
# We verify this indirectly via passing selser tests.
!!test
Regression Test: Ensure nested pipeline TSR doesn't impact top-level DSR values
!!wikitext
{{RegressionTest}}

Bar
!!html/parsoid
<p><a rel="mw:WikiLink" href="./Bar" title="Bar" about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"RegressionTest","href":"./Template:RegressionTest"},"params":{},"i":0}}]}'><span>bar</span></a></p>

<p>Bar</p>
!!end

# As seen in T334957#9026561
!! test
Ensure proper DSR offsets are computed
!! options
parsoid=wt2html,selser
!! wikitext
{|
|-

é

''x''

* {{1x|
{{{!}}
{{!}}-
}}
!! html/parsoid
<p data-parsoid='{"fostered":true,"autoInsertedStart":true}'>

é

<i>x</i></p><ul data-parsoid='{"fostered":true}'><li class="mw-empty-elt"></li></ul><table about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"autoInsertedEnd":true}' data-mw='{"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"\n{{{!}}\n{{!}}-\n"}},"i":0}},"{|\n|-\n\né\n\n&apos;&apos;x&apos;&apos;\n\n* {{1x|\n{{{!}}\n{{!}}-\n}}"]}'>
</table><table about="#mwt1">
</table>
!! end

# This is just a regression test to ensure code can handle tables with fosterable content
# in DOM fragment position (Ex: image captions). This is an edge case and didn't feel it
# belonged in media.txt which already has a number of tests with tables in captions.
!! test
Images with captions containing tables with fosterable content shouldn't crash Parsoid
!! options
parsoid=wt2html
!! wikitext
[[File:Foobar.jpg|thumb|50px|
{|
{{1x|<span>foo</span>}}
|}
]]
!! html/parsoid
<figure typeof="mw:File/Thumb" data-parsoid='{"optList":[{"ck":"thumbnail","ak":"thumb"},{"ck":"width","ak":"50px"},{"ck":"caption","ak":"\n{|\n{{1x|&lt;span>foo&lt;/span>}}\n|}\n"}]}'><a href="./File:Foobar.jpg" class="mw-file-description"><img resource="./File:Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/50px-Foobar.jpg" decoding="async" loading="lazy" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="6" width="50" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/100px-Foobar.jpg 2x" class="mw-file-element" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"6","width":"50"},"sa":{"resource":"File:Foobar.jpg"}}'/></a><figcaption>
<p about="#mwt2" typeof="mw:Transclusion" data-parsoid='{"fostered":true,"autoInsertedStart":true,"firstWikitextNode":"TABLE","pi":[[{"k":"1"}]]}' data-mw='{"parts":["{|\n",{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"&lt;span>foo&lt;/span>"}},"i":0}},"\n|}"]}'><span>foo</span></p><table about="#mwt2">

</table>
</figcaption></figure>
!! end

!! test
Unpacking fostered content
!! options
parsoid=wt2html
!! wikitext
[http://google.com <table>hi</table> ho]
!! html/parsoid
<a rel="mw:ExtLink nofollow" href="http://google.com" class="external text"><p data-parsoid='{"fostered":true,"autoInsertedStart":true}'>hi</p><table data-parsoid='{"stx":"html"}'></table> ho</a>
!! end

!! test
Pipe magic word in bailing wikilink
!! options
parsoid=wt2html
!! wikitext
{|
| [[{{!}}]] [[{{!}}]]
|}
!! html/php
<table>
<tbody><tr>
<td>[[|]] [[|]]
</td></tr></tbody></table>
!! html/parsoid
<table>
<tbody><tr><td>[[|]] [[|]]</td></tr>
</tbody></table>
!! end

!! test
SOL whitespace and newlines after lists should not be swallowed into ListTk compound token
!! options
parsoid=wt2html
!! wikitext
*a
  
   
<div>b</div>
!! html/parsoid
<ul><li>a</li></ul>
  <p>
   <br></p>
<div data-parsoid='{"stx":"html"}'>b</div>
!! end

# Edge case in p-wrapping handling IndentPreTk
!! test
Unbalanced i-tags shouldn't leak out of blockquote containing leading whitespace
!! options
parsoid=wt2html
!! wikitext
<blockquote>
    foo ''bar
</blockquote>

baz
!! html/parsoid
<blockquote data-parsoid='{"stx":"html"}'>
 <p>   foo <i data-parsoid='{"autoInsertedEnd":true}'>bar</i></p>
</blockquote>

<p>baz</p>
!! end

!! test
Ensure ListHandler properly handles other compound tokens
!! options
parsoid=wt2html
!! wikitext
:{|
|
 a
|}
!! html/parsoid
<dl><dd><table>
<tbody><tr><td>
<pre>a</pre></td></tr>
</tbody></table></dd></dl>
!! end

!! test
Ensure WikiLink caching handles embedded fragments properly
!! options
parsoid=wt2html
!! wikitext
1. [[Foo|<spantag>a</spantag>]]
2. [[Foo|<spantag>a</spantag>]]
3. [[Foo|<spantag>a</spantag>]]
4. [[Foo|<spantag>a</spantag>]]
5. [[Foo|<spantag>a</spantag>]]
!! html/parsoid
<p>1. <a rel="mw:WikiLink" href="./Foo?action=edit&amp;redlink=1" title="Foo" class="new" typeof="mw:LocalizedAttrs" data-mw-i18n='{"title":{"lang":"x-page","key":"red-link-title","params":["Foo"]}}'><span typeof="mw:Extension/spantag" about="#mwt1" data-mw='{"name":"spantag","attrs":{},"body":{"extsrc":"a"}}'>a</span></a>
2. <a rel="mw:WikiLink" href="./Foo?action=edit&amp;redlink=1" title="Foo" class="new" typeof="mw:LocalizedAttrs" data-mw-i18n='{"title":{"lang":"x-page","key":"red-link-title","params":["Foo"]}}'><span typeof="mw:Extension/spantag" about="#mwt2" data-mw='{"name":"spantag","attrs":{},"body":{"extsrc":"a"}}'>a</span></a>
3. <a rel="mw:WikiLink" href="./Foo?action=edit&amp;redlink=1" title="Foo" class="new" typeof="mw:LocalizedAttrs" data-mw-i18n='{"title":{"lang":"x-page","key":"red-link-title","params":["Foo"]}}'><span typeof="mw:Extension/spantag" about="#mwt3" data-mw='{"name":"spantag","attrs":{},"body":{"extsrc":"a"}}'>a</span></a>
4. <a rel="mw:WikiLink" href="./Foo?action=edit&amp;redlink=1" title="Foo" class="new" typeof="mw:LocalizedAttrs" data-mw-i18n='{"title":{"lang":"x-page","key":"red-link-title","params":["Foo"]}}'><span typeof="mw:Extension/spantag" about="#mwt4" data-mw='{"name":"spantag","attrs":{},"body":{"extsrc":"a"}}'>a</span></a>
5. <a rel="mw:WikiLink" href="./Foo?action=edit&amp;redlink=1" title="Foo" class="new" typeof="mw:LocalizedAttrs" data-mw-i18n='{"title":{"lang":"x-page","key":"red-link-title","params":["Foo"]}}'><span typeof="mw:Extension/spantag" about="#mwt5" data-mw='{"name":"spantag","attrs":{},"body":{"extsrc":"a"}}'>a</span></a></p>
!! end

# The integrity of empty-line-tk should not get compromised
# because of QuoteHandler's onCompoundTk handling of compound tokens
!! test
QuoteHandler::onCompoundTk should not corrupt EmptyLineTk tokens
!! options
parsoid=wt2html
!! wikitext
<table><tr><td>''a''</td><td title="&amp;">b</td></tr></table>
[[Category:C]]
!! html/parsoid
<table data-parsoid='{"stx":"html"}'><tbody><tr data-parsoid='{"stx":"html"}'><td data-parsoid='{"stx":"html"}'><i>a</i></td><td title="&amp;" data-parsoid='{"stx":"html","a":{"title":"&amp;"},"sa":{"title":"&amp;amp;"}}'>b</td></tr></tbody></table>
<link rel="mw:PageProp/Category" href="./Category:C" />
!! end

!! test
Ensure source offsets are reset when reprocessing
!! options
parsoid=wt2wt
!! wikitext
| dir="{{#dir:hu}}" | [[mail:{{{1}}}|123]]
!! html/parsoid
-- unused in wt2wt --
!! end

!! test
T378906: Drop template-emitted leading/trailing newlines adjacent to <div>s produced by the same template
!! wikitext
{{1x|<div>foo</div>
}}{{1x|<div>bar</div>}}

{{1x|<div>foo</div>
}}<span>bar</span>

{{1x|<div>foo</div>}}{{1x|
<div>bar</div>}}

<span>foo</span>{{1x|
<div>bar</div>}}
!! html/parsoid
<div about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"stx":"html","pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"&lt;div>foo&lt;/div>\n"}},"i":0}}]}'>foo</div><div about="#mwt2" typeof="mw:Transclusion" data-parsoid='{"stx":"html","pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"&lt;div>bar&lt;/div>"}},"i":0}}]}'>bar</div>

<div about="#mwt3" typeof="mw:Transclusion" data-parsoid='{"stx":"html","pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"&lt;div>foo&lt;/div>\n"}},"i":0}}]}'>foo</div><p><span data-parsoid='{"stx":"html"}'>bar</span></p>

<div about="#mwt4" typeof="mw:Transclusion" data-parsoid='{"stx":"html","pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"&lt;div>foo&lt;/div>"}},"i":0}}]}'>foo</div><span class="mw-empty-elt" about="#mwt5" typeof="mw:Transclusion" data-parsoid='{"autoInsertedStart":true,"autoInsertedEnd":true,"pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"\n&lt;div>bar&lt;/div>"}},"i":0}}]}'></span><div about="#mwt5" data-parsoid='{"stx":"html"}'>bar</div>

<p><span data-parsoid='{"stx":"html"}'>foo</span></p><span class="mw-empty-elt" about="#mwt6" typeof="mw:Transclusion" data-parsoid='{"autoInsertedStart":true,"autoInsertedEnd":true,"pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"\n&lt;div>bar&lt;/div>"}},"i":0}}]}'></span><div about="#mwt6" data-parsoid='{"stx":"html"}'>bar</div>
!! end

!! test
T378906: Migrate trailing category tags into an interstitial span
!! wikitext
{{1x|<div>foo</div>
[[Category:Foo]]
[[Category:Bar]]
}}{{1x|<div>bar</div>}}
!! html/parsoid
<div about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"stx":"html","pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"&lt;div>foo&lt;/div>\n[[Category:Foo]]\n[[Category:Bar]]\n"}},"i":0}}]}'>foo</div><span class="mw-empty-elt" about="#mwt1"><link rel="mw:PageProp/Category" href="./Category:Foo"/><link rel="mw:PageProp/Category" href="./Category:Bar"/></span><div about="#mwt2" typeof="mw:Transclusion" data-parsoid='{"stx":"html","pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"&lt;div>bar&lt;/div>"}},"i":0}}]}'>bar</div>
!! end

!! test
T407798: Strip newlines between category link tags in templates
!! wikitext
{{1x|something
[[Category:Foo]]
[[es:Foo]]}}
!! html/php
<p>something
</p>
!! html/parsoid
<p><span about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"something\n[[Category:Foo]]\n[[es:Foo]]"}},"i":0}}]}'>something
</span><link rel="mw:PageProp/Category" href="./Category:Foo" about="#mwt1"/><link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Foo" about="#mwt1" data-parsoid='{"stx":"simple","a":{"href":"http://es.wikipedia.org/wiki/Foo"},"sa":{"href":"es:Foo"}}'/></p>
!! end

!! test
Migrate leading category into an interstitial span
!! wikitext
{{1x|<div>foo</div>
}}{{1x|[[Category:Foo]]<div>bar</div>}}
!! html/parsoid
<div about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"stx":"html","pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"&lt;div>foo&lt;/div>\n"}},"i":0}}]}'>foo</div><span class="mw-empty-elt" about="#mwt2" typeof="mw:Transclusion" data-parsoid='{"autoInsertedStart":true,"autoInsertedEnd":true,"pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"[[Category:Foo]]&lt;div>bar&lt;/div>"}},"i":0}}]}'><link rel="mw:PageProp/Category" href="./Category:Foo"/></span><div about="#mwt2" data-parsoid='{"stx":"html"}'>bar</div>
!! end

!! test
Migrate leading empty extension into an interstitial span
!! wikitext
{{1x|<div>foo</div>
}}{{1x|<section begin="2011-05-16" /><div>bar</div>}}
!! html/parsoid
<div about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"stx":"html","pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"&lt;div>foo&lt;/div>\n"}},"i":0}}]}'>foo</div><span class="mw-empty-elt" about="#mwt2" typeof="mw:Transclusion" data-parsoid='{"autoInsertedStart":true,"autoInsertedEnd":true,"pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"&lt;section begin=\"2011-05-16\" />&lt;div>bar&lt;/div>"}},"i":0}}]}'><link typeof="mw:Extension/section" about="#mwt3" data-mw='{"name":"section","attrs":{"begin":"2011-05-16"}}'/></span><div about="#mwt2" data-parsoid='{"stx":"html"}'>bar</div>
!! end

!! test
T410826: named arguments to parser functions in "old-style" DOM
!! options
parsoid=html2wt
!! html/parsoid
<p data-parsoid='{"dsr":[0,52,0,0]}'><span about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"1"},{"k":"2"}]],"dsr":[0,52,null,null]}' data-mw='{"parts":[{"template":{"target":{"wt":"fullurl:User talk:cscott","function":"fullurl"},"params":{"action":{"wt":"edit&amp;section=new"}},"i":0}}]}'>//en.wikipedia.org/w/index.php?title=User_talk:Cscott&amp;action=edit&amp;section=new</span></p>
!! wikitext
{{fullurl:User talk:cscott|action=edit&section=new}}
!! end

!! test
T425107: TOC shouldn't be stashed
!! wikitext
<div></div>
{{1x|__TOC__}}
<div></div>
!! html/parsoid
<div></div>
<meta data-mw='{"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"__TOC__"}},"i":0}}]}' property="mw:PageProp/toc" typeof="mw:Transclusion"/>
<div></div>
!!end

!! test
T426371: Templated captions with leading templatestyles should not break the caption
!! wikitext
[[File:foobar.jpg|thumb|{{1x|1=<templatestyles src='Legend/styles.css' /><div>foo</div>}}]]
!! html/parsoid
<figure class="mw-default-size" typeof="mw:File/Thumb" data-parsoid='{"optList":[{"ck":"thumbnail","ak":"thumb"},{"ck":"caption","ak":"{{1x|1=&lt;templatestyles src=&apos;Legend/styles.css&apos; />&lt;div>foo&lt;/div>}}"}],"dsr":[0,91,2,2]}'><a href="./File:Foobar.jpg" class="mw-file-description" data-parsoid='{"dsr":[2,24,null,null]}'><img resource="./File:Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" decoding="async" loading="lazy" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="20" width="180" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" class="mw-file-element" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"20","width":"180"},"sa":{"resource":"File:foobar.jpg"}}'/></a><figcaption data-parsoid='{"dsr":[24,89,0,0]}'><span class="mw-empty-elt" about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"autoInsertedStart":true,"autoInsertedEnd":true,"pi":[[{"k":"1","named":true}]],"dsr":[24,89,null,null]}' data-mw='{"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"&lt;templatestyles src=&apos;Legend/styles.css&apos; />&lt;div>foo&lt;/div>"}},"i":0}}]}'><style data-mw-deduplicate="TemplateStyles:r123456" typeof="mw:Extension/templatestyles" about="#mwt2" data-mw='{"name":"templatestyles","attrs":{"src":"Legend/styles.css"}}'>small { font-size: 120% } big { font-size: 80% }</style></span><div about="#mwt1" data-parsoid='{"stx":"html"}'>foo</div></figcaption></figure>
!! end

!! test
T426371: Templated captions with leading category links should not break the caption
!! wikitext
[[File:foobar.jpg|thumb|{{1x|1=[[Category:Foo]]<div>foo</div>}}]]
!! html/parsoid
<figure class="mw-default-size" typeof="mw:File/Thumb" data-parsoid='{"optList":[{"ck":"thumbnail","ak":"thumb"},{"ck":"caption","ak":"{{1x|1=[[Category:Foo]]&lt;div>foo&lt;/div>}}"}]}'><a href="./File:Foobar.jpg" class="mw-file-description"><img resource="./File:Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" decoding="async" loading="lazy" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="20" width="180" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" class="mw-file-element" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"20","width":"180"},"sa":{"resource":"File:foobar.jpg"}}'/></a><figcaption><span class="mw-empty-elt" about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"autoInsertedStart":true,"autoInsertedEnd":true,"pi":[[{"k":"1","named":true}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"[[Category:Foo]]&lt;div>foo&lt;/div>"}},"i":0}}]}'><link rel="mw:PageProp/Category" href="./Category:Foo"/></span><div about="#mwt1" data-parsoid='{"stx":"html"}'>foo</div></figcaption></figure>
!! end

!! test
T429688: do not stash fragments if they contain non-stashable content
!! wikitext
{{1x|[https://www.garesetconnexions.sncf/fr/gares-services/frmor[[Category:Page utilisant P3104]]/ La gare de Moret-Veneux-les-Sablons]}}
!! html/parsoid
<p><a rel="mw:ExtLink nofollow" href="https://www.garesetconnexions.sncf/fr/gares-services/frmor" about="#mwt1" typeof="mw:Transclusion" class="external text" data-mw='{"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"[https://www.garesetconnexions.sncf/fr/gares-services/frmor[[Category:Page utilisant P3104]]/ La gare de Moret-Veneux-les-Sablons]"}},"i":0}}]}'><link rel="mw:PageProp/Category" href="./Category:Page_utilisant_P3104"/>/ La gare de Moret-Veneux-les-Sablons</a></p>
!! end

!! test
Only wrap stashable content in block nodes
!! wikitext
{{1x|[http://test.com [[Category:Test]]]}}
!! html/parsoid
<p><a rel="mw:ExtLink nofollow" href="http://test.com" about="#mwt1" typeof="mw:Transclusion" class="external text" data-mw='{"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"[http://test.com [[Category:Test]]]"}},"i":0}}]}'><link rel="mw:PageProp/Category" href="./Category:Test"/></a></p>
!! end

!! article
Template:mwParamRegressionTester
!!text
| foo

| style="{{{SomeStyle}}}" | bar
!! endarticle

!! test
TSP should not introduce mw:Param tokens when reprocessing templated content
!! wikitext
{{mwParamRegressionTester}}
!! html/php
<p>| foo
</p><p>| style="{{{SomeStyle}}}" | bar
</p>
!! html/parsoid
<p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"mwParamRegressionTester","href":"./Template:MwParamRegressionTester"},"params":{},"i":0}}]}'>| foo</p><span about="#mwt1">

</span><p about="#mwt1">| style="{{{SomeStyle}}}" | bar</p>
!! end

!! test
T426645: Broken template in autolink url
!! options
parsoid=wt2html
!! wikitext
http://example.com/test{{
123 [[hmm]]
}}
!! html/php
<p><a rel="nofollow" class="external free" href="http://example.com/test{{">http://example.com/test{{</a>
123 <a href="/index.php?title=Hmm&amp;action=edit&amp;redlink=1" class="new" title="Hmm (page does not exist)">hmm</a>
}}
</p>
!! html/parsoid
<p><a rel="mw:ExtLink nofollow" href="http://example.com/test{{123+" class="external free" data-parsoid='{"stx":"url","a":{"href":"http://example.com/test{{123+"},"sa":{"href":"http://example.com/test{{\n123 [[hmm]]\n}}"}}'>http://example.com/test{{123 </a></p>
!! end

!! test
T360814: Template titles starting with .
!! options
parsoid=wt2html
subpage
title=[[A/B/C]]
!! wikitext
{{.Foo}}
{{./Foo}}
{{../Foo}}
{{.../Foo}}
!! html/php
<p><a href="/index.php?title=Template:.Foo&amp;action=edit&amp;redlink=1" class="new" title="Template:.Foo (page does not exist)">Template:.Foo</a>
{{./Foo}}
<a href="/index.php?title=A/B/Foo&amp;action=edit&amp;redlink=1" class="new" title="A/B/Foo (page does not exist)">A/B/Foo</a>
<a href="/index.php?title=Template:.../Foo&amp;action=edit&amp;redlink=1" class="new" title="Template:.../Foo (page does not exist)">Template:.../Foo</a>
</p>
!! html/parsoid
<p><a rel="mw:WikiLink" href="./Template:.Foo?action=edit&amp;redlink=1" title="Template:.Foo" about="#mwt1" typeof="mw:Transclusion mw:LocalizedAttrs" class="new" data-mw='{"parts":[{"template":{"target":{"wt":".Foo","href":"./Template:.Foo"},"params":{},"i":0}}]}' data-mw-i18n='{"title":{"lang":"x-page","key":"red-link-title","params":["Template:.Foo"]}}'>Template:.Foo</a>
{{./Foo}}
<a rel="mw:WikiLink" href="./A/B/Foo?action=edit&amp;redlink=1" title="A/B/Foo" about="#mwt3" typeof="mw:Transclusion mw:LocalizedAttrs" class="new" data-mw='{"parts":[{"template":{"target":{"wt":"../Foo","href":"./A/B/Foo"},"params":{},"i":0}}]}' data-mw-i18n='{"title":{"lang":"x-page","key":"red-link-title","params":["A/B/Foo"]}}'>A/B/Foo</a>
<a rel="mw:WikiLink" href="./Template:.../Foo?action=edit&amp;redlink=1" title="Template:.../Foo" about="#mwt4" typeof="mw:Transclusion mw:LocalizedAttrs" class="new" data-mw='{"parts":[{"template":{"target":{"wt":".../Foo","href":"./Template:.../Foo"},"params":{},"i":0}}]}' data-mw-i18n='{"title":{"lang":"x-page","key":"red-link-title","params":["Template:.../Foo"]}}'>Template:.../Foo</a></p>

!! end
