2006-06-01 05:58:52 +00:00
# Force the test runner to ensure the extension is loaded
!! hooks
ref
references
!! endhooks
!! test
Simple <ref>, no <references/>
!! input
Wikipedia rocks!<ref>Proceeds of Rockology, vol. XXI</ref>
!! result
2014-06-23 21:42:17 +00:00
Wikipedia rocks!<sup id="cite_ref-1" class="reference"><a href="#cite_note-1">[1]</a></sup><ol class="references">
<li id="cite_note-1"><span class="mw-cite-backlink"><a href="#cite_ref-1">↑</a></span> <span class="reference-text">Proceeds of Rockology, vol. XXI</span>
</li>
</ol>
2006-06-01 05:58:52 +00:00
!! end
!! test
Simple <ref>, with <references/>
!! input
Wikipedia rocks!<ref>Proceeds of Rockology, vol. XXI</ref>
<references/>
!! result
2012-10-17 22:58:55 +00:00
<p>Wikipedia rocks!<sup id="cite_ref-1" class="reference"><a href="#cite_note-1">[1]</a></sup>
2006-06-01 05:58:52 +00:00
</p>
2012-10-30 16:22:47 +00:00
<ol class="references">
<li id="cite_note-1"><span class="mw-cite-backlink"><a href="#cite_ref-1">↑</a></span> <span class="reference-text">Proceeds of Rockology, vol. XXI</span>
</li>
</ol>
2006-06-01 05:58:52 +00:00
!! end
!! article
Template:Simple template
!! text
A ''simple'' template.
!! endarticle
!! test
<ref> with a simple template
!! input
Templating<ref>{{simple template}}</ref>
<references/>
!! result
2012-10-17 22:58:55 +00:00
<p>Templating<sup id="cite_ref-1" class="reference"><a href="#cite_note-1">[1]</a></sup>
2006-06-01 05:58:52 +00:00
</p>
2012-10-30 16:22:47 +00:00
<ol class="references">
<li id="cite_note-1"><span class="mw-cite-backlink"><a href="#cite_ref-1">↑</a></span> <span class="reference-text">A <i>simple</i> template.</span>
</li>
</ol>
2006-06-01 05:58:52 +00:00
!! end
!! test
<ref> with a <nowiki>
!! input
Templating<ref><nowiki>{{simple template}}</nowiki></ref>
<references/>
!! result
2012-10-17 22:58:55 +00:00
<p>Templating<sup id="cite_ref-1" class="reference"><a href="#cite_note-1">[1]</a></sup>
2006-06-01 05:58:52 +00:00
</p>
2012-10-30 16:22:47 +00:00
<ol class="references">
<li id="cite_note-1"><span class="mw-cite-backlink"><a href="#cite_ref-1">↑</a></span> <span class="reference-text">{{simple template}}</span>
</li>
</ol>
2006-06-01 05:58:52 +00:00
!! end
!! test
<ref> in a <nowiki>
!! input
Templating<nowiki><ref>{{simple template}}</ref></nowiki>
<references/>
!! result
<p>Templating<ref>{{simple template}}</ref>
2007-05-09 14:48:05 +00:00
</p><p><br />
2006-06-01 05:58:52 +00:00
</p>
!! end
!! test
<ref> in a <!--comment-->
!! input
Templating<!--<ref>{{simple template}}</ref>-->
<references/>
!! result
<p>Templating
2007-05-09 14:48:05 +00:00
</p><p><br />
2006-06-01 05:58:52 +00:00
</p>
!! end
!! test
<!--comment--> in a <ref> (bug 5384)
!! input
Templating<ref>Text<!--comment--></ref>
<references/>
!! result
2012-10-17 22:58:55 +00:00
<p>Templating<sup id="cite_ref-1" class="reference"><a href="#cite_note-1">[1]</a></sup>
2006-06-01 05:58:52 +00:00
</p>
2012-10-30 16:22:47 +00:00
<ol class="references">
<li id="cite_note-1"><span class="mw-cite-backlink"><a href="#cite_ref-1">↑</a></span> <span class="reference-text">Text</span>
</li>
</ol>
2006-06-01 05:58:52 +00:00
!! end
2006-06-01 21:11:29 +00:00
!! test
<references> after <gallery> (bug 6164)
!! input
<ref>one</ref>
<gallery>Image:Foobar.jpg</gallery>
<references/>
!! result
2012-10-17 22:58:55 +00:00
<p><sup id="cite_ref-1" class="reference"><a href="#cite_note-1">[1]</a></sup>
2006-06-01 21:11:29 +00:00
</p>
2013-08-17 10:22:45 +00:00
<ul class="gallery mw-gallery-traditional">
2010-11-29 00:11:19 +00:00
<li class="gallerybox" style="width: 155px"><div style="width: 155px">
2015-02-26 17:58:23 +00:00
<div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div>
2007-02-04 03:12:57 +00:00
<div class="gallerytext">
</div>
2010-11-29 00:11:19 +00:00
</div></li>
</ul>
2012-10-30 16:22:47 +00:00
<ol class="references">
<li id="cite_note-1"><span class="mw-cite-backlink"><a href="#cite_ref-1">↑</a></span> <span class="reference-text">one</span>
</li>
</ol>
2006-06-01 21:11:29 +00:00
!! end
2006-07-10 17:59:37 +00:00
!! test
{{REVISIONID}} on page with <ref> (bug 6299)
!! input
{{REVISIONID}}<ref>elite</ref>
!! result
2014-06-23 21:42:17 +00:00
1337<sup id="cite_ref-1" class="reference"><a href="#cite_note-1">[1]</a></sup><ol class="references">
<li id="cite_note-1"><span class="mw-cite-backlink"><a href="#cite_ref-1">↑</a></span> <span class="reference-text">elite</span>
</li>
</ol>
2006-07-10 17:59:37 +00:00
!! end
!! test
{{REVISIONID}} on page without <ref> (bug 6299 sanity check)
!! input
{{REVISIONID}}
!! result
<p>1337
</p>
!! end
2006-11-03 15:34:46 +00:00
2015-09-30 13:38:42 +00:00
!! test
Ref with content followed by blank ref
!! input
<ref name="blank">content</ref>
<ref name="blank"/>
<references/>
!! result
<p><sup id="cite_ref-blank_1-0" class="reference"><a href="#cite_note-blank-1">[1]</a></sup>
</p><p><sup id="cite_ref-blank_1-1" class="reference"><a href="#cite_note-blank-1">[1]</a></sup>
</p>
<ol class="references">
<li id="cite_note-blank-1"><span class="mw-cite-backlink">↑ <sup><a href="#cite_ref-blank_1-0">1.0</a></sup> <sup><a href="#cite_ref-blank_1-1">1.1</a></sup></span> <span class="reference-text">content</span>
</li>
</ol>
!! end
2006-11-03 15:34:46 +00:00
!! test
Blank ref followed by ref with content
!! input
<ref name="blank"/>
<ref name="blank">content</ref>
<references/>
!! result
2012-10-17 22:58:55 +00:00
<p><sup id="cite_ref-blank_1-0" class="reference"><a href="#cite_note-blank-1">[1]</a></sup>
</p><p><sup id="cite_ref-blank_1-1" class="reference"><a href="#cite_note-blank-1">[1]</a></sup>
2006-11-03 15:34:46 +00:00
</p>
2012-10-30 16:22:47 +00:00
<ol class="references">
<li id="cite_note-blank-1"><span class="mw-cite-backlink">↑ <sup><a href="#cite_ref-blank_1-0">1.0</a></sup> <sup><a href="#cite_ref-blank_1-1">1.1</a></sup></span> <span class="reference-text">content</span>
</li>
</ol>
2006-11-03 15:34:46 +00:00
!! end
!! test
Regression: non-blank ref "0" followed by ref with content
!! input
<ref name="blank">0</ref>
<ref name="blank">content</ref>
<references/>
!! result
2012-10-17 22:58:55 +00:00
<p><sup id="cite_ref-blank_1-0" class="reference"><a href="#cite_note-blank-1">[1]</a></sup>
</p><p><sup id="cite_ref-blank_1-1" class="reference"><a href="#cite_note-blank-1">[1]</a></sup>
2006-11-03 15:34:46 +00:00
</p>
2012-10-30 16:22:47 +00:00
<ol class="references">
2015-10-07 15:32:28 +00:00
<li id="cite_note-blank-1"><span class="mw-cite-backlink">↑ <sup><a href="#cite_ref-blank_1-0">1.0</a></sup> <sup><a href="#cite_ref-blank_1-1">1.1</a></sup></span> <span class="reference-text">0 <strong class="error mw-ext-cite-error">Cite error: Invalid <code><ref></code> tag; name "blank" defined multiple times with different content</strong></span>
2012-10-30 16:22:47 +00:00
</li>
</ol>
2015-10-07 15:32:28 +00:00
2006-11-03 15:34:46 +00:00
!! end
!! test
Regression sanity check: non-blank ref "1" followed by ref with content
!! input
<ref name="blank">1</ref>
<ref name="blank">content</ref>
<references/>
!! result
2012-10-17 22:58:55 +00:00
<p><sup id="cite_ref-blank_1-0" class="reference"><a href="#cite_note-blank-1">[1]</a></sup>
</p><p><sup id="cite_ref-blank_1-1" class="reference"><a href="#cite_note-blank-1">[1]</a></sup>
2006-11-03 15:34:46 +00:00
</p>
2012-10-30 16:22:47 +00:00
<ol class="references">
2015-10-07 15:32:28 +00:00
<li id="cite_note-blank-1"><span class="mw-cite-backlink">↑ <sup><a href="#cite_ref-blank_1-0">1.0</a></sup> <sup><a href="#cite_ref-blank_1-1">1.1</a></sup></span> <span class="reference-text">1 <strong class="error mw-ext-cite-error">Cite error: Invalid <code><ref></code> tag; name "blank" defined multiple times with different content</strong></span>
2012-10-30 16:22:47 +00:00
</li>
</ol>
2015-10-07 15:32:28 +00:00
2006-11-03 15:34:46 +00:00
!! end
2007-12-16 18:49:10 +00:00
2007-12-27 22:25:15 +00:00
!! test
Ref names containing a number
!! input
<ref name="test123test">One</ref>
<ref name="123test">Two</ref>
<ref name="test123">Three</ref>
<references />
!! result
2012-10-17 22:58:55 +00:00
<p><sup id="cite_ref-test123test_1-0" class="reference"><a href="#cite_note-test123test-1">[1]</a></sup>
<sup id="cite_ref-123test_2-0" class="reference"><a href="#cite_note-123test-2">[2]</a></sup>
<sup id="cite_ref-test123_3-0" class="reference"><a href="#cite_note-test123-3">[3]</a></sup>
2007-12-27 22:25:15 +00:00
</p>
2012-10-30 16:22:47 +00:00
<ol class="references">
<li id="cite_note-test123test-1"><span class="mw-cite-backlink"><a href="#cite_ref-test123test_1-0">↑</a></span> <span class="reference-text">One</span>
2011-11-14 12:20:24 +00:00
</li>
2012-10-17 22:58:55 +00:00
<li id="cite_note-123test-2"><span class="mw-cite-backlink"><a href="#cite_ref-123test_2-0">↑</a></span> <span class="reference-text">Two</span>
2011-11-14 12:20:24 +00:00
</li>
2012-10-17 22:58:55 +00:00
<li id="cite_note-test123-3"><span class="mw-cite-backlink"><a href="#cite_ref-test123_3-0">↑</a></span> <span class="reference-text">Three</span>
2012-10-30 16:22:47 +00:00
</li>
</ol>
2007-12-27 22:25:15 +00:00
!! end
2007-12-16 18:49:10 +00:00
!! test
Erroneous refs
!! input
<ref name="0">Zero</ref>
<ref>Also zero, but differently! (Normal ref)</ref>
<ref />
<ref name="foo" name="bar" />
<ref name="blankwithnoreference" />
<references name="quasit" />
<references />
!! result
2013-07-10 21:48:31 +00:00
<p><strong class="error mw-ext-cite-error">Cite error: Invalid <code><ref></code> tag;
2008-04-18 22:48:57 +00:00
name cannot be a simple integer. Use a descriptive title</strong>
2012-10-17 22:58:55 +00:00
</p><p><sup id="cite_ref-1" class="reference"><a href="#cite_note-1">[1]</a></sup>
2013-07-10 21:48:31 +00:00
</p><p><strong class="error mw-ext-cite-error">Cite error: Invalid <code><ref></code> tag;
2008-04-18 22:48:57 +00:00
refs with no content must have a name</strong>
2012-10-17 22:58:55 +00:00
</p><p><sup id="cite_ref-bar_2-0" class="reference"><a href="#cite_note-bar-2">[2]</a></sup>
</p><p><sup id="cite_ref-blankwithnoreference_3-0" class="reference"><a href="#cite_note-blankwithnoreference-3">[3]</a></sup>
2013-07-10 21:48:31 +00:00
</p><p><strong class="error mw-ext-cite-error">Cite error: Invalid <code><references></code> tag;
2009-01-26 18:02:28 +00:00
parameter "group" is allowed only.
2009-06-05 16:04:19 +00:00
Use <code><references /></code>, or <code><references group="..." /></code></strong>
2007-12-16 18:49:10 +00:00
</p>
2012-10-30 16:22:47 +00:00
<ol class="references">
<li id="cite_note-1"><span class="mw-cite-backlink"><a href="#cite_ref-1">↑</a></span> <span class="reference-text">Also zero, but differently! (Normal ref)</span>
2011-11-14 12:20:24 +00:00
</li>
2013-07-10 21:48:31 +00:00
<li id="cite_note-bar"><span class="mw-cite-backlink"><a href="#cite_ref-bar_0">↑</a></span> <strong class="error mw-ext-cite-error">Cite error: Invalid <code><ref></code> tag;
2008-04-18 22:48:57 +00:00
no text was provided for refs named <code>bar</code></strong></li>
2013-07-10 21:48:31 +00:00
<li id="cite_note-blankwithnoreference"><span class="mw-cite-backlink"><a href="#cite_ref-blankwithnoreference_0">↑</a></span> <strong class="error mw-ext-cite-error">Cite error: Invalid <code><ref></code> tag;
2012-10-30 16:22:47 +00:00
no text was provided for refs named <code>blankwithnoreference</code></strong></li>
</ol>
2007-12-16 18:49:10 +00:00
!! end
2007-12-16 20:18:33 +00:00
2008-03-21 15:25:26 +00:00
!! test
Simple <ref>, with <references/> in group
!! input
Wikipedia rocks!<ref>Proceeds of Rockology, vol. XXI</ref>
Wikipedia rocks!<ref group=note>Proceeds of Rockology, vol. XXI</ref>
<references/>
<references group=note/>
!! result
2012-10-17 22:58:55 +00:00
<p>Wikipedia rocks!<sup id="cite_ref-1" class="reference"><a href="#cite_note-1">[1]</a></sup>
Wikipedia rocks!<sup id="cite_ref-2" class="reference"><a href="#cite_note-2">[note 1]</a></sup>
2008-03-21 15:25:26 +00:00
</p>
2012-10-30 16:22:47 +00:00
<ol class="references">
<li id="cite_note-1"><span class="mw-cite-backlink"><a href="#cite_ref-1">↑</a></span> <span class="reference-text">Proceeds of Rockology, vol. XXI</span>
</li>
</ol>
<ol class="references">
<li id="cite_note-2"><span class="mw-cite-backlink"><a href="#cite_ref-2">↑</a></span> <span class="reference-text">Proceeds of Rockology, vol. XXI</span>
</li>
</ol>
2008-03-21 15:25:26 +00:00
!! end
2008-06-20 18:41:14 +00:00
!! test
2015-07-07 14:18:43 +00:00
Simple <ref>, with <references/> in group, with groupname in Chinese
2008-06-20 18:41:14 +00:00
!! input
AAA<ref group="参">ref a</ref>BBB<ref group="注">note b</ref>CCC<ref group="参">ref c</ref>
;refs
<references group="参" />
;notes
<references group="注" />
!! result
2012-10-17 22:58:55 +00:00
<p>AAA<sup id="cite_ref-1" class="reference"><a href="#cite_note-1">[参 1]</a></sup>BBB<sup id="cite_ref-2" class="reference"><a href="#cite_note-2">[注 1]</a></sup>CCC<sup id="cite_ref-3" class="reference"><a href="#cite_note-3">[参 2]</a></sup>
2008-06-20 18:41:14 +00:00
</p>
2014-06-11 18:00:07 +00:00
<dl><dt>refs</dt></dl>
2012-10-30 16:22:47 +00:00
<ol class="references">
<li id="cite_note-1"><span class="mw-cite-backlink"><a href="#cite_ref-1">↑</a></span> <span class="reference-text">ref a</span>
2011-11-14 12:20:24 +00:00
</li>
2012-10-17 22:58:55 +00:00
<li id="cite_note-3"><span class="mw-cite-backlink"><a href="#cite_ref-3">↑</a></span> <span class="reference-text">ref c</span>
2012-10-30 16:22:47 +00:00
</li>
</ol>
2014-06-11 18:00:07 +00:00
<dl><dt>notes</dt></dl>
2012-10-30 16:22:47 +00:00
<ol class="references">
<li id="cite_note-2"><span class="mw-cite-backlink"><a href="#cite_ref-2">↑</a></span> <span class="reference-text">note b</span>
</li>
</ol>
2008-06-20 18:41:14 +00:00
!! end
2009-07-26 22:15:13 +00:00
!! test
<ref> defined in <references>
!! input
<ref name="foo"/>
<references>
<ref name="foo">BAR</ref>
</references>
!! result
2012-10-17 22:58:55 +00:00
<p><sup id="cite_ref-foo_1-0" class="reference"><a href="#cite_note-foo-1">[1]</a></sup>
2009-07-26 22:15:13 +00:00
</p>
2012-10-30 16:22:47 +00:00
<ol class="references">
<li id="cite_note-foo-1"><span class="mw-cite-backlink"><a href="#cite_ref-foo_1-0">↑</a></span> <span class="reference-text">BAR</span>
</li>
</ol>
2009-07-26 22:15:13 +00:00
!! end
!! test
<ref> defined in <references> called with #tag
!! input
<ref name="foo"/>
{{#tag:references|
<ref name="foo">BAR</ref>
}}
!! result
2012-10-17 22:58:55 +00:00
<p><sup id="cite_ref-foo_1-0" class="reference"><a href="#cite_note-foo-1">[1]</a></sup>
2009-07-26 22:15:13 +00:00
</p>
2012-10-30 16:22:47 +00:00
<ol class="references">
<li id="cite_note-foo-1"><span class="mw-cite-backlink"><a href="#cite_ref-foo_1-0">↑</a></span> <span class="reference-text">BAR</span>
</li>
</ol>
2009-07-26 22:15:13 +00:00
!! end
!! test
<ref> defined in <references> error conditions
!! input
<ref name="foo" group="2"/>
<references group="2">
<ref name="foo"/>
<ref name="unused">BAR</ref>
<ref name="foo" group="1">bad group</ref>
<ref>BAR BAR</ref>
</references>
!! result
2012-10-17 22:58:55 +00:00
<p><sup id="cite_ref-foo_1-0" class="reference"><a href="#cite_note-foo-1">[2 1]</a></sup>
2009-07-26 22:15:13 +00:00
</p>
2012-10-30 16:22:47 +00:00
<ol class="references">
2013-07-10 21:48:31 +00:00
<li id="cite_note-foo"><span class="mw-cite-backlink"><a href="#cite_ref-foo_0">↑</a></span> <strong class="error mw-ext-cite-error">Cite error: Invalid <code><ref></code> tag;
2012-10-30 16:22:47 +00:00
no text was provided for refs named <code>foo</code></strong></li>
</ol>
2013-07-10 21:48:31 +00:00
<p><strong class="error mw-ext-cite-error">Cite error: <code><ref></code> tag with name "unused" defined in <code><references></code> is not used in prior text.</strong><br />
<strong class="error mw-ext-cite-error">Cite error: <code><ref></code> tag in <code><references></code> has conflicting group attribute "1".</strong><br />
<strong class="error mw-ext-cite-error">Cite error: <code><ref></code> tag defined in <code><references></code> has no name attribute.</strong>
2009-07-26 22:15:13 +00:00
</p>
!! end
2010-05-22 14:28:48 +00:00
!! article
MediaWiki:cite_link_label_group-klingon
!! text
wa' cha' wej loS vagh jav Soch chorgh Hut wa'maH
!! endarticle
!! test
2015-07-07 14:18:43 +00:00
<ref> with custom group link with number names in Klingon
2010-05-22 14:28:48 +00:00
!! input
Wikipedia rocks!<ref group="klingon">Proceeds of Rockology, vol. XXI</ref>
<references group="klingon"/>
!! result
2012-10-17 22:58:55 +00:00
<p>Wikipedia rocks!<sup id="cite_ref-1" class="reference"><a href="#cite_note-1">[wa']</a></sup>
2010-05-22 14:28:48 +00:00
</p>
2012-10-30 16:22:47 +00:00
<ol class="references">
<li id="cite_note-1"><span class="mw-cite-backlink"><a href="#cite_ref-1">↑</a></span> <span class="reference-text">Proceeds of Rockology, vol. XXI</span>
</li>
</ol>
2010-05-22 14:28:48 +00:00
!! end
2011-12-13 11:16:51 +00:00
!! test
Bug 31374 regression check: nested strip items
!! input
{{#tag:ref|note<ref>reference</ref>|group=Note}}
<references group=Note />
<references />
!! result
2015-06-08 14:05:06 +00:00
<p><sup id="cite_ref-2" class="reference"><a href="#cite_note-2">[Note 1]</a></sup>
2011-12-13 11:16:51 +00:00
</p>
2012-10-30 16:22:47 +00:00
<ol class="references">
2015-06-08 14:05:06 +00:00
<li id="cite_note-2"><span class="mw-cite-backlink"><a href="#cite_ref-2">↑</a></span> <span class="reference-text">note<sup id="cite_ref-1" class="reference"><a href="#cite_note-1">[1]</a></sup></span>
2012-10-30 16:22:47 +00:00
</li>
</ol>
<ol class="references">
2015-06-08 14:05:06 +00:00
<li id="cite_note-1"><span class="mw-cite-backlink"><a href="#cite_ref-1">↑</a></span> <span class="reference-text">reference</span>
2012-10-30 16:22:47 +00:00
</li>
</ol>
!! end
!! test
Bug 13073 regression check: wrapped <references>
!! input
<ref>
foo
</ref>
<div><references /></div>
!! result
<p><sup id="cite_ref-1" class="reference"><a href="#cite_note-1">[1]</a></sup>
</p>
<div><ol class="references">
<li id="cite_note-1"><span class="mw-cite-backlink"><a href="#cite_ref-1">↑</a></span> <span class="reference-text">
foo</span>
</li>
</ol></div>
2011-12-13 11:16:51 +00:00
!! end
2015-07-05 09:40:14 +00:00
!! test
<ref> with no name and no content.
!! input
Bla.<ref></ref>
!! result
<p>Bla.<strong class="error mw-ext-cite-error">Cite error: Invalid <code><ref></code> tag;
refs with no name must have content</strong>
</p>
!! end
2015-07-07 12:16:26 +00:00
!! test
<ref> with an empty-string name parameter and no content.
!! input
Bla.<ref name=""></ref>
!! result
<p>Bla.<strong class="error mw-ext-cite-error">Cite error: Invalid <code><ref></code> tag;
refs with no name must have content</strong>
</p>
!! end
!! test
2015-07-09 14:47:47 +00:00
<ref> with a non-empty name parameter and no content.
2015-07-07 12:16:26 +00:00
!! input
Bla.<ref name="void"></ref>
!! result
Bla.<sup id="cite_ref-void_1-0" class="reference"><a href="#cite_note-void-1">[1]</a></sup><ol class="references">
<li id="cite_note-void"><span class="mw-cite-backlink"><a href="#cite_ref-void_0">↑</a></span> <strong class="error mw-ext-cite-error">Cite error: Invalid <code><ref></code> tag;
no text was provided for refs named <code>void</code></strong></li>
</ol>
!! end
2015-08-02 14:53:56 +00:00
!! test
<ref>s with the follow parameter
!! input
Page one.<ref name="beginning">First page footnote text.</ref>
Page two.<ref follow="beginning">Second page footnote text.</ref>
== References ==
<references />
!! result
<p>Page one.<sup id="cite_ref-beginning_1-0" class="reference"><a href="#cite_note-beginning-1">[1]</a></sup>
</p><p>Page two.
</p>
<h2><span class="mw-headline" id="References">References</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: References">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
<ol class="references">
<li id="cite_note-beginning-1"><span class="mw-cite-backlink"><a href="#cite_ref-beginning_1-0">↑</a></span> <span class="reference-text">First page footnote text. Second page footnote text.</span>
</li>
</ol>
!! end
!! test
<ref> with both name and follow parameters - invalid
!! input
Page one.<ref name="the-name" follow="the-name">This ref is invalid.</ref>
<references />
!! result
<p>Page one.<strong class="error mw-ext-cite-error">Cite error: Invalid <code><ref></code> tag;
invalid names, e.g. too many</strong>
</p>
!! end
2015-10-28 14:15:48 +00:00
!! test
Multiple definition (outside <references/>)
!! input
<ref name=a>abc</ref>
<ref name=a>def</ref>
<references />
!! result
<p><sup id="cite_ref-a_1-0" class="reference"><a href="#cite_note-a-1">[1]</a></sup>
<sup id="cite_ref-a_1-1" class="reference"><a href="#cite_note-a-1">[1]</a></sup>
</p>
<ol class="references">
<li id="cite_note-a-1"><span class="mw-cite-backlink">↑ <sup><a href="#cite_ref-a_1-0">1.0</a></sup> <sup><a href="#cite_ref-a_1-1">1.1</a></sup></span> <span class="reference-text">abc <strong class="error mw-ext-cite-error">Cite error: Invalid <code><ref></code> tag; name "a" defined multiple times with different content</strong></span>
</li>
</ol>
!! end
!! test
Multiple definition (inside <references/>)
!! input
<ref name=a />
<references>
<ref name=a>abc</ref>
<ref name=a>def</ref>
</references>
!! result
<p><sup id="cite_ref-a_1-0" class="reference"><a href="#cite_note-a-1">[1]</a></sup>
</p>
<ol class="references">
<li id="cite_note-a-1"><span class="mw-cite-backlink"><a href="#cite_ref-a_1-0">↑</a></span> <span class="reference-text">abc <strong class="error mw-ext-cite-error">Cite error: Invalid <code><ref></code> tag; name "a" defined multiple times with different content</strong></span>
</li>
</ol>
!! end
!! test
Multiple definition (mixed outside/inside)
!! input
<ref name=a>abc</ref>
<references>
<ref name=a>def</ref>
</references>
!! result
<p><sup id="cite_ref-a_1-0" class="reference"><a href="#cite_note-a-1">[1]</a></sup>
</p>
<ol class="references">
<li id="cite_note-a-1"><span class="mw-cite-backlink"><a href="#cite_ref-a_1-0">↑</a></span> <span class="reference-text">abc <strong class="error mw-ext-cite-error">Cite error: Invalid <code><ref></code> tag; name "a" defined multiple times with different content</strong></span>
</li>
</ol>
!! end
Rollback all, then redo all, when fixing out-of-order tags; not one-by-one
Imagine the following wikitext:
<ref name=r/>
<references>
<ref name=r>A</ref>
<ref name=r>B</ref>
</references>
This is simple. Cite would see these as the following operations, in
order:
1. Use only: <ref name=r/>
2. References block
3. Define only: <ref name=r>A</ref>
4. Define only: <ref name=r>B</ref>
<ref name=r> is defined twice with different content and we get an
error message.
Now, imagine the following wikitext:
<ref name=r/>
{{#tag:references|
<ref name=r>A</ref>
<ref name=r>B</ref>
}}
Cite would see these as the following operations, in order:
1. Use only: <ref name=r/>
2. Use and define: <ref name=r>A</ref>
3. Use and define: <ref name=r>B</ref>
4. References block
When the 'references' block appears, Cite notices that the tag has
parsed content, and deduces that it was called with #tag. We need to
undo the last operations to update internal bookkeeping, as the last
two 'ref' tags do not actually represent ref usages, as we assumed,
but only definitions.
5. Undo: <ref name=r> reused
6. Define only: <ref name=r>B</ref>
7. Undo: <ref name=r> defined
(Right now, it appears to Cite that <ref name=r> was never defined!)
8. Define only: <ref name=r>A</ref>
Thus we get no errors, although we should.
This patch changes the order of the rollback operations:
5. Undo: <ref name=r> reused
6. Undo: <ref name=r> defined
7. Define only: <ref name=r>A</ref>
8. Define only: <ref name=r>B</ref>
Aha! <ref name=r> is defined twice with different content! We get an
error correctly.
Bug: T124227
Change-Id: I61766c4104856323987cca9a5e4ff85a76b3618b
2016-01-20 20:38:59 +00:00
!! test
Multiple definition (inside {{#tag:references}})
!! input
<ref name=a />
{{#tag:references|
<ref name=a>abc</ref>
<ref name=a>def</ref>
}}
!! result
<p><sup id="cite_ref-a_1-0" class="reference"><a href="#cite_note-a-1">[1]</a></sup>
</p>
<ol class="references">
<li id="cite_note-a-1"><span class="mw-cite-backlink"><a href="#cite_ref-a_1-0">↑</a></span> <span class="reference-text">abc <strong class="error mw-ext-cite-error">Cite error: Invalid <code><ref></code> tag; name "a" defined multiple times with different content</strong></span>
</li>
</ol>
!! end