Merge "Simplify weirdly complex [\n\t ] regex"

This commit is contained in:
jenkins-bot 2018-11-30 23:50:55 +00:00 committed by Gerrit Code Review
commit c6e13db74f
3 changed files with 25 additions and 6 deletions

View file

@ -50,7 +50,7 @@
"cite_references_no_link": "{{notranslate}}\nParameters:\n* $1 - references key\n* $2 - reference text",
"cite_references_link_one": "{{optional}}\nParameters:\n* $1 - references key\n* $2 - ref key\n* $3 - reference text\n* $4 - optional CSS class for direction",
"cite_references_link_many": "{{optional}}\nParameters:\n* $1 - references key\n* $2 - list of links\n* $3 - reference text\n* $4 - optional CSS class for direction",
"cite_references_link_many_format": "{{optional}}\nParameters:\n* $1 - ref key\n* $2 - ...\n* $3 - (Unused)...",
"cite_references_link_many_format": "{{optional}}\nParameters:\n* $1 - reference key\n* $2 - canonical numeric backlink label for the link, always in the form \"1.2\"\n* $3 - optional alternate backlink label as defined via [[MediaWiki:cite_references_link_many_format_backlink_labels]]",
"cite_references_link_many_format_backlink_labels": "{{Optional}}",
"cite_references_link_many_sep": "{{optional}}",
"cite_references_link_many_and": "{{optional}}",

View file

@ -1111,18 +1111,18 @@ class Cite {
/**
* Generate the labels to pass to the
* 'cite_references_link_many_format' message, the format is an
* arbitrary number of tokens separated by [\t\n ]
* arbitrary number of tokens separated by whitespace.
*/
private function genBacklinkLabels() {
$text = wfMessage( 'cite_references_link_many_format_backlink_labels' )
->inContentLanguage()->plain();
$this->mBacklinkLabels = preg_split( '#[\n\t ]#', $text );
$this->mBacklinkLabels = preg_split( '/\s+/', $text );
}
/**
* Generate the labels to pass to the
* 'cite_reference_link' message instead of numbers, the format is an
* arbitrary number of tokens separated by [\t\n ]
* arbitrary number of tokens separated by whitespace.
*
* @param string $group
* @param string $message
@ -1133,7 +1133,7 @@ class Cite {
if ( $msg->exists() ) {
$text = $msg->plain();
}
$this->mLinkLabels[$group] = ( !$text ) ? false : preg_split( '#[\n\t ]#', $text );
$this->mLinkLabels[$group] = $text ? preg_split( '/\s+/', $text ) : false;
}
/**

View file

@ -422,7 +422,7 @@ no text was provided for refs named <code>foo</code></span></li>
!! article
MediaWiki:cite_link_label_group-klingon
!! text
wa' cha' wej loS vagh jav Soch chorgh Hut wa'maH
wa' cha' wej loS vagh jav Soch chorgh Hut wa'maH
!! endarticle
!! test
@ -441,6 +441,25 @@ Wikipedia rocks!<ref group="klingon">Proceeds of Rockology, vol. XXI</ref>
!! end
!! test
Consecutive whitespace in custom link label message should not create empty []
!! wikitext
<ref group="klingon">1st</ref>
<ref group="klingon">2nd</ref>
<references group="klingon" />
!! html
<p><sup id="cite_ref-1" class="reference"><a href="#cite_note-1">&#91;wa&#39;&#93;</a></sup>
<sup id="cite_ref-2" class="reference"><a href="#cite_note-2">&#91;cha&#39;&#93;</a></sup>
</p>
<div class="mw-references-wrap"><ol class="references">
<li id="cite_note-1"><span class="mw-cite-backlink"><a href="#cite_ref-1">↑</a></span> <span class="reference-text">1st</span>
</li>
<li id="cite_note-2"><span class="mw-cite-backlink"><a href="#cite_ref-2">↑</a></span> <span class="reference-text">2nd</span>
</li>
</ol></div>
!! end
!! test
Bug 31374 regression check: nested strip items
!! wikitext