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

!! article
Template:Deco-z
!! text
z{{{1}}}zz
!! endarticle

!! test
Subreferencing attribute blocked without feature flag
!! config
wgCiteSubReferencing=false
!! wikitext
<ref details="abc" name="a">def</ref>
<references />
!! html/php
<p><sup id="cite&#95;ref-a&#95;1-0" class="reference"><a href="#cite_note-a-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-a-1"><span class="mw-cite-backlink"><a href="#cite_ref-a_1-0">↑</a></span> <span class="reference-text">def <span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: Invalid parameter "details" in <code>&lt;ref&gt;</code> tag. The supported parameters are: dir, follow, group, name.</span></span>
</li>
</ol></div>
!! html/parsoid
<p><sup class="mw-ref reference" id="cite&#95;ref-a&#95;1-0" rel="dc:references" typeof="mw:Extension/ref mw:Error" data-mw='{"name":"ref","attrs":{"details":"abc","name":"a"},"body":{"id":"mw-reference-text-cite_note-a-1"},"errors":[{"key":"cite_error_ref_too_many_keys","params":["details","dir, follow, group, name"]}]}'><a href="./Parser_test#cite_note-a-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":{}}'>
<ol class="mw-references references">
<li id="cite&#95;note-a-1" data-mw-footnote-number="1"><span class="mw-cite-backlink"><a href="./Parser_test#cite_ref-a_1-0" rel="mw:referencedBy"><span class="mw-linkback-text">↑</span></a></span> <span id="mw-reference-text-cite&#95;note-a-1" class="mw-reference-text reference-text">def</span> <span typeof="mw:I18n" class="error mw-ext-cite-error" data-mw-i18n='{"/":{"lang":"x-user","key":"cite_error","params":[{"text":{"key":"cite_error_ref_too_many_keys","params":["details","dir, follow, group, name"]}}]}}'></span></li>
</ol>
</div>
!! end

!! test
T397760: Details with no name but feature flag disabled
!! config
wgCiteSubReferencing=false
!! wikitext
<ref details="y">x</ref>
<references />
!! html/php
<p><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>
</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">x <span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: Invalid parameter "details" in <code>&lt;ref&gt;</code> tag. The supported parameters are: dir, follow, group, name.</span></span>
</li>
</ol></div>
!! end

!! test
Subreferencing attribute allowed with feature flag set
!! config
wgCiteSubReferencing=true
!! wikitext
<ref details="0" name="a">def</ref>
!! html/php
<p><sup id="cite&#95;ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup>
</p>
<div class="mw-references-wrap"><ol class="references">
<li><span class="mw-cite-backlink">↑</span> <span class="reference-text">def</span>
<ol class="mw-subreference-list"><li id="cite&#95;note-2"><span class="mw-cite-backlink"><a href="#cite_ref-2">↑</a></span> <span class="reference-text">0</span>
</li>
</ol></li>
</ol></div>
!! html/parsoid
<p><sup class="mw-ref reference" id="cite&#95;ref-2" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"details":"0","name":"a"},"body":{"id":"mw-reference-text-cite_note-2"},"mainRef":"a","mainBody":"mw-reference-text-cite_note-a-1"}'><a href="./Parser_test#cite_note-2"><span class="mw-reflink-text"><span class="cite-bracket">[</span>1.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,"body":{"html":"\n&lt;sup typeof=\"mw:Extension/ref\" data-mw=&apos;{\"name\":\"ref\",\"attrs\":{\"name\":\"a\",\"group\":\"\"},\"body\":{\"id\":\"mw-reference-text-cite_note-a-1\"},\"isSyntheticMainRef\":1}&apos;>def&lt;/sup>"}}'>
<ol class="mw-references references">
<li id="cite&#95;note-a-1" data-mw-footnote-number="1"><span rel="mw:referencedBy" class="mw-cite-backlink"></span> <span id="mw-reference-text-cite&#95;note-a-1" class="mw-reference-text reference-text">def</span>
<ol class="mw-subreference-list">
<li id="cite&#95;note-2" data-mw-footnote-number="1.1"><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&#95;note-2" class="mw-reference-text reference-text">0</span></li>
</ol>
</li>
</ol>
</div>
!! end

!! test
Subreference round trip with original attribute order
!! config
wgCiteSubReferencing=true
!! wikitext
<ref name="a" details="0">def</ref>
!! html/php
<p><sup id="cite&#95;ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup>
</p>
<div class="mw-references-wrap"><ol class="references">
<li><span class="mw-cite-backlink">↑</span> <span class="reference-text">def</span>
<ol class="mw-subreference-list"><li id="cite&#95;note-2"><span class="mw-cite-backlink"><a href="#cite_ref-2">↑</a></span> <span class="reference-text">0</span>
</li>
</ol></li>
</ol></div>
!! html/parsoid
<p><sup class="mw-ref reference" id="cite&#95;ref-2" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"name":"a","details":"0"},"body":{"id":"mw-reference-text-cite_note-2"},"mainRef":"a","mainBody":"mw-reference-text-cite_note-a-1"}'><a href="./Parser_test#cite_note-2"><span class="mw-reflink-text"><span class="cite-bracket">[</span>1.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,"body":{"html":"\n&lt;sup typeof=\"mw:Extension/ref\" data-mw=&apos;{\"name\":\"ref\",\"attrs\":{\"name\":\"a\",\"group\":\"\"},\"body\":{\"id\":\"mw-reference-text-cite_note-a-1\"},\"isSyntheticMainRef\":1}&apos;>def&lt;/sup>"}}'>
<ol class="mw-references references">
<li id="cite&#95;note-a-1" data-mw-footnote-number="1"><span rel="mw:referencedBy" class="mw-cite-backlink"></span> <span id="mw-reference-text-cite&#95;note-a-1" class="mw-reference-text reference-text">def</span>
<ol class="mw-subreference-list">
<li id="cite&#95;note-2" data-mw-footnote-number="1.1"><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&#95;note-2" class="mw-reference-text reference-text">0</span></li>
</ol>
</li>
</ol>
</div>
!! end

!! test
Unnamed main reference with a lonely sub-ref, neither can be reused
!! config
wgCiteSubReferencing=true
!! wikitext
<ref details="abc">def</ref>
<references />
!! html/php
<p><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>
</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">def <span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: Invalid <code>&lt;ref&gt;</code> tag; missing name attribute. A name attribute must be provided along with a details attribute.</span></span>
</li>
</ol></div>
!! html/parsoid
<p><sup class="mw-ref reference" id="cite&#95;ref-1" rel="dc:references" typeof="mw:Extension/ref mw:Error" data-mw='{"name":"ref","attrs":{"details":"abc"},"body":{"id":"mw-reference-text-cite_note-1"},"errors":[{"key":"cite_error_ref_with_details_no_name"}]}'><a href="./Parser_test#cite_note-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":{}}'>
<ol class="mw-references references">
<li id="cite&#95;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&#95;note-1" class="mw-reference-text reference-text">def</span> <span typeof="mw:I18n" class="error mw-ext-cite-error" data-mw-i18n='{"/":{"lang":"x-user","key":"cite_error","params":[{"text":{"key":"cite_error_ref_with_details_no_name","params":[]}}]}}'></span></li>
</ol>
</div>
!! end

!! test
Named main ref with inline details
!! config
wgCiteSubReferencing=true
!! wikitext
<ref details="p. 1" name="book">The book</ref>
!! html/php
<p><sup id="cite&#95;ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup>
</p>
<div class="mw-references-wrap"><ol class="references">
<li><span class="mw-cite-backlink">↑</span> <span class="reference-text">The book</span>
<ol class="mw-subreference-list"><li id="cite&#95;note-2"><span class="mw-cite-backlink"><a href="#cite_ref-2">↑</a></span> <span class="reference-text">p. 1</span>
</li>
</ol></li>
</ol></div>
!! html/parsoid
<p><sup class="mw-ref reference" id="cite&#95;ref-2" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"details":"p. 1","name":"book"},"body":{"id":"mw-reference-text-cite_note-2"},"mainRef":"book","mainBody":"mw-reference-text-cite_note-book-1"}'><a href="./Parser_test#cite_note-2"><span class="mw-reflink-text"><span class="cite-bracket">[</span>1.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,"body":{"html":"\n&lt;sup typeof=\"mw:Extension/ref\" data-mw=&apos;{\"name\":\"ref\",\"attrs\":{\"name\":\"book\",\"group\":\"\"},\"body\":{\"id\":\"mw-reference-text-cite_note-book-1\"},\"isSyntheticMainRef\":1}&apos;>The book&lt;/sup>"}}'>
<ol class="mw-references references">
<li id="cite&#95;note-book-1" data-mw-footnote-number="1"><span rel="mw:referencedBy" class="mw-cite-backlink"></span> <span id="mw-reference-text-cite&#95;note-book-1" class="mw-reference-text reference-text">The book</span>
<ol class="mw-subreference-list">
<li id="cite&#95;note-2" data-mw-footnote-number="1.1"><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&#95;note-2" class="mw-reference-text reference-text">p. 1</span></li>
</ol>
</li>
</ol>
</div>
!! end

# FIXME: Can we make the whitespace survive the roundtrip?
!! test
Empty sub-referencing attribute with no meaningful content
!! config
wgCiteSubReferencing=true
!! options
parsoid=wt2html,html2html
!! wikitext
<ref details="   " name="a">def</ref>
<references />
!! html/php
<p><sup id="cite&#95;ref-a&#95;1-0" class="reference"><a href="#cite_note-a-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-a-1"><span class="mw-cite-backlink"><a href="#cite_ref-a_1-0">↑</a></span> <span class="reference-text">def</span>
</li>
</ol></div>
!! html/parsoid
<p><sup class="mw-ref reference" id="cite&#95;ref-a&#95;1-0" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"details":"","name":"a"},"body":{"id":"mw-reference-text-cite_note-a-1"}}'><a href="./Parser_test#cite_note-a-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":{}}'>
<ol class="mw-references references">
<li id="cite&#95;note-a-1" data-mw-footnote-number="1"><span class="mw-cite-backlink"><a href="./Parser_test#cite_ref-a_1-0" rel="mw:referencedBy"><span class="mw-linkback-text">↑</span></a></span> <span id="mw-reference-text-cite&#95;note-a-1" class="mw-reference-text reference-text">def</span></li>
</ol>
</div>
!! end

# FIXME: restore self-closing references tag
!! test
Multiple subreferences
!! config
wgCiteSubReferencing=true
!! wikitext
<ref details="abc" name="a">def</ref> <ref details="ghi" name="b">jkl</ref>
<references>
</references>
!! html/php
<p><sup id="cite&#95;ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup> <sup id="cite&#95;ref-4" class="reference"><a href="#cite_note-4"><span class="cite-bracket">&#91;</span>2.1<span class="cite-bracket">&#93;</span></a></sup>
</p>
<div class="mw-references-wrap"><ol class="references">
<li><span class="mw-cite-backlink">↑</span> <span class="reference-text">def</span>
<ol class="mw-subreference-list"><li id="cite&#95;note-2"><span class="mw-cite-backlink"><a href="#cite_ref-2">↑</a></span> <span class="reference-text">abc</span>
</li>
</ol></li>
<li><span class="mw-cite-backlink">↑</span> <span class="reference-text">jkl</span>
<ol class="mw-subreference-list"><li id="cite&#95;note-4"><span class="mw-cite-backlink"><a href="#cite_ref-4">↑</a></span> <span class="reference-text">ghi</span>
</li>
</ol></li>
</ol></div>
!! html/parsoid
<p><sup class="mw-ref reference" id="cite&#95;ref-2" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"details":"abc","name":"a"},"body":{"id":"mw-reference-text-cite_note-2"},"mainRef":"a","mainBody":"mw-reference-text-cite_note-a-1"}'><a href="./Parser_test#cite_note-2"><span class="mw-reflink-text"><span class="cite-bracket">[</span>1.1<span class="cite-bracket">]</span></span></a></sup> <sup class="mw-ref reference" id="cite&#95;ref-4" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"details":"ghi","name":"b"},"body":{"id":"mw-reference-text-cite_note-4"},"mainRef":"b","mainBody":"mw-reference-text-cite_note-b-3"}'><a href="./Parser_test#cite_note-4"><span class="mw-reflink-text"><span class="cite-bracket">[</span>2.1<span class="cite-bracket">]</span></span></a></sup></p>
<div class="mw-references-wrap" typeof="mw:Extension/references" data-mw='{"name":"references","attrs":{},"body":{"html":"\n&lt;sup typeof=\"mw:Extension/ref\" data-mw=&apos;{\"name\":\"ref\",\"attrs\":{\"name\":\"a\",\"group\":\"\"},\"body\":{\"id\":\"mw-reference-text-cite_note-a-1\"},\"isSyntheticMainRef\":1}&apos;>def&lt;/sup>&lt;sup typeof=\"mw:Extension/ref\" data-mw=&apos;{\"name\":\"ref\",\"attrs\":{\"name\":\"b\",\"group\":\"\"},\"body\":{\"id\":\"mw-reference-text-cite_note-b-3\"},\"isSyntheticMainRef\":1}&apos;>jkl&lt;/sup>"}}'>
<ol class="mw-references references">
<li id="cite&#95;note-a-1" data-mw-footnote-number="1"><span rel="mw:referencedBy" class="mw-cite-backlink"></span> <span id="mw-reference-text-cite&#95;note-a-1" class="mw-reference-text reference-text">def</span>
<ol class="mw-subreference-list">
<li id="cite&#95;note-2" data-mw-footnote-number="1.1"><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&#95;note-2" class="mw-reference-text reference-text">abc</span></li>
</ol>
</li>
<li id="cite&#95;note-b-3" data-mw-footnote-number="2"><span rel="mw:referencedBy" class="mw-cite-backlink"></span> <span id="mw-reference-text-cite&#95;note-b-3" class="mw-reference-text reference-text">jkl</span>
<ol class="mw-subreference-list">
<li id="cite&#95;note-4" data-mw-footnote-number="2.1"><span class="mw-cite-backlink"><a href="./Parser_test#cite_ref-4" rel="mw:referencedBy"><span class="mw-linkback-text">↑</span></a></span> <span id="mw-reference-text-cite&#95;note-4" class="mw-reference-text reference-text">ghi</span></li>
</ol>
</li>
</ol>
</div>
!! end

!! test
Parent reference used before sub-reference
!! config
wgCiteSubReferencing=true
!! wikitext
<ref name="book">The book</ref> <ref details="p. 1" name="book" />
<references>
</references>
!! html/php
<p><sup id="cite&#95;ref-book&#95;1-0" class="reference"><a href="#cite_note-book-1"><span class="cite-bracket">&#91;</span>1<span class="cite-bracket">&#93;</span></a></sup> <sup id="cite&#95;ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup>
</p>
<div class="mw-references-wrap"><ol class="references">
<li id="cite&#95;note-book-1"><span class="mw-cite-backlink"><a href="#cite_ref-book_1-0">↑</a></span> <span class="reference-text">The book</span>
<ol class="mw-subreference-list"><li id="cite&#95;note-2"><span class="mw-cite-backlink"><a href="#cite_ref-2">↑</a></span> <span class="reference-text">p. 1</span>
</li>
</ol></li>
</ol></div>
!! html/parsoid
<p><sup class="mw-ref reference" id="cite&#95;ref-book&#95;1-0" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"name":"book"},"body":{"id":"mw-reference-text-cite_note-book-1"}}'><a href="./Parser_test#cite_note-book-1"><span class="mw-reflink-text"><span class="cite-bracket">[</span>1<span class="cite-bracket">]</span></span></a></sup> <sup class="mw-ref reference" id="cite&#95;ref-2" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"details":"p. 1","name":"book"},"mainRef":"book","body":{"id":"mw-reference-text-cite_note-2"}}'><a href="./Parser_test#cite_note-2"><span class="mw-reflink-text"><span class="cite-bracket">[</span>1.1<span class="cite-bracket">]</span></span></a></sup></p>
<div class="mw-references-wrap" typeof="mw:Extension/references" data-mw='{"name":"references","attrs":{},"body":{"html":"\n&lt;sup typeof=\"mw:Extension/ref\" data-mw=&apos;{\"name\":\"ref\",\"attrs\":{\"name\":\"book\",\"group\":\"\"},\"body\":{\"id\":\"mw-reference-text-cite_note-book-1\"},\"isSyntheticMainRef\":1}&apos;>The book&lt;/sup>"}}'>
<ol class="mw-references references">
<li id="cite&#95;note-book-1" data-mw-footnote-number="1"><span class="mw-cite-backlink"><a href="./Parser_test#cite_ref-book_1-0" rel="mw:referencedBy"><span class="mw-linkback-text">↑</span></a></span> <span id="mw-reference-text-cite&#95;note-book-1" class="mw-reference-text reference-text">The book</span>
<ol class="mw-subreference-list">
<li id="cite&#95;note-2" data-mw-footnote-number="1.1"><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&#95;note-2" class="mw-reference-text reference-text">p. 1</span></li>
</ol>
</li>
</ol>
</div>
!! end

!! test
Parent reference used after sub-reference
!! config
wgCiteSubReferencing=true
!! wikitext
<ref details="p. 1" name="book" /> <ref name="book">The book</ref>
<references>
</references>
!! html/php
<p><sup id="cite&#95;ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup> <sup id="cite&#95;ref-book&#95;1-0" class="reference"><a href="#cite_note-book-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-book-1"><span class="mw-cite-backlink"><a href="#cite_ref-book_1-0">↑</a></span> <span class="reference-text">The book</span>
<ol class="mw-subreference-list"><li id="cite&#95;note-2"><span class="mw-cite-backlink"><a href="#cite_ref-2">↑</a></span> <span class="reference-text">p. 1</span>
</li>
</ol></li>
</ol></div>
!! html/parsoid
<p><sup class="mw-ref reference" id="cite&#95;ref-2" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"details":"p. 1","name":"book"},"mainRef":"book","body":{"id":"mw-reference-text-cite_note-2"}}'><a href="./Parser_test#cite_note-2"><span class="mw-reflink-text"><span class="cite-bracket">[</span>1.1<span class="cite-bracket">]</span></span></a></sup> <sup class="mw-ref reference" id="cite&#95;ref-book&#95;1-0" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"name":"book"},"body":{"id":"mw-reference-text-cite_note-book-1"}}'><a href="./Parser_test#cite_note-book-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":{},"body":{"html":"\n&lt;sup typeof=\"mw:Extension/ref\" data-mw=&apos;{\"name\":\"ref\",\"attrs\":{\"name\":\"book\",\"group\":\"\"},\"body\":{\"id\":\"mw-reference-text-cite_note-book-1\"},\"isSyntheticMainRef\":1}&apos;>The book&lt;/sup>"}}'>
<ol class="mw-references references">
<li id="cite&#95;note-book-1" data-mw-footnote-number="1"><span class="mw-cite-backlink"><a href="./Parser_test#cite_ref-book_1-0" rel="mw:referencedBy"><span class="mw-linkback-text">↑</span></a></span> <span id="mw-reference-text-cite&#95;note-book-1" class="mw-reference-text reference-text">The book</span>
<ol class="mw-subreference-list">
<li id="cite&#95;note-2" data-mw-footnote-number="1.1"><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&#95;note-2" class="mw-reference-text reference-text">p. 1</span></li>
</ol>
</li>
</ol>
</div>
!! end

# FIXME: restore self-closing references tag
!! test
Main+details reference used after sub-reference
!! config
wgCiteSubReferencing=true
!! wikitext
<ref details="p. 1" name="book" /> <ref details="p. 2" name="book">The book</ref>
<references>
</references>
!! html/php
<p><sup id="cite&#95;ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup> <sup id="cite&#95;ref-3" class="reference"><a href="#cite_note-3"><span class="cite-bracket">&#91;</span>1.2<span class="cite-bracket">&#93;</span></a></sup>
</p>
<div class="mw-references-wrap"><ol class="references">
<li><span class="mw-cite-backlink">↑</span> <span class="reference-text">The book</span>
<ol class="mw-subreference-list"><li id="cite&#95;note-2"><span class="mw-cite-backlink"><a href="#cite_ref-2">↑</a></span> <span class="reference-text">p. 1</span>
</li>
<li id="cite&#95;note-3"><span class="mw-cite-backlink"><a href="#cite_ref-3">↑</a></span> <span class="reference-text">p. 2</span>
</li>
</ol></li>
</ol></div>
!! html/parsoid
<p><sup class="mw-ref reference" id="cite&#95;ref-2" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"details":"p. 1","name":"book"},"mainRef":"book","body":{"id":"mw-reference-text-cite_note-2"}}'><a href="./Parser_test#cite_note-2"><span class="mw-reflink-text"><span class="cite-bracket">[</span>1.1<span class="cite-bracket">]</span></span></a></sup> <sup class="mw-ref reference" id="cite&#95;ref-3" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"details":"p. 2","name":"book"},"body":{"id":"mw-reference-text-cite_note-3"},"mainRef":"book","mainBody":"mw-reference-text-cite_note-book-1"}'><a href="./Parser_test#cite_note-3"><span class="mw-reflink-text"><span class="cite-bracket">[</span>1.2<span class="cite-bracket">]</span></span></a></sup></p>
<div class="mw-references-wrap" typeof="mw:Extension/references" data-mw='{"name":"references","attrs":{},"body":{"html":"\n&lt;sup typeof=\"mw:Extension/ref\" data-mw=&apos;{\"name\":\"ref\",\"attrs\":{\"name\":\"book\",\"group\":\"\"},\"body\":{\"id\":\"mw-reference-text-cite_note-book-1\"},\"isSyntheticMainRef\":1}&apos;>The book&lt;/sup>"}}'>
<ol class="mw-references references">
<li id="cite&#95;note-book-1" data-mw-footnote-number="1"><span rel="mw:referencedBy" class="mw-cite-backlink"></span> <span id="mw-reference-text-cite&#95;note-book-1" class="mw-reference-text reference-text">The book</span>
<ol class="mw-subreference-list">
<li id="cite&#95;note-2" data-mw-footnote-number="1.1"><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&#95;note-2" class="mw-reference-text reference-text">p. 1</span></li>
<li id="cite&#95;note-3" data-mw-footnote-number="1.2"><span class="mw-cite-backlink"><a href="./Parser_test#cite_ref-3" rel="mw:referencedBy"><span class="mw-linkback-text">↑</span></a></span> <span id="mw-reference-text-cite&#95;note-3" class="mw-reference-text reference-text">p. 2</span></li>
</ol>
</li>
</ol>
</div>
!! end

# FIXME: restore self-closing references tag
!! test
Main+details reference used after sub-reference and standalone main ref
!! config
wgCiteSubReferencing=true
!! options
parsoid=wt2html
!! wikitext
<ref details="p. 1" name="book" /> <ref details="p. 2" name="book">The book</ref> <ref name="book">The book</ref>
<references>
</references>
!! html/php
<p><sup id="cite&#95;ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup> <sup id="cite&#95;ref-3" class="reference"><a href="#cite_note-3"><span class="cite-bracket">&#91;</span>1.2<span class="cite-bracket">&#93;</span></a></sup> <sup id="cite&#95;ref-book&#95;1-0" class="reference"><a href="#cite_note-book-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-book-1"><span class="mw-cite-backlink"><a href="#cite_ref-book_1-0">↑</a></span> <span class="reference-text">The book</span>
<ol class="mw-subreference-list"><li id="cite&#95;note-2"><span class="mw-cite-backlink"><a href="#cite_ref-2">↑</a></span> <span class="reference-text">p. 1</span>
</li>
<li id="cite&#95;note-3"><span class="mw-cite-backlink"><a href="#cite_ref-3">↑</a></span> <span class="reference-text">p. 2</span>
</li>
</ol></li>
</ol></div>
!! html/parsoid
<p><sup class="mw-ref reference" id="cite&#95;ref-2" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"details":"p. 1","name":"book"},"mainRef":"book","body":{"id":"mw-reference-text-cite_note-2"}}'><a href="./Parser_test#cite_note-2"><span class="mw-reflink-text"><span class="cite-bracket">[</span>1.1<span class="cite-bracket">]</span></span></a></sup> <sup class="mw-ref reference" id="cite&#95;ref-3" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"details":"p. 2","name":"book"},"body":{"id":"mw-reference-text-cite_note-3"},"mainRef":"book","mainBody":"mw-reference-text-cite_note-book-1"}'><a href="./Parser_test#cite_note-3"><span class="mw-reflink-text"><span class="cite-bracket">[</span>1.2<span class="cite-bracket">]</span></span></a></sup> <sup class="mw-ref reference" id="cite&#95;ref-book&#95;1-0" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"name":"book"},"body":{"id":"mw-reference-text-cite_note-book-1"}}'><a href="./Parser_test#cite_note-book-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":{},"body":{"html":"\n&lt;sup typeof=\"mw:Extension/ref\" data-mw=&apos;{\"name\":\"ref\",\"attrs\":{\"name\":\"book\",\"group\":\"\"},\"body\":{\"id\":\"mw-reference-text-cite_note-book-1\"},\"isSyntheticMainRef\":1}&apos;>The book&lt;/sup>"}}'>
<ol class="mw-references references">
<li id="cite&#95;note-book-1" data-mw-footnote-number="1"><span class="mw-cite-backlink"><a href="./Parser_test#cite_ref-book_1-0" rel="mw:referencedBy"><span class="mw-linkback-text">↑</span></a></span> <span id="mw-reference-text-cite&#95;note-book-1" class="mw-reference-text reference-text">The book</span>
<ol class="mw-subreference-list">
<li id="cite&#95;note-2" data-mw-footnote-number="1.1"><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&#95;note-2" class="mw-reference-text reference-text">p. 1</span></li>
<li id="cite&#95;note-3" data-mw-footnote-number="1.2"><span class="mw-cite-backlink"><a href="./Parser_test#cite_ref-3" rel="mw:referencedBy"><span class="mw-linkback-text">↑</span></a></span> <span id="mw-reference-text-cite&#95;note-3" class="mw-reference-text reference-text">p. 2</span></li>
</ol>
</li>
</ol>
</div>
!! end

!! test
Unused, list-defined parent reference
!! config
wgCiteSubReferencing=true
!! wikitext
<ref details="p. 1" name="book" />
<references>
<ref name="book">The book</ref>
</references>
!! html/php
<p><sup id="cite&#95;ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup>
</p>
<div class="mw-references-wrap"><ol class="references">
<li><span class="mw-cite-backlink">↑</span> <span class="reference-text">The book</span>
<ol class="mw-subreference-list"><li id="cite&#95;note-2"><span class="mw-cite-backlink"><a href="#cite_ref-2">↑</a></span> <span class="reference-text">p. 1</span>
</li>
</ol></li>
</ol></div>
!! html/parsoid
<p><sup class="mw-ref reference" id="cite&#95;ref-2" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"details":"p. 1","name":"book"},"mainRef":"book","body":{"id":"mw-reference-text-cite_note-2"}}'><a href="./Parser_test#cite_note-2"><span class="mw-reflink-text"><span class="cite-bracket">[</span>1.1<span class="cite-bracket">]</span></span></a></sup></p>
<div class="mw-references-wrap" typeof="mw:Extension/references" data-mw='{"name":"references","attrs":{},"body":{"html":"\n&lt;sup class=\"mw-ref reference\" rel=\"dc:references\" typeof=\"mw:Extension/ref\" data-mw=&apos;{\"name\":\"ref\",\"attrs\":{\"name\":\"book\"},\"body\":{\"id\":\"mw-reference-text-cite_note-book-1\"}}&apos;>&lt;a href=\"./Parser_test#cite_note-book-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>\n"}}'>
<ol class="mw-references references">
<li id="cite&#95;note-book-1" data-mw-footnote-number="1"><span rel="mw:referencedBy" class="mw-cite-backlink"></span> <span id="mw-reference-text-cite&#95;note-book-1" class="mw-reference-text reference-text">The book</span>
<ol class="mw-subreference-list">
<li id="cite&#95;note-2" data-mw-footnote-number="1.1"><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&#95;note-2" class="mw-reference-text reference-text">p. 1</span></li>
</ol>
</li>
</ol>
</div>
!! end

!! test
No main content due to missing name or empty content
!! config
wgCiteSubReferencing=true
!! wikitext
<ref details="page 1" />
<references />
!! html/php
<p><span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: A <code>&lt;ref&gt;</code> tag with details must contain content or point to a parent reference by name.</span>
</p>
!! html/parsoid
<p><sup class="mw-ref reference" id="cite&#95;ref-1" rel="dc:references" typeof="mw:Extension/ref mw:Error" data-mw='{"name":"ref","attrs":{"details":"page 1"},"errors":[{"key":"cite_error_details_missing_parent"}]}'><a href="./Parser_test#cite_note-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":{}}'>
<ol class="mw-references references">
<li id="cite&#95;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&#95;note-1" class="mw-reference-text reference-text"></span> <span typeof="mw:I18n" class="error mw-ext-cite-error" data-mw-i18n='{"/":{"lang":"x-user","key":"cite_error","params":[{"text":{"key":"cite_error_details_missing_parent","params":[]}}]}}'></span></li>
</ol>
</div>
!! end

!! test
Empty content and no name
!! config
wgCiteSubReferencing=true
!! wikitext
<ref details="page 1"></ref>
<references />
!! html/php
<p><span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: A <code>&lt;ref&gt;</code> tag with details must contain content or point to a parent reference by name.</span>
</p>
!! html/parsoid
<p><sup class="mw-ref reference" id="cite&#95;ref-1" rel="dc:references" typeof="mw:Extension/ref mw:Error" data-mw='{"name":"ref","attrs":{"details":"page 1"},"body":{"html":""},"errors":[{"key":"cite_error_details_missing_parent"}]}'><a href="./Parser_test#cite_note-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":{}}'>
<ol class="mw-references references">
<li id="cite&#95;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&#95;note-1" class="mw-reference-text reference-text"></span> <span typeof="mw:I18n" class="error mw-ext-cite-error" data-mw-i18n='{"/":{"lang":"x-user","key":"cite_error","params":[{"text":{"key":"cite_error_details_missing_parent","params":[]}}]}}'></span></li>
</ol>
</div>
!! end

!! test
No main content due to missing named main ref
!! config
wgCiteSubReferencing=true
!! wikitext
<ref details="page 1" name="missingbook" />
<references />
!! html/php
<p><sup id="cite&#95;ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup>
</p>
<div class="mw-references-wrap"><ol class="references">
<li><span class="mw-cite-backlink">↑</span> <span class="reference-text"> <span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: Invalid <code>&lt;ref&gt;</code> tag; no text was provided for refs named <code>missingbook</code></span></span>
<ol class="mw-subreference-list"><li id="cite&#95;note-2"><span class="mw-cite-backlink"><a href="#cite_ref-2">↑</a></span> <span class="reference-text">page 1</span>
</li>
</ol></li>
</ol></div>
!! html/parsoid
<p><sup class="mw-ref reference" id="cite&#95;ref-2" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"details":"page 1","name":"missingbook"},"mainRef":"missingbook","body":{"id":"mw-reference-text-cite_note-2"}}'><a href="./Parser_test#cite_note-2"><span class="mw-reflink-text"><span class="cite-bracket">[</span>1.1<span class="cite-bracket">]</span></span></a></sup></p>
<div class="mw-references-wrap" typeof="mw:Extension/references" data-mw='{"name":"references","attrs":{}}'>
<ol class="mw-references references">
<li id="cite&#95;note-missingbook-1" data-mw-footnote-number="1"><span rel="mw:referencedBy" class="mw-cite-backlink"></span> <span id="mw-reference-text-cite&#95;note-missingbook-1" class="mw-reference-text reference-text"></span>
<ol class="mw-subreference-list">
<li id="cite&#95;note-2" data-mw-footnote-number="1.1"><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&#95;note-2" class="mw-reference-text reference-text">page 1</span></li>
</ol>
</li>
</ol>
</div>
!! end

# FIXME: Currently fails round-trips because <ref></ref> becomes <ref />, see T392195
!! test
Empty content and missing named main ref
!! config
wgCiteSubReferencing=true
!! options
parsoid=wt2html
!! wikitext
<ref details="page 1" name="missingbook"></ref>
<references />
!! html/php
<p><sup id="cite&#95;ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup>
</p>
<div class="mw-references-wrap"><ol class="references">
<li><span class="mw-cite-backlink">↑</span> <span class="reference-text"> <span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: Invalid <code>&lt;ref&gt;</code> tag; no text was provided for refs named <code>missingbook</code></span></span>
<ol class="mw-subreference-list"><li id="cite&#95;note-2"><span class="mw-cite-backlink"><a href="#cite_ref-2">↑</a></span> <span class="reference-text">page 1</span>
</li>
</ol></li>
</ol></div>
!! html/parsoid
<p><sup class="mw-ref reference" id="cite&#95;ref-2" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"details":"page 1","name":"missingbook"},"body":{"id":"mw-reference-text-cite_note-2"},"mainRef":"missingbook"}'><a href="./Parser_test#cite_note-2"><span class="mw-reflink-text"><span class="cite-bracket">[</span>1.1<span class="cite-bracket">]</span></span></a></sup></p>
<div class="mw-references-wrap" typeof="mw:Extension/references" data-mw='{"name":"references","attrs":{}}'>
<ol class="mw-references references">
<li id="cite&#95;note-missingbook-1" data-mw-footnote-number="1"><span rel="mw:referencedBy" class="mw-cite-backlink"></span> <span id="mw-reference-text-cite&#95;note-missingbook-1" class="mw-reference-text reference-text"></span>
<ol class="mw-subreference-list">
<li id="cite&#95;note-2" data-mw-footnote-number="1.1"><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&#95;note-2" class="mw-reference-text reference-text">page 1</span></li>
</ol>
</li>
</ol>
</div>
!! end

# FIXME: Currently fails round-trips because <ref></ref> becomes <ref />, see T392195
!! test
T392195: Details get lost on sub-ref with empty main content
!! config
wgCiteSubReferencing=true
!! options
parsoid=wt2html
!! wikitext
<ref name="book">Book</ref><ref details="page 1" name="book"></ref>
<references />
!! html/php
<p><sup id="cite&#95;ref-book&#95;1-0" class="reference"><a href="#cite_note-book-1"><span class="cite-bracket">&#91;</span>1<span class="cite-bracket">&#93;</span></a></sup><sup id="cite&#95;ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup>
</p>
<div class="mw-references-wrap"><ol class="references">
<li id="cite&#95;note-book-1"><span class="mw-cite-backlink"><a href="#cite_ref-book_1-0">↑</a></span> <span class="reference-text">Book</span>
<ol class="mw-subreference-list"><li id="cite&#95;note-2"><span class="mw-cite-backlink"><a href="#cite_ref-2">↑</a></span> <span class="reference-text">page 1</span>
</li>
</ol></li>
</ol></div>
!! html/parsoid
<p><sup class="mw-ref reference" id="cite&#95;ref-book&#95;1-0" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"name":"book"},"body":{"id":"mw-reference-text-cite_note-book-1"}}'><a href="./Parser_test#cite_note-book-1"><span class="mw-reflink-text"><span class="cite-bracket">[</span>1<span class="cite-bracket">]</span></span></a></sup><sup class="mw-ref reference" id="cite&#95;ref-2" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"details":"page 1","name":"book"},"body":{"id":"mw-reference-text-cite_note-2"},"mainRef":"book"}'><a href="./Parser_test#cite_note-2"><span class="mw-reflink-text"><span class="cite-bracket">[</span>1.1<span class="cite-bracket">]</span></span></a></sup></p>
<div class="mw-references-wrap" typeof="mw:Extension/references" data-mw='{"name":"references","attrs":{},"body":{"html":"\n&lt;sup typeof=\"mw:Extension/ref\" data-mw=&apos;{\"name\":\"ref\",\"attrs\":{\"name\":\"book\",\"group\":\"\"},\"body\":{\"id\":\"mw-reference-text-cite_note-book-1\"},\"isSyntheticMainRef\":1}&apos;>Book&lt;/sup>"}}'>
<ol class="mw-references references">
<li id="cite&#95;note-book-1" data-mw-footnote-number="1"><span class="mw-cite-backlink"><a href="./Parser_test#cite_ref-book_1-0" rel="mw:referencedBy"><span class="mw-linkback-text">↑</span></a></span> <span id="mw-reference-text-cite&#95;note-book-1" class="mw-reference-text reference-text">Book</span>
<ol class="mw-subreference-list">
<li id="cite&#95;note-2" data-mw-footnote-number="1.1"><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&#95;note-2" class="mw-reference-text reference-text">page 1</span></li>
</ol>
</li>
</ol>
</div>
!! end

!! test
Empty details content with name, ignored outside of <references>
!! config
wgCiteSubReferencing=true
!! wikitext
<ref details="" name="a">Book</ref>
<references />
!! html/php
<p><sup id="cite&#95;ref-a&#95;1-0" class="reference"><a href="#cite_note-a-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-a-1"><span class="mw-cite-backlink"><a href="#cite_ref-a_1-0">↑</a></span> <span class="reference-text">Book</span>
</li>
</ol></div>
!! html/parsoid
<p><sup class="mw-ref reference" id="cite&#95;ref-a&#95;1-0" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"details":"","name":"a"},"body":{"id":"mw-reference-text-cite_note-a-1"}}'><a href="./Parser_test#cite_note-a-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":{}}'>
<ol class="mw-references references">
<li id="cite&#95;note-a-1" data-mw-footnote-number="1"><span class="mw-cite-backlink"><a href="./Parser_test#cite_ref-a_1-0" rel="mw:referencedBy"><span class="mw-linkback-text">↑</span></a></span> <span id="mw-reference-text-cite&#95;note-a-1" class="mw-reference-text reference-text">Book</span></li>
</ol>
</div>
!! end

!! test
Empty details content without name, ignored outside of <references>
!! config
wgCiteSubReferencing=true
!! wikitext
<ref details="">Book</ref>
<references />
!! html/php
<p><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>
</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">Book</span>
</li>
</ol></div>
!! html/parsoid
<p><sup class="mw-ref reference" id="cite&#95;ref-1" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"details":""},"body":{"id":"mw-reference-text-cite_note-1"}}'><a href="./Parser_test#cite_note-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":{}}'>
<ol class="mw-references references">
<li id="cite&#95;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&#95;note-1" class="mw-reference-text reference-text">Book</span></li>
</ol>
</div>
!! end

!! test
Empty details content inside of <references>
!! config
wgCiteSubReferencing=true
!! wikitext
<ref name="a" />
<references>
<ref details="" name="a">Book</ref>
</references>
!! html/php
<p><sup id="cite&#95;ref-a&#95;1-0" class="reference"><a href="#cite_note-a-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-a-1"><span class="mw-cite-backlink"><a href="#cite_ref-a_1-0">↑</a></span> <span class="reference-text">Book <span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: <code>&lt;ref&gt;</code> tag with name "a" cannot use details when inside <code>&lt;references&gt;</code>.</span></span>
</li>
</ol></div>
!! html/parsoid
<p><sup class="mw-ref reference" id="cite&#95;ref-a&#95;1-0" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"name":"a"}}'><a href="./Parser_test#cite_note-a-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":{},"body":{"html":"\n&lt;sup class=\"mw-ref reference\" rel=\"dc:references\" typeof=\"mw:Extension/ref mw:Error\" data-mw=&apos;{\"name\":\"ref\",\"attrs\":{\"details\":\"\",\"name\":\"a\"},\"body\":{\"id\":\"mw-reference-text-cite_note-a-1\"},\"errors\":[{\"key\":\"cite_error_details_unsupported_context\",\"params\":[\"a\"]}]}&apos;>&lt;a href=\"./Parser_test#cite_note-a-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>\n"}}'>
<ol class="mw-references references">
<li id="cite&#95;note-a-1" data-mw-footnote-number="1"><span class="mw-cite-backlink"><a href="./Parser_test#cite_ref-a_1-0" rel="mw:referencedBy"><span class="mw-linkback-text">↑</span></a></span> <span id="mw-reference-text-cite&#95;note-a-1" class="mw-reference-text reference-text">Book</span></li>
</ol>
</div>
!! end

!! test
Unused list-defined sub-ref with no name
!! config
wgCiteSubReferencing=true
!! wikitext
<references>
<ref details="page 1">Book</ref>
</references>
!! html/php
<p><span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: <code>&lt;ref&gt;</code> tag with name "" cannot use details when inside <code>&lt;references&gt;</code>.</span>
</p>
!! html/parsoid
<div class="mw-references-wrap" typeof="mw:Extension/references" data-mw='{"name":"references","attrs":{},"body":{"html":"\n&lt;sup class=\"mw-ref reference\" rel=\"dc:references\" typeof=\"mw:Extension/ref\" data-mw=&apos;{\"name\":\"ref\",\"attrs\":{\"details\":\"page 1\"},\"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>\n"}}'>
<ol class="mw-references references">
<li id="cite&#95;note-1" data-mw-footnote-number="1"><span rel="mw:referencedBy" class="mw-cite-backlink"></span> <span id="mw-reference-text-cite&#95;note-1" class="mw-reference-text reference-text">Book</span></li>
</ol>
<span class="error mw-ext-cite-error" data-mw-i18n='{"/":{"lang":"x-user","key":"cite_error","params":[{"text":{"key":"cite_error_details_unsupported_context","params":[""]}}]}}' typeof="mw:I18n"></span><br/>
<span class="error mw-ext-cite-error" data-mw-i18n='{"/":{"lang":"x-user","key":"cite_error","params":[{"text":{"key":"cite_error_references_no_key","params":[]}}]}}' typeof="mw:I18n"></span>
</div>
!! end

# T390974: Bad refs don't round-trip
!! test
Unused list-defined sub-ref with linked existing main ref
!! config
wgCiteSubReferencing=true
!! wikitext
<ref name="book">Book</ref>
<references>
<ref details="page 1" name="book"></ref>
</references>
!! html/php
<p><sup id="cite&#95;ref-book&#95;1-0" class="reference"><a href="#cite_note-book-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-book-1"><span class="mw-cite-backlink"><a href="#cite_ref-book_1-0">↑</a></span> <span class="reference-text">Book</span>
</li>
</ol></div>
<p><span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: <code>&lt;ref&gt;</code> tag with name "book" cannot use details when inside <code>&lt;references&gt;</code>.</span>
</p>
!! html/parsoid
<p><sup class="mw-ref reference" id="cite&#95;ref-book&#95;1-0" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"name":"book"},"body":{"id":"mw-reference-text-cite_note-book-1"}}'><a href="./Parser_test#cite_note-book-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":{},"body":{"html":"\n&lt;sup class=\"mw-ref reference\" rel=\"dc:references\" typeof=\"mw:Extension/ref mw:Error\" data-mw=&apos;{\"name\":\"ref\",\"attrs\":{\"details\":\"page 1\",\"name\":\"book\"},\"body\":{\"html\":\"\"},\"errors\":[{\"key\":\"cite_error_details_unsupported_context\",\"params\":[\"book\"]},{\"key\":\"cite_error_empty_references_define\",\"params\":[\"book\",\"\"]}]}&apos;>&lt;a href=\"./Parser_test#cite_note-book-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>\n"}}'>
<ol class="mw-references references">
<li id="cite&#95;note-book-1" data-mw-footnote-number="1"><span class="mw-cite-backlink"><a href="./Parser_test#cite_ref-book_1-0" rel="mw:referencedBy"><span class="mw-linkback-text">↑</span></a></span> <span id="mw-reference-text-cite&#95;note-book-1" class="mw-reference-text reference-text">Book</span></li>
</ol>
</div>
!! end

!! test
There is no such thing as a list-defined sub-ref (completely unused)
!! config
wgCiteSubReferencing=true
!! wikitext
<references>
<ref details="p. 1" name="book">The book</ref>
</references>
!! html/php
<p><span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: <code>&lt;ref&gt;</code> tag with name "book" cannot use details when inside <code>&lt;references&gt;</code>.</span>
</p>
!! html/parsoid
<div class="mw-references-wrap" typeof="mw:Extension/references" data-mw='{"name":"references","attrs":{},"body":{"html":"\n&lt;sup class=\"mw-ref reference\" rel=\"dc:references\" typeof=\"mw:Extension/ref\" data-mw=&apos;{\"name\":\"ref\",\"attrs\":{\"details\":\"p. 1\",\"name\":\"book\"},\"body\":{\"id\":\"mw-reference-text-cite_note-book-1\"}}&apos;>&lt;a href=\"./Parser_test#cite_note-book-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>\n"}}'>
<ol class="mw-references references">
<li id="cite&#95;note-book-1" data-mw-footnote-number="1"><span rel="mw:referencedBy" class="mw-cite-backlink"></span> <span id="mw-reference-text-cite&#95;note-book-1" class="mw-reference-text reference-text">The book</span></li>
</ol>
<span class="error mw-ext-cite-error" data-mw-i18n='{"/":{"lang":"x-user","key":"cite_error","params":[{"text":{"key":"cite_error_details_unsupported_context","params":["book"]}}]}}' typeof="mw:I18n"></span><br/>
<span class="error mw-ext-cite-error" data-mw-i18n='{"/":{"lang":"x-user","key":"cite_error","params":[{"text":{"key":"cite_error_references_missing_key","params":["book"]}}]}}' typeof="mw:I18n"></span>
</div>
!! end

# T390961: fails to round-trip main+details after main
!! test
Unused list defined sub-ref with used main content
!! config
wgCiteSubReferencing=true
!! wikitext
<ref name="book" />
<references>
<ref details="page 1" name="book">Book</ref>
<ref details="page 2" name="book">Book</ref>
</references>
!! html/php
<p><sup id="cite&#95;ref-book&#95;1-0" class="reference"><a href="#cite_note-book-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-book-1"><span class="mw-cite-backlink"><a href="#cite_ref-book_1-0">↑</a></span> <span class="reference-text">Book <span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: <code>&lt;ref&gt;</code> tag with name "book" cannot use details when inside <code>&lt;references&gt;</code>.</span></span>
</li>
</ol></div>
!! html/parsoid
<p><sup class="mw-ref reference" id="cite&#95;ref-book&#95;1-0" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"name":"book"}}'><a href="./Parser_test#cite_note-book-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":{},"body":{"html":"\n&lt;sup class=\"mw-ref reference\" rel=\"dc:references\" typeof=\"mw:Extension/ref mw:Error\" data-mw=&apos;{\"name\":\"ref\",\"attrs\":{\"details\":\"page 1\",\"name\":\"book\"},\"body\":{\"id\":\"mw-reference-text-cite_note-book-1\"},\"errors\":[{\"key\":\"cite_error_details_unsupported_context\",\"params\":[\"book\"]}]}&apos;>&lt;a href=\"./Parser_test#cite_note-book-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>\n&lt;sup class=\"mw-ref reference\" rel=\"dc:references\" typeof=\"mw:Extension/ref mw:Error\" data-mw=&apos;{\"name\":\"ref\",\"attrs\":{\"details\":\"page 2\",\"name\":\"book\"},\"body\":{\"id\":\"mw-reference-text-cite_note-book-1\"},\"errors\":[{\"key\":\"cite_error_details_unsupported_context\",\"params\":[\"book\"]}]}&apos;>&lt;a href=\"./Parser_test#cite_note-book-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>\n"}}'>
<ol class="mw-references references">
<li id="cite&#95;note-book-1" data-mw-footnote-number="1"><span class="mw-cite-backlink"><a href="./Parser_test#cite_ref-book_1-0" rel="mw:referencedBy"><span class="mw-linkback-text">↑</span></a></span> <span id="mw-reference-text-cite&#95;note-book-1" class="mw-reference-text reference-text">Book</span></li>
</ol>
</div>
!! end

!! test
Unused list defined sub-ref with used main content (same as above but with #tag)
!! config
wgCiteSubReferencing=true
!! wikitext
<ref name="book" />
{{#tag:references|<ref details="page 1" name="book">Book</ref>
<ref details="page 2" name="book">Book</ref>}}
!! html/php
<p><sup id="cite&#95;ref-book&#95;1-0" class="reference"><a href="#cite_note-book-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><span class="mw-cite-backlink">↑</span> <span class="reference-text">Book <span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: <code>&lt;ref&gt;</code> tag with name "book" cannot use details when inside <code>&lt;references&gt;</code>.</span></span>
</li>
</ol></div>
!! html/parsoid
<p><sup class="mw-ref reference" id="cite&#95;ref-book&#95;1-0" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"name":"book"}}'><a href="./Parser_test#cite_note-book-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 mw:Transclusion" data-mw='{"name":"references","attrs":{},"body":{"extsrc":"&lt;ref details=\"page 1\" name=\"book\">Book&lt;/ref>\n&lt;ref details=\"page 2\" name=\"book\">Book&lt;/ref>"},"parts":[{"template":{"target":{"wt":"#tag:references","function":"tag"},"params":{"1":{"wt":"&lt;ref details=\"page 1\" name=\"book\">Book&lt;/ref>\n&lt;ref details=\"page 2\" name=\"book\">Book&lt;/ref>"}},"i":0}}]}'>
<ol class="mw-references references">
<li id="cite&#95;note-book-1" data-mw-footnote-number="1"><span class="mw-cite-backlink"><a href="./Parser_test#cite_ref-book_1-0" rel="mw:referencedBy"><span class="mw-linkback-text">↑</span></a></span> <span id="mw-reference-text-cite&#95;note-book-1" class="mw-reference-text reference-text">Book</span></li>
</ol>
</div>
!! end

!! test
There is no such thing as a list-defined sub-ref (duplicate main content)
!! config
wgCiteSubReferencing=true
!! wikitext
<ref name="book">The book</ref>
<references>
<ref details="p. 1" name="book">The book</ref>
</references>
!! html/php
<p><sup id="cite&#95;ref-book&#95;1-0" class="reference"><a href="#cite_note-book-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-book-1"><span class="mw-cite-backlink"><a href="#cite_ref-book_1-0">↑</a></span> <span class="reference-text">The book <span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: <code>&lt;ref&gt;</code> tag with name "book" cannot use details when inside <code>&lt;references&gt;</code>.</span></span>
</li>
</ol></div>
!! html/parsoid
<p><sup class="mw-ref reference" id="cite&#95;ref-book&#95;1-0" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"name":"book"},"body":{"id":"mw-reference-text-cite_note-book-1"}}'><a href="./Parser_test#cite_note-book-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":{},"body":{"html":"\n&lt;sup class=\"mw-ref reference\" rel=\"dc:references\" typeof=\"mw:Extension/ref mw:Error\" data-mw=&apos;{\"name\":\"ref\",\"attrs\":{\"details\":\"p. 1\",\"name\":\"book\"},\"body\":{\"id\":\"mw-reference-text-cite_note-book-1\"},\"errors\":[{\"key\":\"cite_error_details_unsupported_context\",\"params\":[\"book\"]}]}&apos;>&lt;a href=\"./Parser_test#cite_note-book-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>\n"}}'>
<ol class="mw-references references">
<li id="cite&#95;note-book-1" data-mw-footnote-number="1"><span class="mw-cite-backlink"><a href="./Parser_test#cite_ref-book_1-0" rel="mw:referencedBy"><span class="mw-linkback-text">↑</span></a></span> <span id="mw-reference-text-cite&#95;note-book-1" class="mw-reference-text reference-text">The book</span></li>
</ol>
</div>
!! end

!! test
Unused list defined sub-ref due to duplicate details content
!! config
wgCiteSubReferencing=true
!! wikitext
<ref details="page 1" name="book" />
<references>
<ref details="page 1" name="book">Book</ref>
</references>
!! html/php
<p><sup id="cite&#95;ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup>
</p>
<div class="mw-references-wrap"><ol class="references">
<li><span class="mw-cite-backlink">↑</span> <span class="reference-text">Book <span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: <code>&lt;ref&gt;</code> tag with name "book" cannot use details when inside <code>&lt;references&gt;</code>.</span></span>
<ol class="mw-subreference-list"><li id="cite&#95;note-2"><span class="mw-cite-backlink"><a href="#cite_ref-2">↑</a></span> <span class="reference-text">page 1</span>
</li>
</ol></li>
</ol></div>
!! html/parsoid
<p><sup class="mw-ref reference" id="cite&#95;ref-2" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"details":"page 1","name":"book"},"mainRef":"book","body":{"id":"mw-reference-text-cite_note-2"}}'><a href="./Parser_test#cite_note-2"><span class="mw-reflink-text"><span class="cite-bracket">[</span>1.1<span class="cite-bracket">]</span></span></a></sup></p>
<div class="mw-references-wrap" typeof="mw:Extension/references" data-mw='{"name":"references","attrs":{},"body":{"html":"\n&lt;sup class=\"mw-ref reference\" rel=\"dc:references\" typeof=\"mw:Extension/ref\" data-mw=&apos;{\"name\":\"ref\",\"attrs\":{\"details\":\"page 1\",\"name\":\"book\"},\"body\":{\"id\":\"mw-reference-text-cite_note-book-1\"}}&apos;>&lt;a href=\"./Parser_test#cite_note-book-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>\n"}}'>
<ol class="mw-references references">
<li id="cite&#95;note-book-1" data-mw-footnote-number="1"><span rel="mw:referencedBy" class="mw-cite-backlink"></span> <span id="mw-reference-text-cite&#95;note-book-1" class="mw-reference-text reference-text">Book</span>
<ol class="mw-subreference-list">
<li id="cite&#95;note-2" data-mw-footnote-number="1.1"><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&#95;note-2" class="mw-reference-text reference-text">page 1</span></li>
</ol>
</li>
</ol>
<span typeof="mw:I18n" class="error mw-ext-cite-error" data-mw-i18n='{"/":{"lang":"x-user","key":"cite_error","params":[{"text":{"key":"cite_error_details_unsupported_context","params":["book"]}}]}}'></span>
</div>
!! end

# T390992: detect conflicting main ref content in main+details
!! test
Conflicting main content
!! config
wgCiteSubReferencing=true
!! options
parsoid=wt2html
!! wikitext
<ref details="page 1" name="book">Book</ref> <ref details="page 2" name="book">Book, but different</ref>
!! html/php
<p><sup id="cite&#95;ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup> <sup id="cite&#95;ref-3" class="reference"><a href="#cite_note-3"><span class="cite-bracket">&#91;</span>1.2<span class="cite-bracket">&#93;</span></a></sup>
</p>
<div class="mw-references-wrap"><ol class="references">
<li><span class="mw-cite-backlink">↑</span> <span class="reference-text">Book <span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: Invalid <code>&lt;ref&gt;</code> tag; name "book" defined multiple times with different content</span></span>
<ol class="mw-subreference-list"><li id="cite&#95;note-2"><span class="mw-cite-backlink"><a href="#cite_ref-2">↑</a></span> <span class="reference-text">page 1</span>
</li>
<li id="cite&#95;note-3"><span class="mw-cite-backlink"><a href="#cite_ref-3">↑</a></span> <span class="reference-text">page 2</span>
</li>
</ol></li>
</ol></div>
!! html/parsoid
<p><sup class="mw-ref reference" id="cite&#95;ref-2" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"details":"page 1","name":"book"},"body":{"id":"mw-reference-text-cite_note-2"},"mainRef":"book","mainBody":"mw-reference-text-cite_note-book-1"}'><a href="./Parser_test#cite_note-2"><span class="mw-reflink-text"><span class="cite-bracket">[</span>1.1<span class="cite-bracket">]</span></span></a></sup> <sup class="mw-ref reference" id="cite&#95;ref-3" rel="dc:references" typeof="mw:Extension/ref mw:Error" data-mw='{"name":"ref","attrs":{"details":"page 2","name":"book"},"body":{"id":"mw-reference-text-cite_note-3"},"mainRef":"book","mainBody":"mw-reference-text-cite_note-book-1","errors":[{"key":"cite_error_references_duplicate_key","params":["book"]}]}'><a href="./Parser_test#cite_note-3"><span class="mw-reflink-text"><span class="cite-bracket">[</span>1.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,"body":{"html":"\n&lt;sup typeof=\"mw:Extension/ref\" data-mw=&apos;{\"name\":\"ref\",\"attrs\":{\"name\":\"book\",\"group\":\"\"},\"body\":{\"id\":\"mw-reference-text-cite_note-book-1\"},\"isSyntheticMainRef\":1}&apos;>Book&lt;/sup>"}}'>
<ol class="mw-references references">
<li id="cite&#95;note-book-1" data-mw-footnote-number="1"><span rel="mw:referencedBy" class="mw-cite-backlink"></span> <span id="mw-reference-text-cite&#95;note-book-1" class="mw-reference-text reference-text">Book</span>
<ol class="mw-subreference-list">
<li id="cite&#95;note-2" data-mw-footnote-number="1.1"><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&#95;note-2" class="mw-reference-text reference-text">page 1</span></li>
<li id="cite&#95;note-3" data-mw-footnote-number="1.2"><span class="mw-cite-backlink"><a href="./Parser_test#cite_ref-3" rel="mw:referencedBy"><span class="mw-linkback-text">↑</span></a></span> <span id="mw-reference-text-cite&#95;note-3" class="mw-reference-text reference-text">page 2</span> <span typeof="mw:I18n" class="error mw-ext-cite-error" data-mw-i18n='{"/":{"lang":"x-user","key":"cite_error","params":[{"text":{"key":"cite_error_references_duplicate_key","params":["book"]}}]}}'></span></li>
</ol>
</li>
</ol>
</div>
!! end

!! test
Repeating the main content when using details
!! config
wgCiteSubReferencing=true
!! wikitext
<ref name="book">Book</ref> <ref details="page 1" name="book">Book</ref> <ref details="page 1" name="book">Book</ref>
!! html/php
<p><sup id="cite&#95;ref-book&#95;1-0" class="reference"><a href="#cite_note-book-1"><span class="cite-bracket">&#91;</span>1<span class="cite-bracket">&#93;</span></a></sup> <sup id="cite&#95;ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup> <sup id="cite&#95;ref-2-1" class="reference"><a href="#cite_note-2"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup>
</p>
<div class="mw-references-wrap"><ol class="references">
<li id="cite&#95;note-book-1"><span class="mw-cite-backlink"><a href="#cite_ref-book_1-0">↑</a></span> <span class="reference-text">Book</span>
<ol class="mw-subreference-list"><li id="cite&#95;note-2"><span class="mw-cite-backlink">↑ <sup><a href="#cite_ref-2">1.0</a></sup> <sup><a href="#cite_ref-2-1">1.1</a></sup></span> <span class="reference-text">page 1</span>
</li>
</ol></li>
</ol></div>
!! html/parsoid
<p><sup class="mw-ref reference" id="cite&#95;ref-book&#95;1-0" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"name":"book"},"body":{"id":"mw-reference-text-cite_note-book-1"}}'><a href="./Parser_test#cite_note-book-1"><span class="mw-reflink-text"><span class="cite-bracket">[</span>1<span class="cite-bracket">]</span></span></a></sup> <sup class="mw-ref reference" id="cite&#95;ref-2" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"details":"page 1","name":"book"},"body":{"id":"mw-reference-text-cite_note-2"},"mainRef":"book","mainBody":"mw-reference-text-cite_note-book-1"}'><a href="./Parser_test#cite_note-2"><span class="mw-reflink-text"><span class="cite-bracket">[</span>1.1<span class="cite-bracket">]</span></span></a></sup> <sup class="mw-ref reference" id="cite&#95;ref-2-1" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"details":"page 1","name":"book"},"body":{"id":"mw-reference-text-cite_note-2"},"mainRef":"book","mainBody":"mw-reference-text-cite_note-book-1"}'><a href="./Parser_test#cite_note-2"><span class="mw-reflink-text"><span class="cite-bracket">[</span>1.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,"body":{"html":"\n&lt;sup typeof=\"mw:Extension/ref\" data-mw=&apos;{\"name\":\"ref\",\"attrs\":{\"name\":\"book\",\"group\":\"\"},\"body\":{\"id\":\"mw-reference-text-cite_note-book-1\"},\"isSyntheticMainRef\":1}&apos;>Book&lt;/sup>"}}'>
<ol class="mw-references references">
<li id="cite&#95;note-book-1" data-mw-footnote-number="1"><span class="mw-cite-backlink"><a href="./Parser_test#cite_ref-book_1-0" rel="mw:referencedBy"><span class="mw-linkback-text">↑</span></a></span> <span id="mw-reference-text-cite&#95;note-book-1" class="mw-reference-text reference-text">Book</span>
<ol class="mw-subreference-list">
<li id="cite&#95;note-2" data-mw-footnote-number="1.1"><span rel="mw:referencedBy" class="mw-cite-backlink"><a href="./Parser_test#cite_ref-2"><span class="mw-linkback-text">1</span></a> <a href="./Parser_test#cite_ref-2-1"><span class="mw-linkback-text">2</span></a></span> <span id="mw-reference-text-cite&#95;note-2" class="mw-reference-text reference-text">page 1</span></li>
</ol>
</li>
</ol>
</div>
!! end

!! test
T410125: Identical sub-refs in different <references> sections must be independent
!! config
wgCiteSubReferencing=true
!! wikitext
<ref name="a" details="p1">content</ref>
<references>
</references>
<ref name="a" details="p1">different</ref>
<references>
</references>
!! html/php
<p><sup id="cite&#95;ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup>
</p>
<div class="mw-references-wrap"><ol class="references">
<li><span class="mw-cite-backlink">↑</span> <span class="reference-text">content</span>
<ol class="mw-subreference-list"><li id="cite&#95;note-2"><span class="mw-cite-backlink"><a href="#cite_ref-2">↑</a></span> <span class="reference-text">p1</span>
</li>
</ol></li>
</ol></div>
<p><sup id="cite&#95;ref-4" class="reference"><a href="#cite_note-4"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup>
</p>
<div class="mw-references-wrap"><ol class="references">
<li><span class="mw-cite-backlink">↑</span> <span class="reference-text">different</span>
<ol class="mw-subreference-list"><li id="cite&#95;note-4"><span class="mw-cite-backlink"><a href="#cite_ref-4">↑</a></span> <span class="reference-text">p1</span>
</li>
</ol></li>
</ol></div>
!! html/parsoid
<p><sup class="mw-ref reference" id="cite&#95;ref-2" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"name":"a","details":"p1"},"body":{"id":"mw-reference-text-cite_note-2"},"mainRef":"a","mainBody":"mw-reference-text-cite_note-a-1"}'><a href="./Parser_test#cite_note-2"><span class="mw-reflink-text"><span class="cite-bracket">[</span>1.1<span class="cite-bracket">]</span></span></a></sup></p>
<div class="mw-references-wrap" typeof="mw:Extension/references" data-mw='{"name":"references","attrs":{},"body":{"html":"\n&lt;sup typeof=\"mw:Extension/ref\" data-mw=&apos;{\"name\":\"ref\",\"attrs\":{\"name\":\"a\",\"group\":\"\"},\"body\":{\"id\":\"mw-reference-text-cite_note-a-1\"},\"isSyntheticMainRef\":1}&apos;>content&lt;/sup>"}}'>
<ol class="mw-references references">
<li id="cite&#95;note-a-1" data-mw-footnote-number="1"><span rel="mw:referencedBy" class="mw-cite-backlink"></span> <span id="mw-reference-text-cite&#95;note-a-1" class="mw-reference-text reference-text">content</span>
<ol class="mw-subreference-list">
<li id="cite&#95;note-2" data-mw-footnote-number="1.1"><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&#95;note-2" class="mw-reference-text reference-text">p1</span></li>
</ol>
</li>
</ol>
</div>
<p><sup class="mw-ref reference" id="cite&#95;ref-4" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"name":"a","details":"p1"},"body":{"id":"mw-reference-text-cite_note-4"},"mainRef":"a","mainBody":"mw-reference-text-cite_note-a-3"}'><a href="./Parser_test#cite_note-4"><span class="mw-reflink-text"><span class="cite-bracket">[</span>1.1<span class="cite-bracket">]</span></span></a></sup></p>
<div class="mw-references-wrap" typeof="mw:Extension/references" data-mw='{"name":"references","attrs":{},"body":{"html":"\n&lt;sup typeof=\"mw:Extension/ref\" data-mw=&apos;{\"name\":\"ref\",\"attrs\":{\"name\":\"a\",\"group\":\"\"},\"body\":{\"id\":\"mw-reference-text-cite_note-a-3\"},\"isSyntheticMainRef\":1}&apos;>different&lt;/sup>"}}'>
<ol class="mw-references references">
<li id="cite&#95;note-a-3" data-mw-footnote-number="1"><span rel="mw:referencedBy" class="mw-cite-backlink"></span> <span id="mw-reference-text-cite&#95;note-a-3" class="mw-reference-text reference-text">different</span>
<ol class="mw-subreference-list">
<li id="cite&#95;note-4" data-mw-footnote-number="1.1"><span class="mw-cite-backlink"><a href="./Parser_test#cite_ref-4" rel="mw:referencedBy"><span class="mw-linkback-text">↑</span></a></span> <span id="mw-reference-text-cite&#95;note-4" class="mw-reference-text reference-text">p1</span></li>
</ol>
</li>
</ol>
</div>
!! end

# T406467: Parsoid doesn't do any merging yet
!! test
Merging sub-refs with inline main that do not repeat the main content
!! config
wgCiteSubReferencing=true
!! wikitext
<ref details="p1" name="a">Book</ref><ref details="p1" name="a" />
!! html/php
<p><sup id="cite&#95;ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup><sup id="cite&#95;ref-2-1" class="reference"><a href="#cite_note-2"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup>
</p>
<div class="mw-references-wrap"><ol class="references">
<li><span class="mw-cite-backlink">↑</span> <span class="reference-text">Book</span>
<ol class="mw-subreference-list"><li id="cite&#95;note-2"><span class="mw-cite-backlink">↑ <sup><a href="#cite_ref-2">1.0</a></sup> <sup><a href="#cite_ref-2-1">1.1</a></sup></span> <span class="reference-text">p1</span>
</li>
</ol></li>
</ol></div>
!! html/parsoid
<p><sup class="mw-ref reference" id="cite&#95;ref-2" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"details":"p1","name":"a"},"body":{"id":"mw-reference-text-cite_note-2"},"mainRef":"a","mainBody":"mw-reference-text-cite_note-a-1"}'><a href="./Parser_test#cite_note-2"><span class="mw-reflink-text"><span class="cite-bracket">[</span>1.1<span class="cite-bracket">]</span></span></a></sup><sup class="mw-ref reference" id="cite&#95;ref-2-1" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"details":"p1","name":"a"},"mainRef":"a","body":{"id":"mw-reference-text-cite_note-2"}}'><a href="./Parser_test#cite_note-2"><span class="mw-reflink-text"><span class="cite-bracket">[</span>1.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,"body":{"html":"\n&lt;sup typeof=\"mw:Extension/ref\" data-mw=&apos;{\"name\":\"ref\",\"attrs\":{\"name\":\"a\",\"group\":\"\"},\"body\":{\"id\":\"mw-reference-text-cite_note-a-1\"},\"isSyntheticMainRef\":1}&apos;>Book&lt;/sup>"}}'>
<ol class="mw-references references">
<li id="cite&#95;note-a-1" data-mw-footnote-number="1"><span rel="mw:referencedBy" class="mw-cite-backlink"></span> <span id="mw-reference-text-cite&#95;note-a-1" class="mw-reference-text reference-text">Book</span>
<ol class="mw-subreference-list">
<li id="cite&#95;note-2" data-mw-footnote-number="1.1"><span rel="mw:referencedBy" class="mw-cite-backlink"><a href="./Parser_test#cite_ref-2"><span class="mw-linkback-text">1</span></a> <a href="./Parser_test#cite_ref-2-1"><span class="mw-linkback-text">2</span></a></span> <span id="mw-reference-text-cite&#95;note-2" class="mw-reference-text reference-text">p1</span></li>
</ol>
</li>
</ol>
</div>
!! end

# T406467: Parsoid doesn't do any merging yet
!! test
Merging sub-refs with inline main that do repeat the main content
!! config
wgCiteSubReferencing=true
!! wikitext
<ref details="p1" name="a">Book</ref><ref details="p1" name="a">Book</ref>
!! html/php
<p><sup id="cite&#95;ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup><sup id="cite&#95;ref-2-1" class="reference"><a href="#cite_note-2"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup>
</p>
<div class="mw-references-wrap"><ol class="references">
<li><span class="mw-cite-backlink">↑</span> <span class="reference-text">Book</span>
<ol class="mw-subreference-list"><li id="cite&#95;note-2"><span class="mw-cite-backlink">↑ <sup><a href="#cite_ref-2">1.0</a></sup> <sup><a href="#cite_ref-2-1">1.1</a></sup></span> <span class="reference-text">p1</span>
</li>
</ol></li>
</ol></div>
!! html/parsoid
<p><sup class="mw-ref reference" id="cite&#95;ref-2" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"details":"p1","name":"a"},"body":{"id":"mw-reference-text-cite_note-2"},"mainRef":"a","mainBody":"mw-reference-text-cite_note-a-1"}'><a href="./Parser_test#cite_note-2"><span class="mw-reflink-text"><span class="cite-bracket">[</span>1.1<span class="cite-bracket">]</span></span></a></sup><sup class="mw-ref reference" id="cite&#95;ref-2-1" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"details":"p1","name":"a"},"body":{"id":"mw-reference-text-cite_note-2"},"mainRef":"a","mainBody":"mw-reference-text-cite_note-a-1"}'><a href="./Parser_test#cite_note-2"><span class="mw-reflink-text"><span class="cite-bracket">[</span>1.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,"body":{"html":"\n&lt;sup typeof=\"mw:Extension/ref\" data-mw=&apos;{\"name\":\"ref\",\"attrs\":{\"name\":\"a\",\"group\":\"\"},\"body\":{\"id\":\"mw-reference-text-cite_note-a-1\"},\"isSyntheticMainRef\":1}&apos;>Book&lt;/sup>"}}'>
<ol class="mw-references references">
<li id="cite&#95;note-a-1" data-mw-footnote-number="1"><span rel="mw:referencedBy" class="mw-cite-backlink"></span> <span id="mw-reference-text-cite&#95;note-a-1" class="mw-reference-text reference-text">Book</span>
<ol class="mw-subreference-list">
<li id="cite&#95;note-2" data-mw-footnote-number="1.1"><span rel="mw:referencedBy" class="mw-cite-backlink"><a href="./Parser_test#cite_ref-2"><span class="mw-linkback-text">1</span></a> <a href="./Parser_test#cite_ref-2-1"><span class="mw-linkback-text">2</span></a></span> <span id="mw-reference-text-cite&#95;note-2" class="mw-reference-text reference-text">p1</span></li>
</ol>
</li>
</ol>
</div>
!! end

# T406467: Parsoid doesn't do any merging yet
!! test
Merging sub-refs with standalone main
!! config
wgCiteSubReferencing=true
!! wikitext
<ref name="a">Book</ref><ref details="p1" name="a" /><ref details="p1" name="a" />
!! html/php
<p><sup id="cite&#95;ref-a&#95;1-0" class="reference"><a href="#cite_note-a-1"><span class="cite-bracket">&#91;</span>1<span class="cite-bracket">&#93;</span></a></sup><sup id="cite&#95;ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup><sup id="cite&#95;ref-2-1" class="reference"><a href="#cite_note-2"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup>
</p>
<div class="mw-references-wrap"><ol class="references">
<li id="cite&#95;note-a-1"><span class="mw-cite-backlink"><a href="#cite_ref-a_1-0">↑</a></span> <span class="reference-text">Book</span>
<ol class="mw-subreference-list"><li id="cite&#95;note-2"><span class="mw-cite-backlink">↑ <sup><a href="#cite_ref-2">1.0</a></sup> <sup><a href="#cite_ref-2-1">1.1</a></sup></span> <span class="reference-text">p1</span>
</li>
</ol></li>
</ol></div>
!! html/parsoid
<p><sup class="mw-ref reference" id="cite&#95;ref-a&#95;1-0" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"name":"a"},"body":{"id":"mw-reference-text-cite_note-a-1"}}'><a href="./Parser_test#cite_note-a-1"><span class="mw-reflink-text"><span class="cite-bracket">[</span>1<span class="cite-bracket">]</span></span></a></sup><sup class="mw-ref reference" id="cite&#95;ref-2" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"details":"p1","name":"a"},"mainRef":"a","body":{"id":"mw-reference-text-cite_note-2"}}'><a href="./Parser_test#cite_note-2"><span class="mw-reflink-text"><span class="cite-bracket">[</span>1.1<span class="cite-bracket">]</span></span></a></sup><sup class="mw-ref reference" id="cite&#95;ref-2-1" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"details":"p1","name":"a"},"mainRef":"a","body":{"id":"mw-reference-text-cite_note-2"}}'><a href="./Parser_test#cite_note-2"><span class="mw-reflink-text"><span class="cite-bracket">[</span>1.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,"body":{"html":"\n&lt;sup typeof=\"mw:Extension/ref\" data-mw=&apos;{\"name\":\"ref\",\"attrs\":{\"name\":\"a\",\"group\":\"\"},\"body\":{\"id\":\"mw-reference-text-cite_note-a-1\"},\"isSyntheticMainRef\":1}&apos;>Book&lt;/sup>"}}'>
<ol class="mw-references references">
<li id="cite&#95;note-a-1" data-mw-footnote-number="1"><span class="mw-cite-backlink"><a href="./Parser_test#cite_ref-a_1-0" rel="mw:referencedBy"><span class="mw-linkback-text">↑</span></a></span> <span id="mw-reference-text-cite&#95;note-a-1" class="mw-reference-text reference-text">Book</span>
<ol class="mw-subreference-list">
<li id="cite&#95;note-2" data-mw-footnote-number="1.1"><span rel="mw:referencedBy" class="mw-cite-backlink"><a href="./Parser_test#cite_ref-2"><span class="mw-linkback-text">1</span></a> <a href="./Parser_test#cite_ref-2-1"><span class="mw-linkback-text">2</span></a></span> <span id="mw-reference-text-cite&#95;note-2" class="mw-reference-text reference-text">p1</span></li>
</ol>
</li>
</ol>
</div>
!! end

# T406467: Parsoid doesn't do any merging yet
!! test
Merging sub-refs with multiple list-defined main refs
!! config
wgCiteSubReferencing=true
!! wikitext
<ref details="p1" name="a" /><ref details="p1" name="b" /><ref details="p1" name="a" /><ref details="p1" name="b" />
<references>
<ref name="a">Book A</ref>
<ref name="b">Book B</ref>
</references>
!! html/php
<p><sup id="cite&#95;ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup><sup id="cite&#95;ref-4" class="reference"><a href="#cite_note-4"><span class="cite-bracket">&#91;</span>2.1<span class="cite-bracket">&#93;</span></a></sup><sup id="cite&#95;ref-2-1" class="reference"><a href="#cite_note-2"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup><sup id="cite&#95;ref-4-1" class="reference"><a href="#cite_note-4"><span class="cite-bracket">&#91;</span>2.1<span class="cite-bracket">&#93;</span></a></sup>
</p>
<div class="mw-references-wrap"><ol class="references">
<li><span class="mw-cite-backlink">↑</span> <span class="reference-text">Book A</span>
<ol class="mw-subreference-list"><li id="cite&#95;note-2"><span class="mw-cite-backlink">↑ <sup><a href="#cite_ref-2">1.0</a></sup> <sup><a href="#cite_ref-2-1">1.1</a></sup></span> <span class="reference-text">p1</span>
</li>
</ol></li>
<li><span class="mw-cite-backlink">↑</span> <span class="reference-text">Book B</span>
<ol class="mw-subreference-list"><li id="cite&#95;note-4"><span class="mw-cite-backlink">↑ <sup><a href="#cite_ref-4">2.0</a></sup> <sup><a href="#cite_ref-4-1">2.1</a></sup></span> <span class="reference-text">p1</span>
</li>
</ol></li>
</ol></div>
!! html/parsoid
<p><sup class="mw-ref reference" id="cite&#95;ref-2" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"details":"p1","name":"a"},"mainRef":"a","body":{"id":"mw-reference-text-cite_note-2"}}'><a href="./Parser_test#cite_note-2"><span class="mw-reflink-text"><span class="cite-bracket">[</span>1.1<span class="cite-bracket">]</span></span></a></sup><sup class="mw-ref reference" id="cite&#95;ref-4" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"details":"p1","name":"b"},"mainRef":"b","body":{"id":"mw-reference-text-cite_note-4"}}'><a href="./Parser_test#cite_note-4"><span class="mw-reflink-text"><span class="cite-bracket">[</span>2.1<span class="cite-bracket">]</span></span></a></sup><sup class="mw-ref reference" id="cite&#95;ref-2-1" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"details":"p1","name":"a"},"mainRef":"a","body":{"id":"mw-reference-text-cite_note-2"}}'><a href="./Parser_test#cite_note-2"><span class="mw-reflink-text"><span class="cite-bracket">[</span>1.1<span class="cite-bracket">]</span></span></a></sup><sup class="mw-ref reference" id="cite&#95;ref-4-1" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"details":"p1","name":"b"},"mainRef":"b","body":{"id":"mw-reference-text-cite_note-4"}}'><a href="./Parser_test#cite_note-4"><span class="mw-reflink-text"><span class="cite-bracket">[</span>2.1<span class="cite-bracket">]</span></span></a></sup></p>
<div class="mw-references-wrap" typeof="mw:Extension/references" data-mw='{"name":"references","attrs":{},"body":{"html":"\n&lt;sup class=\"mw-ref reference\" rel=\"dc:references\" typeof=\"mw:Extension/ref\" data-mw=&apos;{\"name\":\"ref\",\"attrs\":{\"name\":\"a\"},\"body\":{\"id\":\"mw-reference-text-cite_note-a-1\"}}&apos;>&lt;a href=\"./Parser_test#cite_note-a-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>\n&lt;sup class=\"mw-ref reference\" rel=\"dc:references\" typeof=\"mw:Extension/ref\" data-mw=&apos;{\"name\":\"ref\",\"attrs\":{\"name\":\"b\"},\"body\":{\"id\":\"mw-reference-text-cite_note-b-3\"}}&apos;>&lt;a href=\"./Parser_test#cite_note-b-3\">&lt;span class=\"mw-reflink-text\">&lt;span class=\"cite-bracket\">[&lt;/span>2&lt;span class=\"cite-bracket\">]&lt;/span>&lt;/span>&lt;/a>&lt;/sup>\n"}}'>
<ol class="mw-references references">
<li id="cite&#95;note-a-1" data-mw-footnote-number="1"><span rel="mw:referencedBy" class="mw-cite-backlink"></span> <span id="mw-reference-text-cite&#95;note-a-1" class="mw-reference-text reference-text">Book A</span>
<ol class="mw-subreference-list">
<li id="cite&#95;note-2" data-mw-footnote-number="1.1"><span rel="mw:referencedBy" class="mw-cite-backlink"><a href="./Parser_test#cite_ref-2"><span class="mw-linkback-text">1</span></a> <a href="./Parser_test#cite_ref-2-1"><span class="mw-linkback-text">2</span></a></span> <span id="mw-reference-text-cite&#95;note-2" class="mw-reference-text reference-text">p1</span></li>
</ol>
</li>
<li id="cite&#95;note-b-3" data-mw-footnote-number="2"><span rel="mw:referencedBy" class="mw-cite-backlink"></span> <span id="mw-reference-text-cite&#95;note-b-3" class="mw-reference-text reference-text">Book B</span>
<ol class="mw-subreference-list">
<li id="cite&#95;note-4" data-mw-footnote-number="2.1"><span rel="mw:referencedBy" class="mw-cite-backlink"><a href="./Parser_test#cite_ref-4"><span class="mw-linkback-text">1</span></a> <a href="./Parser_test#cite_ref-4-1"><span class="mw-linkback-text">2</span></a></span> <span id="mw-reference-text-cite&#95;note-4" class="mw-reference-text reference-text">p1</span></li>
</ol>
</li>
</ol>
</div>
!! end

# T406467: Parsoid doesn't do any merging yet
!! test
Merging sub-refs should not suppress error message for mismatching dir
!! config
wgCiteSubReferencing=true
!! wikitext
<ref name="a" details="p1" dir="rtl">Book</ref>
<ref name="a" details="p1" dir="ltr" />
<references />
!! html/php
<p><sup id="cite&#95;ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup>
<sup id="cite&#95;ref-2-1" class="reference"><a href="#cite_note-2"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup>
</p>
<div class="mw-references-wrap"><ol class="references">
<li class="mw-cite-dir-rtl"><span class="mw-cite-backlink">↑</span> <span class="reference-text">Book <span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: One of the <code>&lt;ref&gt;</code> tags with the name "a" does have a conflicting dir attribute.</span></span>
<ol class="mw-subreference-list"><li id="cite&#95;note-2" class="mw-cite-dir-rtl"><span class="mw-cite-backlink">↑ <sup><a href="#cite_ref-2">1.0</a></sup> <sup><a href="#cite_ref-2-1">1.1</a></sup></span> <span class="reference-text">p1</span>
</li>
</ol></li>
</ol></div>
!! end

# T406467: Parsoid doesn't do any merging yet
!! test
Merging sub-refs should not suppress error message for misplaced follow
!! config
wgCiteSubReferencing=true
!! wikitext
<ref name="a" details="p1">Book</ref>
<ref name="a" details="p1" follow="b" />
<references />
!! html/php
<p><sup id="cite&#95;ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup>
<span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: A <code>&lt;ref follow="…"&gt;</code> tag that is the continuation of a previous one cannot be named individually or have details.</span>
</p>
<div class="mw-references-wrap"><ol class="references">
<li><span class="mw-cite-backlink">↑</span> <span class="reference-text">Book</span>
<ol class="mw-subreference-list"><li id="cite&#95;note-2"><span class="mw-cite-backlink"><a href="#cite_ref-2">↑</a></span> <span class="reference-text">p1</span>
</li>
</ol></li>
</ol></div>
!! end

# T406467: Parsoid doesn't do any merging yet
!! test
Merging sub-refs should not suppress error message for conflicting main content
!! config
wgCiteSubReferencing=true
!! wikitext
<ref name="a" details="p1">Book</ref>
<ref name="a" details="p1">conflict</ref>
<references />
!! html/php
<p><sup id="cite&#95;ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup>
<sup id="cite&#95;ref-2-1" class="reference"><a href="#cite_note-2"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup>
</p>
<div class="mw-references-wrap"><ol class="references">
<li><span class="mw-cite-backlink">↑</span> <span class="reference-text">Book <span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: Invalid <code>&lt;ref&gt;</code> tag; name "a" defined multiple times with different content</span></span>
<ol class="mw-subreference-list"><li id="cite&#95;note-2"><span class="mw-cite-backlink">↑ <sup><a href="#cite_ref-2">1.0</a></sup> <sup><a href="#cite_ref-2-1">1.1</a></sup></span> <span class="reference-text">p1</span>
</li>
</ol></li>
</ol></div>
!! end

# TODO: Specify desired behavior. Bad round-trip.
!! test
Using `follow` with details on the "main" part
!! config
wgCiteSubReferencing=true
!! options
parsoid=wt2html
!! wikitext
<ref details="page 1" name="book">Book</ref>
<ref follow="book">continued</ref>
!! html/php
<p><sup id="cite&#95;ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup>
</p>
<div class="mw-references-wrap"><ol class="references">
<li><span class="mw-cite-backlink">↑</span> <span class="reference-text">Book continued</span>
<ol class="mw-subreference-list"><li id="cite&#95;note-2"><span class="mw-cite-backlink"><a href="#cite_ref-2">↑</a></span> <span class="reference-text">page 1</span>
</li>
</ol></li>
</ol></div>
!! html/parsoid
<p><sup class="mw-ref reference" id="cite&#95;ref-2" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"details":"page 1","name":"book"},"body":{"id":"mw-reference-text-cite_note-2"},"mainRef":"book","mainBody":"mw-reference-text-cite_note-book-1"}'><a href="./Parser_test#cite_note-2"><span class="mw-reflink-text"><span class="cite-bracket">[</span>1.1<span class="cite-bracket">]</span></span></a></sup> <sup class="mw-ref reference mw-ref-follow" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"follow":"book"},"body":{"id":"mw-reference-text-cite_note-book-1"}}'><a href="./Parser_test#cite_note-book-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,"body":{"html":"\n&lt;sup typeof=\"mw:Extension/ref\" data-mw=&apos;{\"name\":\"ref\",\"attrs\":{\"name\":\"book\",\"group\":\"\"},\"body\":{\"id\":\"mw-reference-text-cite_note-book-1\"},\"isSyntheticMainRef\":1}&apos;>Book&lt;/sup>"}}'>
<ol class="mw-references references">
<li id="cite&#95;note-book-1" data-mw-footnote-number="1"><span rel="mw:referencedBy" class="mw-cite-backlink"></span> <span id="mw-reference-text-cite&#95;note-book-1" class="mw-reference-text reference-text">Book<span typeof="mw:Cite/Follow"> continued</span></span>
<ol class="mw-subreference-list">
<li id="cite&#95;note-2" data-mw-footnote-number="1.1"><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&#95;note-2" class="mw-reference-text reference-text">page 1</span></li>
</ol>
</li>
</ol>
</div>
!! end

# T390974: Bad refs don't round-trip
!! test
Using `follow` with details on the "follow" part
!! config
wgCiteSubReferencing=true
!! wikitext
<ref name="book">Book</ref> <ref details="page 1" follow="book">continued</ref>
<references />
!! html/php
<p><sup id="cite&#95;ref-book&#95;1-0" class="reference"><a href="#cite_note-book-1"><span class="cite-bracket">&#91;</span>1<span class="cite-bracket">&#93;</span></a></sup> <span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: A <code>&lt;ref follow="…"&gt;</code> tag that is the continuation of a previous one cannot be named individually or have details.</span>
</p>
<div class="mw-references-wrap"><ol class="references">
<li id="cite&#95;note-book-1"><span class="mw-cite-backlink"><a href="#cite_ref-book_1-0">↑</a></span> <span class="reference-text">Book</span>
</li>
</ol></div>
!! html/parsoid
<p><sup class="mw-ref reference" id="cite&#95;ref-book&#95;1-0" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"name":"book"},"body":{"id":"mw-reference-text-cite_note-book-1"}}'><a href="./Parser_test#cite_note-book-1"><span class="mw-reflink-text"><span class="cite-bracket">[</span>1<span class="cite-bracket">]</span></span></a></sup> <sup about="#mwt2" class="mw-ref reference mw-ref-follow" rel="dc:references" typeof="mw:Extension/ref mw:Error" data-mw='{"name":"ref","attrs":{"details":"page 1","follow":"book"},"body":{"id":"mw-reference-text-cite_note-book-1"},"errors":[{"key":"cite_error_ref_follow_conflicts"},{"key":"cite_error_ref_with_details_no_name"}]}'><a href="./Parser_test#cite_note-book-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":{}}'>
<ol class="mw-references references">
<li id="cite&#95;note-book-1" data-mw-footnote-number="1"><span class="mw-cite-backlink"><a href="./Parser_test#cite_ref-book_1-0" rel="mw:referencedBy"><span class="mw-linkback-text">↑</span></a></span> <span id="mw-reference-text-cite&#95;note-book-1" class="mw-reference-text reference-text">Book<span typeof="mw:Cite/Follow" about="#mwt2"> continued</span></span></li>
</ol>
</div>
!! end

!! test
Details include basic wikitext syntax
!! config
wgCiteSubReferencing=true
!! wikitext
<ref details="''abc''" name="a">def</ref>
!! html/php
<p><sup id="cite&#95;ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup>
</p>
<div class="mw-references-wrap"><ol class="references">
<li><span class="mw-cite-backlink">↑</span> <span class="reference-text">def</span>
<ol class="mw-subreference-list"><li id="cite&#95;note-2"><span class="mw-cite-backlink"><a href="#cite_ref-2">↑</a></span> <span class="reference-text"><i>abc</i></span>
</li>
</ol></li>
</ol></div>
!! html/parsoid
<p><sup class="mw-ref reference" id="cite&#95;ref-2" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"details":"&apos;&apos;abc&apos;&apos;","name":"a"},"body":{"id":"mw-reference-text-cite_note-2"},"mainRef":"a","mainBody":"mw-reference-text-cite_note-a-1"}'><a href="./Parser_test#cite_note-2"><span class="mw-reflink-text"><span class="cite-bracket">[</span>1.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,"body":{"html":"\n&lt;sup typeof=\"mw:Extension/ref\" data-mw=&apos;{\"name\":\"ref\",\"attrs\":{\"name\":\"a\",\"group\":\"\"},\"body\":{\"id\":\"mw-reference-text-cite_note-a-1\"},\"isSyntheticMainRef\":1}&apos;>def&lt;/sup>"}}'>
<ol class="mw-references references">
<li id="cite&#95;note-a-1" data-mw-footnote-number="1"><span rel="mw:referencedBy" class="mw-cite-backlink"></span> <span id="mw-reference-text-cite&#95;note-a-1" class="mw-reference-text reference-text">def</span>
<ol class="mw-subreference-list">
<li id="cite&#95;note-2" data-mw-footnote-number="1.1"><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&#95;note-2" class="mw-reference-text reference-text"><i>abc</i></span></li>
</ol>
</li>
</ol>
</div>
!! end

!! test
Details include template invocation
!! config
wgCiteSubReferencing=true
!! wikitext
<ref details="{{Deco-z|abc}}" name="a">def</ref>
!! html/php
<p><sup id="cite&#95;ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup>
</p>
<div class="mw-references-wrap"><ol class="references">
<li><span class="mw-cite-backlink">↑</span> <span class="reference-text">def</span>
<ol class="mw-subreference-list"><li id="cite&#95;note-2"><span class="mw-cite-backlink"><a href="#cite_ref-2">↑</a></span> <span class="reference-text">zabczz</span>
</li>
</ol></li>
</ol></div>
!! html/parsoid
<p><sup class="mw-ref reference" id="cite&#95;ref-2" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"details":"{{Deco-z|abc}}","name":"a"},"body":{"id":"mw-reference-text-cite_note-2"},"mainRef":"a","mainBody":"mw-reference-text-cite_note-a-1"}'><a href="./Parser_test#cite_note-2"><span class="mw-reflink-text"><span class="cite-bracket">[</span>1.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,"body":{"html":"\n&lt;sup typeof=\"mw:Extension/ref\" data-mw=&apos;{\"name\":\"ref\",\"attrs\":{\"name\":\"a\",\"group\":\"\"},\"body\":{\"id\":\"mw-reference-text-cite_note-a-1\"},\"isSyntheticMainRef\":1}&apos;>def&lt;/sup>"}}'>
<ol class="mw-references references">
<li id="cite&#95;note-a-1" data-mw-footnote-number="1"><span rel="mw:referencedBy" class="mw-cite-backlink"></span> <span id="mw-reference-text-cite&#95;note-a-1" class="mw-reference-text reference-text">def</span>
<ol class="mw-subreference-list">
<li id="cite&#95;note-2" data-mw-footnote-number="1.1"><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&#95;note-2" class="mw-reference-text reference-text"><span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"Deco-z","href":"./Template:Deco-z"},"params":{"1":{"wt":"abc"}},"i":0}}]}'>zabczz</span></span></li>
</ol>
</li>
</ol>
</div>
!! end

# TODO: Should be blocked with a fatal, identical to how the main content behaves; see T380979
!! test
Details include another, nested ref tag
!! config
wgCiteSubReferencing=true
!! options
parsoid=wt2html
!! wikitext
<ref name=x>x</ref>
<ref details="d<ref name=x&gt;x</ref&gt;" name=a>a</ref>
!! html/php
<p><sup id="cite&#95;ref-x&#95;1-0" class="reference"><a href="#cite_note-x-1"><span class="cite-bracket">&#91;</span>1<span class="cite-bracket">&#93;</span></a></sup>
<sup id="cite&#95;ref-3" class="reference"><a href="#cite_note-3"><span class="cite-bracket">&#91;</span>2.1<span class="cite-bracket">&#93;</span></a></sup>
</p>
<div class="mw-references-wrap"><ol class="references">
<li id="cite&#95;note-x-1"><span class="mw-cite-backlink"><a href="#cite_ref-x_1-0">↑</a></span> <span class="reference-text">x</span>
</li>
<li><span class="mw-cite-backlink">↑</span> <span class="reference-text">a</span>
<ol class="mw-subreference-list"><li id="cite&#95;note-3"><span class="mw-cite-backlink"><a href="#cite_ref-3">↑</a></span> <span class="reference-text">d<sup id="cite&#95;ref-x&#95;4-0" class="reference"><a href="#cite_note-x-4"><span class="cite-bracket">&#91;</span>1<span class="cite-bracket">&#93;</span></a></sup></span>
</li>
</ol></li>
</ol></div>
!! html/parsoid
<p><sup class="mw-ref reference" id="cite&#95;ref-x&#95;1-0" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"name":"x"},"body":{"id":"mw-reference-text-cite_note-x-1"}}'><a href="./Parser_test#cite_note-x-1"><span class="mw-reflink-text"><span class="cite-bracket">[</span>1<span class="cite-bracket">]</span></span></a></sup> <sup class="mw-ref reference" id="cite&#95;ref-3" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"details":"d&lt;ref name=x>x&lt;/ref>","name":"a"},"body":{"id":"mw-reference-text-cite_note-3"},"mainRef":"a","mainBody":"mw-reference-text-cite_note-a-2"}'><a href="./Parser_test#cite_note-3"><span class="mw-reflink-text"><span class="cite-bracket">[</span>2.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,"body":{"html":"\n&lt;sup typeof=\"mw:Extension/ref\" data-mw=&apos;{\"name\":\"ref\",\"attrs\":{\"name\":\"a\",\"group\":\"\"},\"body\":{\"id\":\"mw-reference-text-cite_note-a-2\"},\"isSyntheticMainRef\":1}&apos;>a&lt;/sup>"}}'>
<ol class="mw-references references">
<li id="cite&#95;note-x-1" data-mw-footnote-number="1"><span class="mw-cite-backlink"><a href="./Parser_test#cite_ref-x_1-0" rel="mw:referencedBy"><span class="mw-linkback-text">↑</span></a></span> <span id="mw-reference-text-cite&#95;note-x-1" class="mw-reference-text reference-text">x</span></li>
<li id="cite&#95;note-a-2" data-mw-footnote-number="2"><span rel="mw:referencedBy" class="mw-cite-backlink"></span> <span id="mw-reference-text-cite&#95;note-a-2" class="mw-reference-text reference-text">a</span>
<ol class="mw-subreference-list">
<li id="cite&#95;note-3" data-mw-footnote-number="2.1"><span class="mw-cite-backlink"><a href="./Parser_test#cite_ref-3" rel="mw:referencedBy"><span class="mw-linkback-text">↑</span></a></span> <span id="mw-reference-text-cite&#95;note-3" class="mw-reference-text reference-text">d<sup typeof="mw:DOMFragment/sealed/ref" data-mw='{"name":"ref","attrs":{"name":"x"},"body":{"extsrc":"x"}}'></sup></span></li>
</ol>
</li>
</ol>
</div>
!! end

# TODO: Legacy should block this with cite_error_details_unsupported_context!
# FIXME: Parsoid displays an unresolved strip marker!
!! test
T380979: Nesting another ref inside the details syntax
!! config
wgCiteSubReferencing=true
!! wikitext
{{#tag:ref|Outer ref|name=a|details=Outer details<ref name="b">Inner ref</ref>}}
!! html
<p><sup id="cite&#95;ref-3" class="reference"><a href="#cite_note-3"><span class="cite-bracket">&#91;</span>2.1<span class="cite-bracket">&#93;</span></a></sup>
</p>
<div class="mw-references-wrap"><ol class="references">
<li id="cite&#95;note-b-1"><span class="mw-cite-backlink"><a href="#cite_ref-b_1-0">↑</a></span> <span class="reference-text">Inner ref</span>
</li>
<li><span class="mw-cite-backlink">↑</span> <span class="reference-text">Outer ref</span>
<ol class="mw-subreference-list"><li id="cite&#95;note-3"><span class="mw-cite-backlink"><a href="#cite_ref-3">↑</a></span> <span class="reference-text">Outer details<sup id="cite&#95;ref-b&#95;1-0" class="reference"><a href="#cite_note-b-1"><span class="cite-bracket">&#91;</span>1<span class="cite-bracket">&#93;</span></a></sup></span>
</li>
</ol></li>
</ol></div>
!! html/parsoid
<p><sup class="mw-ref reference" id="cite_ref-2" rel="dc:references" typeof="mw:Transclusion mw:Extension/ref" data-mw='{"name":"ref","attrs":{"name":"a","details":"Outer details&apos;\"`UNIQ--ref-00000000-QINU`\"&apos;"},"body":{"id":"mw-reference-text-cite_note-2"},"parts":[{"template":{"target":{"wt":"#tag:ref","function":"tag"},"params":{"1":{"wt":"Outer ref"},"2":{"wt":"name=a"},"3":{"wt":"details=Outer details&lt;ref name=\"b\">Inner ref&lt;/ref>"}},"i":0}}],"mainRef":"a","mainBody":"mw-reference-text-cite_note-a-1"}'><a href="./Parser_test#cite_note-2"><span class="mw-reflink-text"><span class="cite-bracket">[</span>1.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,"body":{"html":"\n&lt;sup typeof=\"mw:Extension/ref\" data-mw=&apos;{\"name\":\"ref\",\"attrs\":{\"name\":\"a\",\"group\":\"\"},\"body\":{\"id\":\"mw-reference-text-cite_note-a-1\"},\"isSyntheticMainRef\":1}&apos;>Outer ref&lt;/sup>"}}'>
<ol class="mw-references references">
<li id="cite_note-a-1" data-mw-footnote-number="1"><span rel="mw:referencedBy" class="mw-cite-backlink"></span> <span id="mw-reference-text-cite_note-a-1" class="mw-reference-text reference-text">Outer ref</span>
<ol class="mw-subreference-list">
<li id="cite_note-2" data-mw-footnote-number="1.1"><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">Outer details'"`UNIQ--ref-00000000-QINU`"'</span></li>
</ol>
</li>
</ol>
</div>
!! end

# TODO: Legacy should block this with cite_error_details_unsupported_context!
# FIXME: Parsoid displays an unresolved strip marker!
!! test
T380979: Nesting another sub-ref inside the details syntax
!! config
wgCiteSubReferencing=true
!! wikitext
{{#tag:ref|Outer ref|name=a|details=Outer details<ref name="a" details="Inner details"/>}}
!! html
<p><sup id="cite&#95;ref-3" class="reference"><a href="#cite_note-3"><span class="cite-bracket">&#91;</span>1.2<span class="cite-bracket">&#93;</span></a></sup>
</p>
<div class="mw-references-wrap"><ol class="references">
<li><span class="mw-cite-backlink">↑</span> <span class="reference-text">Outer ref</span>
<ol class="mw-subreference-list"><li id="cite&#95;note-2"><span class="mw-cite-backlink"><a href="#cite_ref-2">↑</a></span> <span class="reference-text">Inner details</span>
</li>
<li id="cite&#95;note-3"><span class="mw-cite-backlink"><a href="#cite_ref-3">↑</a></span> <span class="reference-text">Outer details<sup id="cite&#95;ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup></span>
</li>
</ol></li>
</ol></div>
!! html/parsoid
<p><sup class="mw-ref reference" id="cite_ref-2" rel="dc:references" typeof="mw:Transclusion mw:Extension/ref" data-mw='{"name":"ref","attrs":{"name":"a","details":"Outer details&apos;\"`UNIQ--ref-00000000-QINU`\"&apos;"},"body":{"id":"mw-reference-text-cite_note-2"},"parts":[{"template":{"target":{"wt":"#tag:ref","function":"tag"},"params":{"1":{"wt":"Outer ref"},"2":{"wt":"name=a"},"3":{"wt":"details=Outer details&lt;ref name=\"a\" details=\"Inner details\"/>"}},"i":0}}],"mainRef":"a","mainBody":"mw-reference-text-cite_note-a-1"}'><a href="./Parser_test#cite_note-2"><span class="mw-reflink-text"><span class="cite-bracket">[</span>1.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,"body":{"html":"\n&lt;sup typeof=\"mw:Extension/ref\" data-mw=&apos;{\"name\":\"ref\",\"attrs\":{\"name\":\"a\",\"group\":\"\"},\"body\":{\"id\":\"mw-reference-text-cite_note-a-1\"},\"isSyntheticMainRef\":1}&apos;>Outer ref&lt;/sup>"}}'>
<ol class="mw-references references">
<li id="cite_note-a-1" data-mw-footnote-number="1"><span rel="mw:referencedBy" class="mw-cite-backlink"></span> <span id="mw-reference-text-cite_note-a-1" class="mw-reference-text reference-text">Outer ref</span>
<ol class="mw-subreference-list">
<li id="cite_note-2" data-mw-footnote-number="1.1"><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">Outer details'"`UNIQ--ref-00000000-QINU`"'</span></li>
</ol>
</li>
</ol>
</div>
!! end

!! test
Subreference doesn't affect main reference numbering
!! config
wgCiteSubReferencing=true
!! wikitext
<ref>abc</ref> <ref details="def" name="a">ghi</ref> <ref>jkl</ref>
!! html/php
<p><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> <sup id="cite&#95;ref-3" class="reference"><a href="#cite_note-3"><span class="cite-bracket">&#91;</span>2.1<span class="cite-bracket">&#93;</span></a></sup> <sup id="cite&#95;ref-4" class="reference"><a href="#cite_note-4"><span class="cite-bracket">&#91;</span>3<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">abc</span>
</li>
<li><span class="mw-cite-backlink">↑</span> <span class="reference-text">ghi</span>
<ol class="mw-subreference-list"><li id="cite&#95;note-3"><span class="mw-cite-backlink"><a href="#cite_ref-3">↑</a></span> <span class="reference-text">def</span>
</li>
</ol></li>
<li id="cite&#95;note-4"><span class="mw-cite-backlink"><a href="#cite_ref-4">↑</a></span> <span class="reference-text">jkl</span>
</li>
</ol></div>
!! html/parsoid
<p><sup class="mw-ref reference" id="cite&#95;ref-1" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{},"body":{"id":"mw-reference-text-cite_note-1"}}'><a href="./Parser_test#cite_note-1"><span class="mw-reflink-text"><span class="cite-bracket">[</span>1<span class="cite-bracket">]</span></span></a></sup> <sup class="mw-ref reference" id="cite&#95;ref-3" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"details":"def","name":"a"},"body":{"id":"mw-reference-text-cite_note-3"},"mainRef":"a","mainBody":"mw-reference-text-cite_note-a-2"}'><a href="./Parser_test#cite_note-3"><span class="mw-reflink-text"><span class="cite-bracket">[</span>2.1<span class="cite-bracket">]</span></span></a></sup> <sup class="mw-ref reference" id="cite&#95;ref-4" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{},"body":{"id":"mw-reference-text-cite_note-4"}}'><a href="./Parser_test#cite_note-4"><span class="mw-reflink-text"><span class="cite-bracket">[</span>3<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,"body":{"html":"\n&lt;sup typeof=\"mw:Extension/ref\" data-mw=&apos;{\"name\":\"ref\",\"attrs\":{\"name\":\"a\",\"group\":\"\"},\"body\":{\"id\":\"mw-reference-text-cite_note-a-2\"},\"isSyntheticMainRef\":1}&apos;>ghi&lt;/sup>"}}'>
<ol class="mw-references references">
<li id="cite&#95;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&#95;note-1" class="mw-reference-text reference-text">abc</span></li>
<li id="cite&#95;note-a-2" data-mw-footnote-number="2"><span rel="mw:referencedBy" class="mw-cite-backlink"></span> <span id="mw-reference-text-cite&#95;note-a-2" class="mw-reference-text reference-text">ghi</span>
<ol class="mw-subreference-list">
<li id="cite&#95;note-3" data-mw-footnote-number="2.1"><span class="mw-cite-backlink"><a href="./Parser_test#cite_ref-3" rel="mw:referencedBy"><span class="mw-linkback-text">↑</span></a></span> <span id="mw-reference-text-cite&#95;note-3" class="mw-reference-text reference-text">def</span></li>
</ol>
</li>
<li id="cite&#95;note-4" data-mw-footnote-number="3"><span class="mw-cite-backlink"><a href="./Parser_test#cite_ref-4" rel="mw:referencedBy"><span class="mw-linkback-text">↑</span></a></span> <span id="mw-reference-text-cite&#95;note-4" class="mw-reference-text reference-text">jkl</span></li>
</ol>
</div>
!! end

# T390961: fails to round-trip main+details after main
!! test
Subreference of existing ref doesn't affect main reference numbering
!! config
wgCiteSubReferencing=true
!! options
parsoid=wt2html
!! wikitext
<ref name="a">abc</ref> <ref details="def" name="a">abc</ref> <ref>jkl</ref>
!! html/php
<p><sup id="cite&#95;ref-a&#95;1-0" class="reference"><a href="#cite_note-a-1"><span class="cite-bracket">&#91;</span>1<span class="cite-bracket">&#93;</span></a></sup> <sup id="cite&#95;ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup> <sup id="cite&#95;ref-3" class="reference"><a href="#cite_note-3"><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-a-1"><span class="mw-cite-backlink"><a href="#cite_ref-a_1-0">↑</a></span> <span class="reference-text">abc</span>
<ol class="mw-subreference-list"><li id="cite&#95;note-2"><span class="mw-cite-backlink"><a href="#cite_ref-2">↑</a></span> <span class="reference-text">def</span>
</li>
</ol></li>
<li id="cite&#95;note-3"><span class="mw-cite-backlink"><a href="#cite_ref-3">↑</a></span> <span class="reference-text">jkl</span>
</li>
</ol></div>
!! html/parsoid
<p><sup class="mw-ref reference" id="cite&#95;ref-a&#95;1-0" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"name":"a"},"body":{"id":"mw-reference-text-cite_note-a-1"}}'><a href="./Parser_test#cite_note-a-1"><span class="mw-reflink-text"><span class="cite-bracket">[</span>1<span class="cite-bracket">]</span></span></a></sup> <sup class="mw-ref reference" id="cite&#95;ref-2" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"details":"def","name":"a"},"body":{"id":"mw-reference-text-cite_note-2"},"mainRef":"a","mainBody":"mw-reference-text-cite_note-a-1"}'><a href="./Parser_test#cite_note-2"><span class="mw-reflink-text"><span class="cite-bracket">[</span>1.1<span class="cite-bracket">]</span></span></a></sup> <sup class="mw-ref reference" id="cite&#95;ref-3" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{},"body":{"id":"mw-reference-text-cite_note-3"}}'><a href="./Parser_test#cite_note-3"><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,"body":{"html":"\n&lt;sup typeof=\"mw:Extension/ref\" data-mw=&apos;{\"name\":\"ref\",\"attrs\":{\"name\":\"a\",\"group\":\"\"},\"body\":{\"id\":\"mw-reference-text-cite_note-a-1\"},\"isSyntheticMainRef\":1}&apos;>abc&lt;/sup>"}}'>
<ol class="mw-references references">
<li id="cite&#95;note-a-1" data-mw-footnote-number="1"><span class="mw-cite-backlink"><a href="./Parser_test#cite_ref-a_1-0" rel="mw:referencedBy"><span class="mw-linkback-text">↑</span></a></span> <span id="mw-reference-text-cite&#95;note-a-1" class="mw-reference-text reference-text">abc</span>
<ol class="mw-subreference-list">
<li id="cite&#95;note-2" data-mw-footnote-number="1.1"><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&#95;note-2" class="mw-reference-text reference-text">def</span></li>
</ol>
</li>
<li id="cite&#95;note-3" data-mw-footnote-number="2"><span class="mw-cite-backlink"><a href="./Parser_test#cite_ref-3" rel="mw:referencedBy"><span class="mw-linkback-text">↑</span></a></span> <span id="mw-reference-text-cite&#95;note-3" class="mw-reference-text reference-text">jkl</span></li>
</ol>
</div>
!! end

!! test
Rolling back a sub-reference inside the #tag:references function
!! config
wgCiteSubReferencing=true
!! wikitext
<ref name="a" />
{{#tag:references|<ref name="a">a</ref><ref details="p1" name="b">b</ref>}}
!! html/php
<p><sup id="cite&#95;ref-a&#95;1-0" class="reference"><a href="#cite_note-a-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-a-1"><span class="mw-cite-backlink"><a href="#cite_ref-a_1-0">↑</a></span> <span class="reference-text">a</span>
</li>
</ol></div>
<p><span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: <code>&lt;ref&gt;</code> tag with name "b" cannot use details when inside <code>&lt;references&gt;</code>.</span>
</p>
!! html/parsoid
<p><sup class="mw-ref reference" id="cite&#95;ref-a&#95;1-0" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"name":"a"}}'><a href="./Parser_test#cite_note-a-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 mw:Transclusion" data-mw='{"name":"references","attrs":{},"body":{"extsrc":"&lt;ref name=\"a\">a&lt;/ref>&lt;ref details=\"p1\" name=\"b\">b&lt;/ref>"},"parts":[{"template":{"target":{"wt":"#tag:references","function":"tag"},"params":{"1":{"wt":"&lt;ref name=\"a\">a&lt;/ref>&lt;ref details=\"p1\" name=\"b\">b&lt;/ref>"}},"i":0}}]}'>
<ol class="mw-references references">
<li id="cite&#95;note-a-1" data-mw-footnote-number="1"><span class="mw-cite-backlink"><a href="./Parser_test#cite_ref-a_1-0" rel="mw:referencedBy"><span class="mw-linkback-text">↑</span></a></span> <span id="mw-reference-text-cite&#95;note-a-1" class="mw-reference-text reference-text">a</span></li>
<li id="cite&#95;note-b-2" data-mw-footnote-number="2"><span rel="mw:referencedBy" class="mw-cite-backlink"></span> <span id="mw-reference-text-cite&#95;note-b-2" class="mw-reference-text reference-text">b</span></li>
</ol>
<span class="error mw-ext-cite-error" data-mw-i18n='{"/":{"lang":"x-user","key":"cite_error","params":[{"text":{"key":"cite_error_details_unsupported_context","params":["b"]}}]}}' typeof="mw:I18n"></span><br/>
<span class="error mw-ext-cite-error" data-mw-i18n='{"/":{"lang":"x-user","key":"cite_error","params":[{"text":{"key":"cite_error_references_missing_key","params":["b"]}}]}}' typeof="mw:I18n"></span>
</div>
!! end

!! test
Named main ref with inline details and <references> called with #tag
!! config
wgCiteSubReferencing=true
!! wikitext
<ref details="p. 1" name="book">The book</ref> <ref>Another book</ref>
{{#tag:references}}
!! html
<p><sup id="cite&#95;ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup> <sup id="cite&#95;ref-3" class="reference"><a href="#cite_note-3"><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><span class="mw-cite-backlink">↑</span> <span class="reference-text">The book</span>
<ol class="mw-subreference-list"><li id="cite&#95;note-2"><span class="mw-cite-backlink"><a href="#cite_ref-2">↑</a></span> <span class="reference-text">p. 1</span>
</li>
</ol></li>
<li id="cite&#95;note-3"><span class="mw-cite-backlink"><a href="#cite_ref-3">↑</a></span> <span class="reference-text">Another book</span>
</li>
</ol></div>
!! html/parsoid
<p><sup class="mw-ref reference" id="cite&#95;ref-2" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"details":"p. 1","name":"book"},"body":{"id":"mw-reference-text-cite_note-2"},"mainRef":"book","mainBody":"mw-reference-text-cite_note-book-1"}'><a href="./Parser_test#cite_note-2"><span class="mw-reflink-text"><span class="cite-bracket">[</span>1.1<span class="cite-bracket">]</span></span></a></sup> <sup class="mw-ref reference" id="cite&#95;ref-3" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{},"body":{"id":"mw-reference-text-cite_note-3"}}'><a href="./Parser_test#cite_note-3"><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 mw:Transclusion" data-mw='{"name":"references","attrs":{},"parts":[{"template":{"target":{"wt":"#tag:references","function":"tag"},"params":{},"i":0}}],"body":{"html":"\n&lt;sup typeof=\"mw:Extension/ref\" data-mw=&apos;{\"name\":\"ref\",\"attrs\":{\"name\":\"book\",\"group\":\"\"},\"body\":{\"id\":\"mw-reference-text-cite_note-book-1\"},\"isSyntheticMainRef\":1}&apos;>The book&lt;/sup>"}}'>
<ol class="mw-references references">
<li id="cite&#95;note-book-1" data-mw-footnote-number="1"><span rel="mw:referencedBy" class="mw-cite-backlink"></span> <span id="mw-reference-text-cite&#95;note-book-1" class="mw-reference-text reference-text">The book</span>
<ol class="mw-subreference-list">
<li id="cite&#95;note-2" data-mw-footnote-number="1.1"><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&#95;note-2" class="mw-reference-text reference-text">p. 1</span></li>
</ol>
</li>
<li id="cite&#95;note-3" data-mw-footnote-number="2"><span class="mw-cite-backlink"><a href="./Parser_test#cite_ref-3" rel="mw:referencedBy"><span class="mw-linkback-text">↑</span></a></span> <span id="mw-reference-text-cite&#95;note-3" class="mw-reference-text reference-text">Another book</span></li>
</ol>
</div>
!! end

# T389929 We don't want Parsoid to convert a synthetic list defined refs into ref tags
!! test
Synthetic main refs from VE dont convert to list defined refs
!! config
wgCiteSubReferencing=true
!! options
parsoid=html2wt
!! wikitext
<ref details="page 1" name="miller">Miller</ref>
<ref name="smith" />

<references>
<ref name="smith">Smith</ref>
</references>
!! html/parsoid
<p id="mwAg"><sup typeof="mw:Extension/ref" data-mw="{&quot;name&quot;:&quot;ref&quot;,&quot;attrs&quot;:{&quot;details&quot;:&quot;page 1&quot;,&quot;name&quot;:&quot;miller&quot;},&quot;body&quot;:{&quot;id&quot;:&quot;mw-reference-text-cite_note-2&quot;},&quot;mainBody&quot;:&quot;mw-reference-text-cite_note-miller-1&quot;,&quot;mainRef&quot;:&quot;miller&quot;}" class="mw-ref reference" about="#mwt1" id="cite&#95;ref-2" rel="dc:references"><a href="./Example/Test11#cite_note-2" id="mwAw"><span class="mw-reflink-text" id="mwBA"><span class="cite-bracket" id="mwBQ">[</span>1.1<span class="cite-bracket" id="mwBg">]</span></span></a></sup>
<sup about="#mwt2" class="mw-ref reference" id="cite&#95;ref-smith&#95;3-0" rel="dc:references" typeof="mw:Extension/ref" data-mw="{&quot;name&quot;:&quot;ref&quot;,&quot;attrs&quot;:{&quot;name&quot;:&quot;smith&quot;}}"><a href="./Example/Test11#cite_note-smith-3" id="mwBw"><span class="mw-reflink-text" id="mwCA"><span class="cite-bracket" id="mwCQ">[</span>2<span class="cite-bracket" id="mwCg">]</span></span></a></sup></p>

<div typeof="mw:Extension/references" data-mw="{&quot;name&quot;:&quot;references&quot;,&quot;attrs&quot;:{},&quot;body&quot;:{&quot;html&quot;:&quot;\n&lt;sup typeof=\&quot;mw:Extension/ref\&quot; data-mw=\&quot;{&amp;quot;name&amp;quot;:&amp;quot;ref&amp;quot;,&amp;quot;attrs&amp;quot;:{&amp;quot;name&amp;quot;:&amp;quot;smith&amp;quot;},&amp;quot;body&amp;quot;:{&amp;quot;id&amp;quot;:&amp;quot;mw-reference-text-cite_note-smith-3&amp;quot;,&amp;quot;html&amp;quot;:&amp;quot;Smith&amp;quot;}}\&quot; class=\&quot;mw-ref reference\&quot; about=\&quot;#mwt3\&quot; rel=\&quot;dc:references\&quot;&gt;&lt;a href=\&quot;./Example/Test11#cite_note-smith-3\&quot;&gt;&lt;span class=\&quot;mw-reflink-text\&quot;&gt;&lt;span class=\&quot;cite-bracket\&quot;&gt;[&lt;/span&gt;2&lt;span class=\&quot;cite-bracket\&quot;&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/sup&gt;\n&lt;sup typeof=\&quot;mw:Extension/ref\&quot; data-mw=\&quot;{&amp;quot;name&amp;quot;:&amp;quot;ref&amp;quot;,&amp;quot;attrs&amp;quot;:{&amp;quot;name&amp;quot;:&amp;quot;miller&amp;quot;},&amp;quot;body&amp;quot;:{&amp;quot;id&amp;quot;:&amp;quot;mw-reference-text-cite_note-miller-1&amp;quot;,&amp;quot;html&amp;quot;:&amp;quot;Miller&amp;quot;},&amp;quot;isSyntheticMainRef&amp;quot;:1}\&quot; class=\&quot;mw-ref reference\&quot;&gt;&lt;a&gt;&lt;span class=\&quot;mw-reflink-text\&quot;&gt;&lt;span class=\&quot;cite-bracket\&quot;&gt;[&lt;/span&gt;1&lt;span class=\&quot;cite-bracket\&quot;&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/sup&gt;&quot;}}"><ol><li><span typeof="mw:Extension/ref" id="mw-reference-text-cite&#95;note-miller-1">Miller</span><ol><li><span typeof="mw:Extension/ref" id="mw-reference-text-cite&#95;note-2">page 1</span></li></ol></li><li><span typeof="mw:Extension/ref">Smith</span></li></ol></div>
!! end

!! test
T406002: Selser detects edits to the main part of a main+details
!! config
wgCiteSubReferencing=true
!! options
parsoid={
  "modes": ["selser"],
  "changes": [["#x", "remove"]],
  "selser": "noauto"
}
!! wikitext
<ref name="main" details="page 1"><span id="x">Original</span>body</ref>
!! wikitext/edited
<ref name="main" details="page 1">body</ref>
!! html/parsoid
!! end
