!! options
parsoid-compatible=wt2html
version=2
!! end

!! test
Indicator is not a standalone document and can reference content in the main document
!! options
showindicators
!! wikitext
<indicator name="ref">foo <ref name='bar' /></indicator>
<ref name='bar'>baz</ref>
!! metadata/php
ref=foo <sup id="cite&#95;ref-bar&#95;1-0" class="reference"><a href="#cite_note-bar-1"><span class="cite-bracket">&#91;</span>1<span class="cite-bracket">&#93;</span></a></sup>
!! metadata/parsoid+integrated
ref=foo <sup about="#mwt1" class="mw-ref reference" id="cite_ref-bar_1-0" rel="dc:references" typeof="mw:Extension/ref" data-parsoid='{"dsr":[26,44,18,0]}' data-mw='{"name":"ref","attrs":{"name":"bar"}}'><a href="./Parser_test#cite_note-bar-1" data-parsoid="{}"><span class="mw-reflink-text" data-parsoid="{}"><span class="cite-bracket" data-parsoid="{}">[</span>1<span class="cite-bracket" data-parsoid="{}">]</span></span></a></sup>
!! html/php
<p><sup id="cite&#95;ref-bar&#95;1-1" class="reference"><a href="#cite_note-bar-1"><span class="cite-bracket">&#91;</span>1<span class="cite-bracket">&#93;</span></a></sup>
</p>
<div class="mw-references-wrap"><ol class="references">
<li id="cite&#95;note-bar-1"><span class="mw-cite-backlink">↑ <sup><a href="#cite_ref-bar_1-0">1.0</a></sup> <sup><a href="#cite_ref-bar_1-1">1.1</a></sup></span> <span class="reference-text">baz</span>
</li>
</ol></div>
!! html/parsoid+integrated
<meta typeof="mw:Extension/indicator" data-mw='{"name":"indicator","attrs":{"name":"ref"},"body":{"extsrc":"foo &lt;ref name=&apos;bar&apos; />"},"html":"foo &lt;sup class=\"mw-ref reference\" id=\"cite_ref-bar_1-0\" rel=\"dc:references\" typeof=\"mw:Extension/ref\" data-mw=&apos;{\"name\":\"ref\",\"attrs\":{\"name\":\"bar\"}}&apos;>&lt;a href=\"./Parser_test#cite_note-bar-1\">&lt;span class=\"mw-reflink-text\">&lt;span class=\"cite-bracket\">[&lt;/span>1&lt;span class=\"cite-bracket\">]&lt;/span>&lt;/span>&lt;/a>&lt;/sup>"}'/>
<p><sup class="mw-ref reference" id="cite_ref-bar_1-1" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"name":"bar"},"body":{"id":"mw-reference-text-cite_note-bar-1"}}'><a href="./Parser_test#cite_note-bar-1"><span class="mw-reflink-text"><span class="cite-bracket">[</span>1<span class="cite-bracket">]</span></span></a></sup></p>
<div class="mw-references-wrap" typeof="mw:Extension/references" data-mw='{"name":"references","attrs":{},"autoGenerated":true}'>
<ol class="mw-references references">
<li id="cite_note-bar-1" data-mw-footnote-number="1"><span rel="mw:referencedBy" class="mw-cite-backlink"><a href="./Parser_test#cite_ref-bar_1-0"><span class="mw-linkback-text">1</span></a> <a href="./Parser_test#cite_ref-bar_1-1"><span class="mw-linkback-text">2</span></a></span> <span id="mw-reference-text-cite&#95;note-bar-1" class="mw-reference-text reference-text">baz</span></li>
</ol>
</div>
!! end

!! test
Nested indicator
!! options
showindicators
!! wikitext
{{#tag:ref|{{#tag:indicator|{{#tag:ref|ref 3}}|name=indic}}}}
!! metadata/php
indic=<sup id="cite&#95;ref-1" class="reference"><a href="#cite_note-1"><span class="cite-bracket">&#91;</span>1<span class="cite-bracket">&#93;</span></a></sup>
!! metadata/parsoid+integrated
indic=<sup about="#mwt2" class="mw-ref reference" id="cite_ref-1" rel="dc:references" typeof="mw:Extension/ref" data-parsoid="{}" data-mw='{"name":"ref","attrs":{},"body":{"id":"mw-reference-text-cite_note-1"}}'><a href="./Parser_test#cite_note-1" data-parsoid="{}"><span class="mw-reflink-text" data-parsoid="{}"><span class="cite-bracket" data-parsoid="{}">[</span>1<span class="cite-bracket" data-parsoid="{}">]</span></span></a></sup>
!! html/php
<p><sup id="cite&#95;ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">&#91;</span>2<span class="cite-bracket">&#93;</span></a></sup>
</p>
<div class="mw-references-wrap"><ol class="references">
<li id="cite&#95;note-1"><span class="mw-cite-backlink"><a href="#cite_ref-1">↑</a></span> <span class="reference-text">ref 3</span>
</li>
<li id="cite&#95;note-2"><span class="mw-cite-backlink"><a href="#cite_ref-2">↑</a></span> <span class="reference-text"></span>
</li>
</ol></div>
!! html/parsoid+integrated
<p><sup class="mw-ref reference" id="cite_ref-2" rel="dc:references" typeof="mw:Transclusion mw:Extension/ref" data-mw='{"name":"ref","attrs":{},"body":{"id":"mw-reference-text-cite_note-2"},"parts":[{"template":{"target":{"wt":"#tag:ref","function":"tag"},"params":{"1":{"wt":"{{#tag:indicator|{{#tag:ref|ref 3}}|name=indic}}"}},"i":0}}]}'><a href="./Parser_test#cite_note-2"><span class="mw-reflink-text"><span class="cite-bracket">[</span>2<span class="cite-bracket">]</span></span></a></sup></p>
<div class="mw-references-wrap" typeof="mw:Extension/references" data-mw='{"name":"references","attrs":{},"autoGenerated":true}'>
<ol class="mw-references references">
<li id="cite_note-1" data-mw-footnote-number="1"><span class="mw-cite-backlink"><a href="./Parser_test#cite_ref-1" rel="mw:referencedBy"><span class="mw-linkback-text">↑</span></a></span> <span id="mw-reference-text-cite_note-1" class="mw-reference-text reference-text">ref 3</span></li>
<li id="cite_note-2" data-mw-footnote-number="2"><span class="mw-cite-backlink"><a href="./Parser_test#cite_ref-2" rel="mw:referencedBy"><span class="mw-linkback-text">↑</span></a></span> <span id="mw-reference-text-cite_note-2" class="mw-reference-text reference-text"><meta typeof="mw:Extension/indicator" data-mw='{"name":"indicator","attrs":{"name":"indic"},"body":{"extsrc":"&lt;ref>ref 3&lt;/ref>"},"html":"&lt;sup class=\"mw-ref reference\" id=\"cite_ref-1\" rel=\"dc:references\" typeof=\"mw:Extension/ref\" data-mw=&apos;{\"name\":\"ref\",\"attrs\":{},\"body\":{\"id\":\"mw-reference-text-cite_note-1\"}}&apos;>&lt;a href=\"./Parser_test#cite_note-1\">&lt;span class=\"mw-reflink-text\">&lt;span class=\"cite-bracket\">[&lt;/span>1&lt;span class=\"cite-bracket\">]&lt;/span>&lt;/span>&lt;/a>&lt;/sup>"}'/></span></li>
</ol>
</div>
!! end

!! test
T393913: Consider <indicator> only when at the very top of the stack
!! options
showindicators
!! wikitext
<indicator name="test">
[[File:Foobar.jpg|<ref name="test">123</ref>]]
</indicator>
!! metadata/parsoid+integrated
test=
<span class="mw-default-size" typeof="mw:File" data-parsoid='{"optList":[{"ck":"caption","ak":"&lt;ref name=\"test\">123&lt;/ref>"}],"dsr":[24,70,null,null]}' data-mw='{"caption":"&lt;sup about=\"#mwt1\" class=\"mw-ref reference\" rel=\"dc:references\" typeof=\"mw:Extension/ref\" data-parsoid=&apos;{\"dsr\":[42,68,17,6]}&apos; data-mw=&apos;{\"name\":\"ref\",\"attrs\":{\"name\":\"test\"},\"body\":{\"id\":\"mw-reference-text-cite_note-test-1\"}}&apos;>&lt;a href=\"./Parser_test#cite_note-test-1\" data-parsoid=\"{}\">&lt;span class=\"mw-reflink-text\" data-parsoid=\"{}\">&lt;span class=\"cite-bracket\" data-parsoid=\"{}\">[&lt;/span>1&lt;span class=\"cite-bracket\" data-parsoid=\"{}\">]&lt;/span>&lt;/span>&lt;/a>&lt;/sup>"}'><a href="./File:Foobar.jpg" class="mw-file-description" data-parsoid="{}"><img resource="./File:Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" class="mw-file-element" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></span>

!! html/parsoid+integrated
<meta typeof="mw:Extension/indicator" data-mw='{"name":"indicator","attrs":{"name":"test"},"body":{"extsrc":"\n[[File:Foobar.jpg|&lt;ref name=\"test\">123&lt;/ref>]]\n"},"html":"\n&lt;span class=\"mw-default-size\" typeof=\"mw:File\" data-mw=&apos;{\"caption\":\"&amp;lt;sup about=\\\"#mwt1\\\" class=\\\"mw-ref reference\\\" rel=\\\"dc:references\\\" typeof=\\\"mw:Extension/ref\\\" data-parsoid=&amp;apos;{\\\"dsr\\\":[42,68,17,6]}&amp;apos; data-mw=&amp;apos;{\\\"name\\\":\\\"ref\\\",\\\"attrs\\\":{\\\"name\\\":\\\"test\\\"},\\\"body\\\":{\\\"id\\\":\\\"mw-reference-text-cite_note-test-1\\\"}}&amp;apos;>&amp;lt;a href=\\\"./Parser_test#cite_note-test-1\\\" data-parsoid=\\\"{}\\\">&amp;lt;span class=\\\"mw-reflink-text\\\" data-parsoid=\\\"{}\\\">&amp;lt;span class=\\\"cite-bracket\\\" data-parsoid=\\\"{}\\\">[&amp;lt;/span>1&amp;lt;span class=\\\"cite-bracket\\\" data-parsoid=\\\"{}\\\">]&amp;lt;/span>&amp;lt;/span>&amp;lt;/a>&amp;lt;/sup>\"}&apos;>&lt;a href=\"./File:Foobar.jpg\" class=\"mw-file-description\">&lt;img resource=\"./File:Foobar.jpg\" src=\"http://example.com/images/3/3a/Foobar.jpg\" decoding=\"async\" data-file-width=\"1941\" data-file-height=\"220\" data-file-type=\"bitmap\" height=\"220\" width=\"1941\" class=\"mw-file-element\"/>&lt;/a>&lt;/span>\n"}'/>
<div class="mw-references-wrap" typeof="mw:Extension/references" data-mw='{"name":"references","attrs":{},"autoGenerated":true}'>
<ol class="mw-references references">
<li id="cite_note-test-1" data-mw-footnote-number="1"><span rel="mw:referencedBy" class="mw-cite-backlink"></span> <span id="mw-reference-text-cite_note-test-1" class="mw-reference-text reference-text">123</span></li>
</ol>
</div>
!! end
