mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-27 16:30:12 +00:00
Show warning when dir="…" don't match
This classifies as a "warning" because we still show everything, just with an error message appended. Disabling the Parsoid tests right away hopefully makes it easier to do the same change in Parsoid. Bug: T202593 Depends-On: If14acd1070617ca8c4d15be6b1759bd47ead4926 Change-Id: I294b59f989f553932b40d08308906dd72d92d2cd
This commit is contained in:
parent
e64d944194
commit
b181614ba1
|
@ -18,6 +18,7 @@
|
|||
"cite-desc": "Adds <code><ref></code> and <code><references></code> tags for citations",
|
||||
"cite_error": "Cite error: $1",
|
||||
"cite_error_ref_invalid_dir": "Invalid <code>dir=\"$1\"</code>, must be <code>ltr</code> or <code>rtl</code>",
|
||||
"cite_error_ref_conflicting_dir": "One of the <code><ref></code> tags with the name \"$1\" does have a conflicting dir attribute.",
|
||||
"cite_error_ref_numeric_key": "Invalid <code><ref></code> tag; name cannot be a simple integer. Use a descriptive title",
|
||||
"cite_error_ref_no_key": "The opening <code><ref></code> tag is malformed or has a bad name",
|
||||
"cite_error_ref_too_many_keys": "Invalid parameter in <code><ref></code> tag",
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
"cite-desc": "{{desc|name=Cite|url=https://www.mediawiki.org/wiki/Extension:Cite}}",
|
||||
"cite_error": "Used when there are errors in ref or references tags.\n\nParameters:\n* $1 - an error message",
|
||||
"cite_error_ref_invalid_dir": "Error message shown when ref tag contain dir attribute with invalid value.\n\nParameters:\n* $1 - invalid dir value",
|
||||
"cite_error_ref_conflicting_dir": "Error message shown when ref tags with the same name contain conflicting dir attributes.\n\nParameters:\n* $1 - name of the reference",
|
||||
"cite_error_ref_numeric_key": "Error message shown if the name of a ref tag only contains digits. Examples that cause this error are <code><ref name=\"123\"/></code> or <code><ref name=\"456\">input</ref></code>",
|
||||
"cite_error_ref_no_key": "Error message shown when ref tags without any content (that is <code><ref/></code>) are used without a name.",
|
||||
"cite_error_ref_too_many_keys": "Generic error message shown when unknown, unsupported parameters are used in a <code><ref></code> tag. This can happen when there is a mistake in a parameter name, or a parameter exclusive to the <code><references></code> tag is used in a <code><ref></code> tag. This and [[MediaWiki:Cite error references invalid parameters]] form a pair and should be worded similarly.",
|
||||
|
|
|
@ -152,6 +152,11 @@ class ReferenceStack {
|
|||
$ref['count']++;
|
||||
// Rollback the global counter since we won't create a new ref.
|
||||
$this->refSequence--;
|
||||
|
||||
if ( $ref['dir'] && $dir && $ref['dir'] !== $dir ) {
|
||||
$ref['warnings'][] = [ 'cite_error_ref_conflicting_dir', $name ];
|
||||
}
|
||||
|
||||
if ( $ref['text'] === null && $text !== null ) {
|
||||
// If no text was set before, use this text
|
||||
$ref['text'] = $text;
|
||||
|
|
|
@ -1275,7 +1275,7 @@ Multiple definition (mixed outside/inside)
|
|||
!! end
|
||||
|
||||
!! test
|
||||
T202593: Conflicting dir attributes are currently not reported as an error
|
||||
T202593: Conflicting dir attributes
|
||||
!! wikitext
|
||||
<ref name="a" dir="ltr" />
|
||||
<ref name="a" dir="rtl">abc</ref>
|
||||
|
@ -1285,11 +1285,59 @@ T202593: Conflicting dir attributes are currently not reported as an error
|
|||
<sup id="cite_ref-a_1-1" class="reference"><a href="#cite_note-a-1">[1]</a></sup>
|
||||
</p>
|
||||
<div class="mw-references-wrap"><ol class="references">
|
||||
<li id="cite_note-a-1" class="mw-cite-dir-rtl"><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 <span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: One of the <code><ref></code> tags with the name "a" does have a conflicting dir attribute.</span></span>
|
||||
</li>
|
||||
</ol></div>
|
||||
!! html/parsoid+disabled
|
||||
<p><sup class="mw-ref reference" id="cite_ref-a_1-0" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"name":"a","dir":"ltr"}}'><a href="./Parser_test#cite_note-a-1" style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a></sup>
|
||||
<sup class="mw-ref reference" id="cite_ref-a_1-1" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"name":"a","dir":"rtl"},"body":{"id":"mw-reference-text-cite_note-a-1"}}'><a href="./Parser_test#cite_note-a-1" style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</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_note-a-1" class="mw-cite-dir-rtl"><span rel="mw:referencedBy"><a href="./Parser_test#cite_ref-a_1-0"><span class="mw-linkback-text">1 </span></a><a href="./Parser_test#cite_ref-a_1-1"><span class="mw-linkback-text">2 </span></a></span> <span id="mw-reference-text-cite_note-a-1" class="mw-reference-text">abc</span></li>
|
||||
</ol>
|
||||
</div>
|
||||
!! end
|
||||
|
||||
!! test
|
||||
T202593: Conflicting dir attributes with the full ref first
|
||||
!! wikitext
|
||||
<ref name="a" dir="ltr">abc</ref>
|
||||
<ref name="a" dir="rtl" />
|
||||
<references />
|
||||
!! html/php
|
||||
<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>
|
||||
<div class="mw-references-wrap"><ol class="references">
|
||||
<li id="cite_note-a-1" class="mw-cite-dir-ltr"><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 <span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: One of the <code><ref></code> tags with the name "a" does have a conflicting dir attribute.</span></span>
|
||||
</li>
|
||||
</ol></div>
|
||||
!! html/parsoid+disabled
|
||||
<p><sup class="mw-ref reference" id="cite_ref-a_1-0" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"name":"a","dir":"ltr"},"body":{"id":"mw-reference-text-cite_note-a-1"}}'><a href="./Parser_test#cite_note-a-1" style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a></sup>
|
||||
<sup class="mw-ref reference" id="cite_ref-a_1-1" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"name":"a","dir":"rtl"}}'><a href="./Parser_test#cite_note-a-1" style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</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_note-a-1" class="mw-cite-dir-ltr"><span rel="mw:referencedBy"><a href="./Parser_test#cite_ref-a_1-0"><span class="mw-linkback-text">1 </span></a><a href="./Parser_test#cite_ref-a_1-1"><span class="mw-linkback-text">2 </span></a></span> <span id="mw-reference-text-cite_note-a-1" class="mw-reference-text">abc</span></li>
|
||||
</ol>
|
||||
</div>
|
||||
!! end
|
||||
|
||||
!! test
|
||||
T202593: Identical dir attributes are pointless, but should not generate an error
|
||||
!! wikitext
|
||||
<ref name="a" dir="rtl" />
|
||||
<ref name="a" dir="rtl">abc</ref>
|
||||
<references />
|
||||
!! html/php
|
||||
<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>
|
||||
<div class="mw-references-wrap"><ol class="references">
|
||||
<li id="cite_note-a-1" class="mw-cite-dir-rtl"><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</span>
|
||||
</li>
|
||||
</ol></div>
|
||||
!! html/parsoid
|
||||
<p><sup class="mw-ref reference" id="cite_ref-a_1-0" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"name":"a","dir":"ltr"}}'><a href="./Parser_test#cite_note-a-1" style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a></sup>
|
||||
<p><sup class="mw-ref reference" id="cite_ref-a_1-0" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"name":"a","dir":"rtl"}}'><a href="./Parser_test#cite_note-a-1" style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a></sup>
|
||||
<sup class="mw-ref reference" id="cite_ref-a_1-1" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"name":"a","dir":"rtl"},"body":{"id":"mw-reference-text-cite_note-a-1"}}'><a href="./Parser_test#cite_note-a-1" style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a></sup></p>
|
||||
<div class="mw-references-wrap" typeof="mw:Extension/references" data-mw='{"name":"references","attrs":{}}'>
|
||||
<ol class="mw-references references">
|
||||
|
|
Loading…
Reference in a new issue