Addresses #1262, Broken pluralization with et al. + other issues

Values enclosed in double quotes now fail is-numeric test, and the double quotes are stripped on output to CSL -- if any fields actually need enclosing quotes, this could be limited to certain fields such as edition.
This commit is contained in:
Dan Stillman 2008-12-20 01:18:15 +00:00
parent 2689f92335
commit 573dea6dcd

View file

@ -99,6 +99,7 @@ Zotero.CSL.prototype.createCitation = function(citationItems) {
Zotero.CSL._firstNameRegexp = /^[^\s]*/;
Zotero.CSL._textCharRegexp = /[a-zA-Z0-9]/;
Zotero.CSL._numberRegexp = /\d+/;
Zotero.CSL._quotedRegexp = /^".+"$/;
Zotero.CSL.prototype.formatCitation = function(citation, format) {
default xml namespace = "http://purl.org/net/xbiblio/csl"; with({});
@ -1824,7 +1825,14 @@ Zotero.CSL.Item.prototype.getVariable = function(variable, form) {
for each(var zoteroField in zoteroFields) {
var value = this.zoteroItem.getField(zoteroField, false, true);
if(value != "") return value + '';
value = value + '';
if(value != "") {
// Strip enclosing quotes
if(value.match(Zotero.CSL._quotedRegexp)) {
value = value.substr(1, value.length-2);
}
return value;
}
}
return "";
@ -1904,6 +1912,12 @@ Zotero.CSL.Item.prototype.getNumericVariable = function(variable, form) {
var matches;
for each(var zoteroField in zoteroFields) {
var value = this.zoteroItem.getField(zoteroField, false, true);
// Quoted strings are never numeric
if(value.match(Zotero.CSL._quotedRegexp)) {
continue;
}
var matches;
if(value != "" && (matches = value.toString().match(Zotero.CSL._numberRegexp)) ) {
value = matches[0];