www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 573dea6dcd820e1c98020a4c0c574df4a3192885
parent 2689f923350e8d2fbc614f02807b88fd526a4c1c
Author: Dan Stillman <dstillman@zotero.org>
Date:   Sat, 20 Dec 2008 01:18:15 +0000

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.



Diffstat:
Mchrome/content/zotero/xpcom/csl.js | 16+++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/chrome/content/zotero/xpcom/csl.js b/chrome/content/zotero/xpcom/csl.js @@ -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];