mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-28 08:50:07 +00:00
Make Cite <references> group attribute handling more robust
The PHP preprocessor returns a references tag with an empty group attribute, which we did not map to the null reference group. This caused the references listing to vanish when using the PHP preprocessor. This patch makes sure the attribute is converted to a string, stripped of leading/trailing whitespace and finally set to null if no string remains. No changes in parser tests, since Cite is in a separate extension. Change-Id: Ib3de375225947a78c362370be8d78504fa24def2
This commit is contained in:
parent
3eff5dfc13
commit
bad9921a2d
|
@ -186,14 +186,31 @@ Cite.prototype.onReferences = function ( token, manager ) {
|
|||
};
|
||||
|
||||
var res,
|
||||
options = $.extend({
|
||||
name: null,
|
||||
group: null
|
||||
}, Util.KVtoHash(token.attribs));
|
||||
attribHash = Util.KVtoHash(token.attribs),
|
||||
// Default to null group if the group param is actually empty
|
||||
options = {},
|
||||
dataAttribs,
|
||||
group = attribHash.group;
|
||||
|
||||
var dataAttribs;
|
||||
if (options.group in refGroups) {
|
||||
var group = refGroups[options.group],
|
||||
if ( group && group.constructor === Array ) {
|
||||
// Array of tokens, convert to string.
|
||||
group = Util.tokensToString(group);
|
||||
}
|
||||
|
||||
if ( group ) {
|
||||
// have a String, strip whitespace
|
||||
group = group.replace(/^\s*(.*)\s$/, '$1');
|
||||
}
|
||||
|
||||
// Point invalid / empty groups to null
|
||||
if ( ! group )
|
||||
{
|
||||
group = null;
|
||||
}
|
||||
|
||||
|
||||
if (group in refGroups) {
|
||||
var group = refGroups[group],
|
||||
listItems = $.map(group.refs, renderLine );
|
||||
|
||||
dataAttribs = Util.clone(token.dataAttribs);
|
||||
|
|
Loading…
Reference in a new issue