Merge "Cite anchors should be numbered starting at 1"

This commit is contained in:
Ori.livneh 2012-10-23 17:10:58 +00:00 committed by Gerrit Code Review
commit 5a8c11107b
2 changed files with 51 additions and 63 deletions

View file

@ -63,15 +63,6 @@ class Cite {
var $mOutCnt = 0;
var $mGroupCnt = array();
/**
* Internal counter for anonymous references, separate from
* $mOutCnt because anonymous references won't increment it,
* but will incremement $mOutCnt
*
* @var int
*/
var $mInCnt = 0;
/**
* Counter to track the total number of (useful) calls to either the
* ref or references tag hook
@ -400,7 +391,6 @@ class Cite {
'follow' => $follow ) ) );
array_splice( $this->mRefCallStack, $k, 0,
array( array( 'new', $call, $str, $key, $group, $this->mOutCnt ) ) );
$this->mInCnt++;
}
// return an empty string : this is not a reference
return '';
@ -411,7 +401,7 @@ class Cite {
$this->mRefs[$group][] = array( 'count' => - 1, 'text' => $str, 'key' => ++$this->mOutCnt );
$this->mRefCallStack[] = array( 'new', $call, $str, $key, $group, $this->mOutCnt );
return $this->linkRef( $group, $this->mInCnt++ );
return $this->linkRef( $group, $this->mOutCnt );
} elseif ( is_string( $key ) ) {
// Valid key
if ( !isset( $this->mRefs[$group][$key] ) || !is_array( $this->mRefs[$group][$key] ) ) {
@ -424,7 +414,6 @@ class Cite {
);
$this->mRefCallStack[] = array( 'new', $call, $str, $key, $group, $this->mOutCnt );
$this->mInCnt++;
return
$this->linkRef(
$group,
@ -1057,8 +1046,7 @@ class Cite {
}
$this->mGroupCnt = array();
$this->mOutCnt = - 1;
$this->mInCnt = 0;
$this->mOutCnt = 0;
$this->mCallCnt = 0;
$this->mRefs = array();
$this->mReferencesErrors = array();

View file

@ -9,7 +9,7 @@ Simple <ref>, no <references/>
!! input
Wikipedia rocks!<ref>Proceeds of Rockology, vol. XXI</ref>
!! result
<p>Wikipedia rocks!<sup id="cite_ref-0" class="reference"><a href="#cite_note-0">[1]</a></sup>
<p>Wikipedia rocks!<sup id="cite_ref-1" class="reference"><a href="#cite_note-1">[1]</a></sup>
<br /><strong class="error">Cite error: <code>&lt;ref&gt;</code> tags exist, but no <code>&lt;references/&gt;</code> tag was found</strong>
</p>
!! end
@ -21,9 +21,9 @@ Wikipedia rocks!<ref>Proceeds of Rockology, vol. XXI</ref>
<references/>
!! result
<p>Wikipedia rocks!<sup id="cite_ref-0" class="reference"><a href="#cite_note-0">[1]</a></sup>
<p>Wikipedia rocks!<sup id="cite_ref-1" class="reference"><a href="#cite_note-1">[1]</a></sup>
</p>
<ol class="references"><li id="cite_note-0"><span class="mw-cite-backlink"><a href="#cite_ref-0">↑</a></span> <span class="reference-text">Proceeds of Rockology, vol. XXI</span>
<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>
!! end
@ -43,9 +43,9 @@ Templating<ref>{{simple template}}</ref>
<references/>
!! result
<p>Templating<sup id="cite_ref-0" class="reference"><a href="#cite_note-0">[1]</a></sup>
<p>Templating<sup id="cite_ref-1" class="reference"><a href="#cite_note-1">[1]</a></sup>
</p>
<ol class="references"><li id="cite_note-0"><span class="mw-cite-backlink"><a href="#cite_ref-0">↑</a></span> <span class="reference-text">A <i>simple</i> template.</span>
<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>
!! end
@ -57,9 +57,9 @@ Templating<ref><nowiki>{{simple template}}</nowiki></ref>
<references/>
!! result
<p>Templating<sup id="cite_ref-0" class="reference"><a href="#cite_note-0">[1]</a></sup>
<p>Templating<sup id="cite_ref-1" class="reference"><a href="#cite_note-1">[1]</a></sup>
</p>
<ol class="references"><li id="cite_note-0"><span class="mw-cite-backlink"><a href="#cite_ref-0">↑</a></span> <span class="reference-text">{{simple template}}</span>
<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>
!! end
@ -96,9 +96,9 @@ Templating<ref>Text<!--comment--></ref>
<references/>
!! result
<p>Templating<sup id="cite_ref-0" class="reference"><a href="#cite_note-0">[1]</a></sup>
<p>Templating<sup id="cite_ref-1" class="reference"><a href="#cite_note-1">[1]</a></sup>
</p>
<ol class="references"><li id="cite_note-0"><span class="mw-cite-backlink"><a href="#cite_ref-0">↑</a></span> <span class="reference-text">Text</span>
<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>
!! end
@ -112,7 +112,7 @@ Templating<ref>Text<!--comment--></ref>
<references/>
!! result
<p><sup id="cite_ref-0" class="reference"><a href="#cite_note-0">[1]</a></sup>
<p><sup id="cite_ref-1" class="reference"><a href="#cite_note-1">[1]</a></sup>
</p>
<ul class="gallery">
<li class="gallerybox" style="width: 155px"><div style="width: 155px">
@ -121,7 +121,7 @@ Templating<ref>Text<!--comment--></ref>
</div>
</div></li>
</ul>
<ol class="references"><li id="cite_note-0"><span class="mw-cite-backlink"><a href="#cite_ref-0">↑</a></span> <span class="reference-text">one</span>
<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>
!! end
@ -131,7 +131,7 @@ Templating<ref>Text<!--comment--></ref>
!! input
{{REVISIONID}}<ref>elite</ref>
!! result
<p>1337<sup id="cite_ref-0" class="reference"><a href="#cite_note-0">[1]</a></sup>
<p>1337<sup id="cite_ref-1" class="reference"><a href="#cite_note-1">[1]</a></sup>
<br /><strong class="error">Cite error: <code>&lt;ref&gt;</code> tags exist, but no <code>&lt;references/&gt;</code> tag was found</strong>
</p>
!! end
@ -154,10 +154,10 @@ Blank ref followed by ref with content
<references/>
!! result
<p><sup id="cite_ref-blank_0-0" class="reference"><a href="#cite_note-blank-0">[1]</a></sup>
</p><p><sup id="cite_ref-blank_0-1" class="reference"><a href="#cite_note-blank-0">[1]</a></sup>
<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-0"><span class="mw-cite-backlink">↑ <sup><a href="#cite_ref-blank_0-0">1.0</a></sup> <sup><a href="#cite_ref-blank_0-1">1.1</a></sup></span> <span class="reference-text">content</span>
<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
@ -171,10 +171,10 @@ Regression: non-blank ref "0" followed by ref with content
<references/>
!! result
<p><sup id="cite_ref-blank_0-0" class="reference"><a href="#cite_note-blank-0">[1]</a></sup>
</p><p><sup id="cite_ref-blank_0-1" class="reference"><a href="#cite_note-blank-0">[1]</a></sup>
<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-0"><span class="mw-cite-backlink">↑ <sup><a href="#cite_ref-blank_0-0">1.0</a></sup> <sup><a href="#cite_ref-blank_0-1">1.1</a></sup></span> <span class="reference-text">0</span>
<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">0</span>
</li></ol>
!! end
@ -188,10 +188,10 @@ Regression sanity check: non-blank ref "1" followed by ref with content
<references/>
!! result
<p><sup id="cite_ref-blank_0-0" class="reference"><a href="#cite_note-blank-0">[1]</a></sup>
</p><p><sup id="cite_ref-blank_0-1" class="reference"><a href="#cite_note-blank-0">[1]</a></sup>
<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-0"><span class="mw-cite-backlink">↑ <sup><a href="#cite_ref-blank_0-0">1.0</a></sup> <sup><a href="#cite_ref-blank_0-1">1.1</a></sup></span> <span class="reference-text">1</span>
<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">1</span>
</li></ol>
!! end
@ -205,15 +205,15 @@ Ref names containing a number
<references />
!! result
<p><sup id="cite_ref-test123test_0-0" class="reference"><a href="#cite_note-test123test-0">[1]</a></sup>
<sup id="cite_ref-123test_1-0" class="reference"><a href="#cite_note-123test-1">[2]</a></sup>
<sup id="cite_ref-test123_2-0" class="reference"><a href="#cite_note-test123-2">[3]</a></sup>
<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>
</p>
<ol class="references"><li id="cite_note-test123test-0"><span class="mw-cite-backlink"><a href="#cite_ref-test123test_0-0">↑</a></span> <span class="reference-text">One</span>
<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>
</li>
<li id="cite_note-123test-1"><span class="mw-cite-backlink"><a href="#cite_ref-123test_1-0">↑</a></span> <span class="reference-text">Two</span>
<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>
</li>
<li id="cite_note-test123-2"><span class="mw-cite-backlink"><a href="#cite_ref-test123_2-0">↑</a></span> <span class="reference-text">Three</span>
<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>
</li></ol>
!! end
@ -237,16 +237,16 @@ Erroneous refs
!! result
<p><strong class="error">Cite error: Invalid <code>&lt;ref&gt;</code> tag;
name cannot be a simple integer. Use a descriptive title</strong>
</p><p><sup id="cite_ref-0" class="reference"><a href="#cite_note-0">[1]</a></sup>
</p><p><sup id="cite_ref-1" class="reference"><a href="#cite_note-1">[1]</a></sup>
</p><p><strong class="error">Cite error: Invalid <code>&lt;ref&gt;</code> tag;
refs with no content must have a name</strong>
</p><p><sup id="cite_ref-bar_1-0" class="reference"><a href="#cite_note-bar-1">[2]</a></sup>
</p><p><sup id="cite_ref-blankwithnoreference_2-0" class="reference"><a href="#cite_note-blankwithnoreference-2">[3]</a></sup>
</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>
</p><p><strong class="error">Cite error: Invalid <code>&lt;references&gt;</code> tag;
parameter "group" is allowed only.
Use <code>&lt;references /&gt;</code>, or <code>&lt;references group="..." /&gt;</code></strong>
</p>
<ol class="references"><li id="cite_note-0"><span class="mw-cite-backlink"><a href="#cite_ref-0">↑</a></span> <span class="reference-text">Also zero, but differently! (Normal ref)</span>
<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>
</li>
<li id="cite_note-bar"><span class="mw-cite-backlink"><a href="#cite_ref-bar_0">↑</a></span> <strong class="error">Cite error: Invalid <code>&lt;ref&gt;</code> tag;
no text was provided for refs named <code>bar</code></strong></li>
@ -265,13 +265,13 @@ Wikipedia rocks!<ref group=note>Proceeds of Rockology, vol. XXI</ref>
<references/>
<references group=note/>
!! result
<p>Wikipedia rocks!<sup id="cite_ref-0" class="reference"><a href="#cite_note-0">[1]</a></sup>
Wikipedia rocks!<sup id="cite_ref-1" class="reference"><a href="#cite_note-1">[note 1]</a></sup>
<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>
</p>
<ol class="references"><li id="cite_note-0"><span class="mw-cite-backlink"><a href="#cite_ref-0">↑</a></span> <span class="reference-text">Proceeds of Rockology, vol. XXI</span>
</li></ol>
<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>
!! end
@ -285,17 +285,17 @@ AAA<ref group="参">ref a</ref>BBB<ref group="注">note b</ref>CCC<ref group="
;notes
<references group="注" />
!! result
<p>AAA<sup id="cite_ref-0" class="reference"><a href="#cite_note-0">[参 1]</a></sup>BBB<sup id="cite_ref-1" class="reference"><a href="#cite_note-1">[注 1]</a></sup>CCC<sup id="cite_ref-2" class="reference"><a href="#cite_note-2">[参 2]</a></sup>
<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>
</p>
<dl><dt>refs
</dt></dl>
<ol class="references"><li id="cite_note-0"><span class="mw-cite-backlink"><a href="#cite_ref-0">↑</a></span> <span class="reference-text">ref a</span>
<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>
</li>
<li id="cite_note-2"><span class="mw-cite-backlink"><a href="#cite_ref-2">↑</a></span> <span class="reference-text">ref c</span>
<li id="cite_note-3"><span class="mw-cite-backlink"><a href="#cite_ref-3">↑</a></span> <span class="reference-text">ref c</span>
</li></ol>
<dl><dt>notes
</dt></dl>
<ol class="references"><li id="cite_note-1"><span class="mw-cite-backlink"><a href="#cite_ref-1">↑</a></span> <span class="reference-text">note b</span>
<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>
!! end
@ -309,9 +309,9 @@ AAA<ref group="参">ref a</ref>BBB<ref group="注">note b</ref>CCC<ref group="
<ref name="foo">BAR</ref>
</references>
!! result
<p><sup id="cite_ref-foo_0-0" class="reference"><a href="#cite_note-foo-0">[1]</a></sup>
<p><sup id="cite_ref-foo_1-0" class="reference"><a href="#cite_note-foo-1">[1]</a></sup>
</p>
<ol class="references"><li id="cite_note-foo-0"><span class="mw-cite-backlink"><a href="#cite_ref-foo_0-0">↑</a></span> <span class="reference-text">BAR</span>
<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>
!! end
@ -325,9 +325,9 @@ AAA<ref group="参">ref a</ref>BBB<ref group="注">note b</ref>CCC<ref group="
<ref name="foo">BAR</ref>
}}
!! result
<p><sup id="cite_ref-foo_0-0" class="reference"><a href="#cite_note-foo-0">[1]</a></sup>
<p><sup id="cite_ref-foo_1-0" class="reference"><a href="#cite_note-foo-1">[1]</a></sup>
</p>
<ol class="references"><li id="cite_note-foo-0"><span class="mw-cite-backlink"><a href="#cite_ref-foo_0-0">↑</a></span> <span class="reference-text">BAR</span>
<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>
!! end
@ -344,7 +344,7 @@ AAA<ref group="参">ref a</ref>BBB<ref group="注">note b</ref>CCC<ref group="
<ref>BAR BAR</ref>
</references>
!! result
<p><sup id="cite_ref-foo_0-0" class="reference"><a href="#cite_note-foo-0">[2 1]</a></sup>
<p><sup id="cite_ref-foo_1-0" class="reference"><a href="#cite_note-foo-1">[2 1]</a></sup>
</p>
<ol class="references"><li id="cite_note-foo"><span class="mw-cite-backlink"><a href="#cite_ref-foo_0">↑</a></span> <strong class="error">Cite error: Invalid <code>&lt;ref&gt;</code> tag;
no text was provided for refs named <code>foo</code></strong></li></ol>
@ -367,9 +367,9 @@ Wikipedia rocks!<ref group="klingon">Proceeds of Rockology, vol. XXI</ref>
<references group="klingon"/>
!! result
<p>Wikipedia rocks!<sup id="cite_ref-0" class="reference"><a href="#cite_note-0">[wa']</a></sup>
<p>Wikipedia rocks!<sup id="cite_ref-1" class="reference"><a href="#cite_note-1">[wa']</a></sup>
</p>
<ol class="references"><li id="cite_note-0"><span class="mw-cite-backlink"><a href="#cite_ref-0">↑</a></span> <span class="reference-text">Proceeds of Rockology, vol. XXI</span>
<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>
!! end
@ -381,11 +381,11 @@ Bug 31374 regression check: nested strip items
<references group=Note />
<references />
!! result
<p><sup id="cite_ref-1" class="reference"><a href="#cite_note-1">[Note 1]</a></sup>
<p><sup id="cite_ref-2" class="reference"><a href="#cite_note-2">[Note 1]</a></sup>
</p>
<ol class="references"><li id="cite_note-1"><span class="mw-cite-backlink"><a href="#cite_ref-1">↑</a></span> <span class="reference-text">note<sup id="cite_ref-0" class="reference"><a href="#cite_note-0">[1]</a></sup></span>
<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<sup id="cite_ref-1" class="reference"><a href="#cite_note-1">[1]</a></sup></span>
</li></ol>
<ol class="references"><li id="cite_note-0"><span class="mw-cite-backlink"><a href="#cite_ref-0">↑</a></span> <span class="reference-text">reference</span>
<ol class="references"><li id="cite_note-1"><span class="mw-cite-backlink"><a href="#cite_ref-1">↑</a></span> <span class="reference-text">reference</span>
</li></ol>
!! end