www

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

commit 0a8990947cbf2c5264f708f079b00fbb2d5c1571
parent 8e8bc1507142fdb3e2952e73c41924d28ad0678f
Author: Simon Kornblith <simon@simonster.com>
Date:   Wed,  3 Jul 2013 00:40:15 -0400

Update to citeproc-js 1.0.469

Diffstat:
Mchrome/content/zotero/xpcom/citeproc.js | 434+++++++++++++++++++++++++++++++++++++++----------------------------------------
1 file changed, 216 insertions(+), 218 deletions(-)

diff --git a/chrome/content/zotero/xpcom/citeproc.js b/chrome/content/zotero/xpcom/citeproc.js @@ -57,7 +57,7 @@ if (!Array.indexOf) { }; } var CSL = { - PROCESSOR_VERSION: "1.0.460", + PROCESSOR_VERSION: "1.0.469", CONDITION_LEVEL_TOP: 1, CONDITION_LEVEL_BOTTOM: 2, PLAIN_HYPHEN_REGEX: /(?:[^\\]-|\u2013)/, @@ -264,11 +264,11 @@ var CSL = { SUFFIX_PUNCTUATION: /^\s*[.;:,\(\)]/, NUMBER_REGEXP: /(?:^\d+|\d+$)/, NAME_INITIAL_REGEXP: /^([A-Z\u0590-\u05ff\u0080-\u017f\u0400-\u042f\u0600-\u06ff])([a-zA-Z\u0080-\u017f\u0400-\u052f\u0600-\u06ff]*|)/, - ROMANESQUE_REGEXP: /[-0-9a-zA-Z\u0590-\u05ff\u0080-\u017f\u0400-\u052f\u0386-\u03fb\u1f00-\u1ffe\u0600-\u06ff\u200c\u200d\u200e\u202a-\u202e]/, - ROMANESQUE_NOT_REGEXP: /[^a-zA-Z\u0590-\u05ff\u0080-\u017f\u0400-\u052f\u0386-\u03fb\u1f00-\u1ffe\u0600-\u06ff\u200c\u200d\u200e\u202a-\u202e]/g, - STARTSWITH_ROMANESQUE_REGEXP: /^[&a-zA-Z\u0590-\u05ff\u0080-\u017f\u0400-\u052f\u0386-\u03fb\u1f00-\u1ffe\u0600-\u06ff\u200c\u200d\u200e\u202a-\u202e]/, - ENDSWITH_ROMANESQUE_REGEXP: /[.;:&a-zA-Z\u0590-\u05ff\u0080-\u017f\u0400-\u052f\u0386-\u03fb\u1f00-\u1ffe\u0600-\u06ff\u200c\u200d\u200e\u202a-\u202e]$/, - ALL_ROMANESQUE_REGEXP: /^[a-zA-Z\u0590-\u05ff\u0080-\u017f\u0400-\u052f\u0386-\u03fb\u1f00-\u1ffe\u0600-\u06ff\u200c\u200d\u200e\u202a-\u202e]+$/, + ROMANESQUE_REGEXP: /[-0-9a-zA-Z\u0590-\u05ff\u0080-\u017f\u0400-\u052f\u0386-\u03fb\u1f00-\u1ffe\u0600-\u06ff\u200c\u200d\u200e\u0218\u0219\u021a\u021b\u202a-\u202e]/, + ROMANESQUE_NOT_REGEXP: /[^a-zA-Z\u0590-\u05ff\u0080-\u017f\u0400-\u052f\u0386-\u03fb\u1f00-\u1ffe\u0600-\u06ff\u200c\u200d\u200e\u0218\u0219\u021a\u021b\u202a-\u202e]/g, + STARTSWITH_ROMANESQUE_REGEXP: /^[&a-zA-Z\u0590-\u05ff\u0080-\u017f\u0400-\u052f\u0386-\u03fb\u1f00-\u1ffe\u0600-\u06ff\u200c\u200d\u200e\u0218\u0219\u021a\u021b\u202a-\u202e]/, + ENDSWITH_ROMANESQUE_REGEXP: /[.;:&a-zA-Z\u0590-\u05ff\u0080-\u017f\u0400-\u052f\u0386-\u03fb\u1f00-\u1ffe\u0600-\u06ff\u200c\u200d\u200e\u0218\u0219\u021a\u021b\u202a-\u202e]$/, + ALL_ROMANESQUE_REGEXP: /^[a-zA-Z\u0590-\u05ff\u0080-\u017f\u0400-\u052f\u0386-\u03fb\u1f00-\u1ffe\u0600-\u06ff\u200c\u200d\u200e\u0218\u0219\u021a\u021b\u202a-\u202e]+$/, VIETNAMESE_SPECIALS: /[\u00c0-\u00c3\u00c8-\u00ca\u00cc\u00cd\u00d2-\u00d5\u00d9\u00da\u00dd\u00e0-\u00e3\u00e8-\u00ea\u00ec\u00ed\u00f2-\u00f5\u00f9\u00fa\u00fd\u0101\u0103\u0110\u0111\u0128\u0129\u0168\u0169\u01a0\u01a1\u01af\u01b0\u1ea0-\u1ef9]/, VIETNAMESE_NAMES: /^(?:(?:[.AaBbCcDdEeGgHhIiKkLlMmNnOoPpQqRrSsTtUuVvXxYy \u00c0-\u00c3\u00c8-\u00ca\u00cc\u00cd\u00d2-\u00d5\u00d9\u00da\u00dd\u00e0-\u00e3\u00e8-\u00ea\u00ec\u00ed\u00f2-\u00f5\u00f9\u00fa\u00fd\u0101\u0103\u0110\u0111\u0128\u0129\u0168\u0169\u01a0\u01a1\u01af\u01b0\u1ea0-\u1ef9]{2,6})(\s+|$))+$/, NOTE_FIELDS_REGEXP: /\{:(?:[\-_a-z]+|[A-Z]+):[^\}]+\}/g, @@ -289,6 +289,7 @@ var CSL = { "recipient" ], NUMERIC_VARIABLES: [ + "call-number", "chapter-number", "collection-number", "edition", @@ -1123,8 +1124,17 @@ CSL.tokenExec = function (token, Item, item) { debug = false; next = token.next; maybenext = false; - if (token.evaluator) { - next = token.evaluator(token, this, Item, item); + var record = function (result) { + if (result) { + this.tmp.jump.replace("succeed"); + return token.succeed; + } else { + this.tmp.jump.replace("fail"); + return token.fail; + } + } + if (token.test) { + next = record.call(this,token.test(Item, item)); } len = token.execs.length; for (pos = 0; pos < len; pos += 1) { @@ -3426,6 +3436,7 @@ CSL.Engine.Opt = function () { this.development_extensions.main_title_from_short_title = false; this.development_extensions.normalize_lang_keys_to_lowercase = false; this.development_extensions.strict_text_case_locales = false; + this.development_extensions.rtl_support = true; this.nodenames = []; this.gender = {}; this['cite-lang-prefs'] = { @@ -3478,7 +3489,7 @@ CSL.Engine.Tmp = function () { this.shadow_numbers = {}; }; CSL.Engine.Fun = function (state) { - this.match = new CSL.Util.Match(); + this.match = new CSL.Util.Match; this.suffixator = new CSL.Util.Suffixator(CSL.SUFFIX_CHARS); this.romanizer = new CSL.Util.Romanizer(); this.ordinalizer = new CSL.Util.Ordinalizer(state); @@ -4346,10 +4357,25 @@ CSL.citeStart = function (Item, item) { } else { this.tmp.disambig_settings = new CSL.AmbigConfig(); } - if (this.tmp.area === 'bibliography' && this.opt["disambiguate-add-names"] && this.registry.registry[Item.id] && this.tmp.disambig_override) { - this.tmp.disambig_request = this.tmp.disambig_settings; - this.tmp.disambig_request.names = this.registry.registry[Item.id].disambig.names.slice(); - this.tmp.disambig_settings.names = this.registry.registry[Item.id].disambig.names.slice(); + if (this.tmp.area !== 'citation' && this.registry.registry[Item.id]) { + this.tmp.disambig_restore = CSL.cloneAmbigConfig(this.registry.registry[Item.id].disambig); + if (this.tmp.area === 'bibliography' && this.tmp.disambig_settings && this.tmp.disambig_override) { + if (this.opt["disambiguate-add-names"]) { + this.tmp.disambig_settings.names = this.registry.registry[Item.id].disambig.names.slice(); + this.tmp.disambig_request.names = this.registry.registry[Item.id].disambig.names.slice(); + } + if (this.opt["disambiguate-add-givenname"]) { + this.tmp.disambig_request = this.tmp.disambig_settings; + this.tmp.disambig_settings.givens = this.registry.registry[Item.id].disambig.givens.slice(); + this.tmp.disambig_request.givens = this.registry.registry[Item.id].disambig.givens.slice(); + for (var i=0,ilen=this.tmp.disambig_settings.givens.length;i<ilen;i+=1) { + this.tmp.disambig_settings.givens[i] = this.registry.registry[Item.id].disambig.givens[i].slice(); + } + for (var i=0,ilen=this.tmp.disambig_request.givens.length;i<ilen;i+=1) { + this.tmp.disambig_request.givens[i] = this.registry.registry[Item.id].disambig.givens[i].slice(); + } + } + } } this.tmp.names_used = []; this.tmp.nameset_counter = 0; @@ -4384,8 +4410,11 @@ CSL.citeStart = function (Item, item) { }; CSL.citeEnd = function (Item, item) { if (this.tmp.disambig_restore) { - this.registry.registry[Item.id].disambig.names = this.tmp.disambig_restore.names; - this.registry.registry[Item.id].disambig.givens = this.tmp.disambig_restore.givens; + this.registry.registry[Item.id].disambig.names = this.tmp.disambig_restore.names.slice(); + this.registry.registry[Item.id].disambig.givens = this.tmp.disambig_restore.givens.slice(); + for (var i=0,ilen=this.registry.registry[Item.id].disambig.givens.length;i<ilen;i+=1) { + this.registry.registry[Item.id].disambig.givens[i] = this.tmp.disambig_restore.givens[i].slice(); + } } this.tmp.disambig_restore = false; this.tmp.last_suffix_used = this.tmp.suffix.value(); @@ -5504,58 +5533,11 @@ CSL.Node["date-part"] = { }; CSL.Node["else-if"] = { build: function (state, target) { - var func, tryposition; - if (this.tokentype === CSL.START || this.tokentype === CSL.SINGLETON) { - if (this.locale) { - state.opt.lang = this.locale; - } - var func = state.fun.match[this.match](this, state, this.rawtests, CSL.CONDITION_LEVEL_BOTTOM); - this.tests.push(func); - if (!this.evaluator) { - this.evaluator = function (token, state, Item, item) { - var record = function (result) { - if (result) { - state.tmp.jump.replace("succeed"); - return token.succeed; - } else { - state.tmp.jump.replace("fail"); - return token.fail; - } - } - return record(state.fun.match.any(token, state, token.tests, CSL.CONDITION_LEVEL_TOP)(Item, item)); - }; - } - } - if (this.tokentype === CSL.END || this.tokentype === CSL.SINGLETON) { - func = function (state, Item) { - if (this.locale_default) { - state.output.current.value().old_locale = this.locale_default; - state.output.closeLevel("empty"); - state.opt.lang = this.locale_default; - } - var next = this[state.tmp.jump.value()]; - return next; - }; - this.execs.push(func); - if (this.locale_default) { - state.opt.lang = this.locale_default; - } - } + CSL.Conditions.TopNode.call(this, state, target); target.push(this); }, configure: function (state, pos) { - if (this.tokentype === CSL.START) { - this.fail = state.configure.fail.slice(-1)[0]; - this.succeed = this.next; - state.configure.fail[(state.configure.fail.length - 1)] = pos; - } else if (this.tokentype === CSL.SINGLETON) { - this.fail = this.next; - this.succeed = state.configure.succeed.slice(-1)[0]; - state.configure.fail[(state.configure.fail.length - 1)] = pos; - } else { - this.succeed = state.configure.succeed.slice(-1)[0]; - this.fail = this.next; - } + CSL.Conditions.Configure.call(this, state, pos); } }; CSL.Node["else"] = { @@ -5675,58 +5657,87 @@ CSL.Node.group = { }; CSL.Node["if"] = { build: function (state, target) { - var func; - if (this.tokentype === CSL.START || this.tokentype === CSL.SINGLETON) { - if (this.locale) { - state.opt.lang = this.locale; - } - var func = state.fun.match[this.match](this, state, this.rawtests, CSL.CONDITION_LEVEL_BOTTOM); - this.tests.push(func); - if (!this.evaluator) { - this.evaluator = function (token, state, Item, item) { - var record = function (result) { - if (result) { - state.tmp.jump.replace("succeed"); - return token.succeed; - } else { - state.tmp.jump.replace("fail"); - return token.fail; - } - } - return record(state.fun.match.any(token, state, token.tests, CSL.CONDITION_LEVEL_TOP)(Item, item)); - }; - } - } - if (this.tokentype === CSL.END || this.tokentype === CSL.SINGLETON) { - func = function (state, Item) { - if (this.locale_default) { - state.output.current.value().old_locale = this.locale_default; - state.output.closeLevel("empty"); - state.opt.lang = this.locale_default; - } - var next = this[state.tmp.jump.value()]; - return next; - }; - this.execs.push(func); - if (this.locale_default) { - state.opt.lang = this.locale_default; - } - } + CSL.Conditions.TopNode.call(this, state, target); target.push(this); }, configure: function (state, pos) { + CSL.Conditions.Configure.call(this, state, pos); + } +}; +CSL.Node["conditions"] = { + build: function (state, target) { if (this.tokentype === CSL.START) { - this.fail = state.configure.fail.slice(-1)[0]; - this.succeed = this.next; - } else if (this.tokentype === CSL.SINGLETON) { - this.fail = this.next; - this.succeed = state.configure.succeed.slice(-1)[0]; + state.tmp.conditions.addMatch(this.match); + } + if (this.tokentype === CSL.END) { + state.tmp.conditions.matchCombine(); + } + } +}; +CSL.Node["condition"] = { + build: function (state, target) { + if (this.tokentype === CSL.SINGLETON) { + var test = state.fun.match[this.match](this, state, this.tests); + state.tmp.conditions.addTest(test); + } + } +}; +CSL.Conditions = {}; +CSL.Conditions.TopNode = function (state, target) { + var func; + if (this.tokentype === CSL.START || this.tokentype === CSL.SINGLETON) { + if (this.locale) { + state.opt.lang = this.locale; + } + if (!this.tests || !this.tests.length) { + state.tmp.conditions = new CSL.Conditions.Engine(state, this); } else { - this.succeed = state.configure.succeed.slice(-1)[0]; - this.fail = this.next; + this.test = state.fun.match[this.match](this, state, this.tests); + } + } + if (this.tokentype === CSL.END || this.tokentype === CSL.SINGLETON) { + func = function (state, Item) { + if (this.locale_default) { + state.output.current.value().old_locale = this.locale_default; + state.output.closeLevel("empty"); + state.opt.lang = this.locale_default; + } + var next = this[state.tmp.jump.value()]; + return next; + }; + this.execs.push(func); + if (this.locale_default) { + state.opt.lang = this.locale_default; } } }; +CSL.Conditions.Configure = function (state, pos) { + if (this.tokentype === CSL.START) { + this.fail = state.configure.fail.slice(-1)[0]; + this.succeed = this.next; + state.configure.fail[(state.configure.fail.length - 1)] = pos; + } else if (this.tokentype === CSL.SINGLETON) { + this.fail = this.next; + this.succeed = state.configure.succeed.slice(-1)[0]; + state.configure.fail[(state.configure.fail.length - 1)] = pos; + } else { + this.succeed = state.configure.succeed.slice(-1)[0]; + this.fail = this.next; + } +}; +CSL.Conditions.Engine = function (state, token) { + this.token = token; + this.state = state; +}; +CSL.Conditions.Engine.prototype.addTest = function (test) { + this.token.tests.push(test); +}; +CSL.Conditions.Engine.prototype.addMatch = function (match) { + this.token.match = match; +}; +CSL.Conditions.Engine.prototype.matchCombine = function () { + this.token.test = this.state.fun.match[this.token.match](this.token, this.state, this.token.tests); +}; CSL.Node.info = { build: function (state, target) { if (this.tokentype === CSL.START) { @@ -6066,10 +6077,22 @@ CSL.Node.layout = { }; this.execs.push(func); func = function (state, Item) { - state.output.openLevel("empty"); - }; + var tok = "empty"; + if (state.opt.development_extensions.rtl_support) { + if (["ar", "he", "fa", "ur", "yi", "ps", "syr"].indexOf(Item.language) > -1) { + tok = new CSL.Token(); + tok.strings.prefix = "\u202b"; + tok.strings.suffix = "\u202c"; + } + } + state.output.openLevel(tok); + } this.execs.push(func); target.push(this); + if (state.opt.development_extensions.rtl_support && false) { + this.strings.prefix = this.strings.prefix.replace(/\((.|$)/g,"(\u200e$1"); + this.strings.suffix = this.strings.suffix.replace(/\)(.|$)/g,")\u200e$1"); + } if (state.build.area === "citation") { prefix_token = new CSL.Token("text", CSL.SINGLETON); func = function (state, Item, item) { @@ -6914,7 +6937,7 @@ CSL.NameOutput.prototype._imposeNameConstraints = function (lst, count, key, pos var display_names = lst[key]; var discretionary_names_length = this.state.tmp["et-al-min"]; if (this.state.tmp.suppress_decorations) { - if (this.state.tmp.disambig_request) { + if (this.state.tmp.disambig_request && this.state.tmp.disambig_request.names[pos]) { discretionary_names_length = this.state.tmp.disambig_request.names[pos]; } else if (count[key] >= this.etal_min) { discretionary_names_length = this.etal_use_first; @@ -7656,7 +7679,7 @@ CSL.NameOutput.prototype._parseName = function (name) { } else { noparse = false; } - if (!name["non-dropping-particle"] && name.family && !noparse) { + if (!name["non-dropping-particle"] && name.family && !noparse && name.given) { m = name.family.match(/^((?:[a-z][ \'\u2019a-z]*[-|\s+|\'\u2019]|[ABDVL][^ ][-|\s+][a-z]*\s*|[ABDVL][^ ][^ ][-|\s+][a-z]*\s*))/); if (m) { name.family = name.family.slice(m[1].length); @@ -8812,8 +8835,7 @@ CSL.Attributes["@disambiguate"] = function (state, arg) { }; CSL.Attributes["@is-numeric"] = function (state, arg, joiner) { var variables = arg.split(/\s+/); - var reverses = CSL.Util.setReverseConditions.call(this, variables); - var maketest = function(variable, reverse) { + var maketest = function(variable) { return function (Item, item) { var myitem = Item; if (["locator","locator-revision"].indexOf(variable) > -1) { @@ -8824,43 +8846,41 @@ CSL.Attributes["@is-numeric"] = function (state, arg, joiner) { state.processNumber(false, myitem, variable, Item.type); } if (myitem[variable] && state.tmp.shadow_numbers[variable].numeric) { - return reverse ? false : true; + return true; } } else if (["title", "locator-revision","version"].indexOf(variable) > -1) { if (myitem[variable]) { if (myitem[variable].slice(-1) === "" + parseInt(myitem[variable].slice(-1), 10)) { - return reverse ? false : true; + return true; } } } - return reverse ? true : false; + return false; } } for (var i=0; i<variables.length; i+=1) { - this.rawtests.push(maketest(variables[i], reverses[i])); + this.tests.push(maketest(variables[i])); } }; CSL.Attributes["@is-uncertain-date"] = function (state, arg) { var variables = arg.split(/\s+/); - var reverses = CSL.Util.setReverseConditions.call(this, variables); - var maketest = function (myvariable, reverse) { + var maketest = function (myvariable) { return function(Item, item) { if (Item[myvariable] && Item[myvariable].circa) { - return reverse ? false : true; + return true; } else { - return reverse ? true : false; + return false; } } } for (var i=0,ilen=variables.length;i<ilen;i+=1) { - this.rawtests.push(maketest(variables[i], reverses[i])); + this.tests.push(maketest(variables[i])); }; }; CSL.Attributes["@locator"] = function (state, arg) { var trylabels = arg.replace("sub verbo", "sub-verbo"); trylabels = trylabels.split(/\s+/); - var reverses = CSL.Util.setReverseConditions.call(this, trylabels); - var maketest = function (trylabel, reverse) { + var maketest = function (trylabel) { return function(Item, item) { var label; if ("undefined" === typeof item || !item.label) { @@ -8871,14 +8891,14 @@ CSL.Attributes["@locator"] = function (state, arg) { label = item.label; } if (trylabel === label) { - return reverse ? false : true; + return true; } else { - return reverse ? true : false; + return false; } } } for (var i=0,ilen=trylabels.length;i<ilen;i+=1) { - this.rawtests.push(maketest(trylabels[i], reverses[i])); + this.tests.push(maketest(trylabels[i])); } }; CSL.Attributes["@position"] = function (state, arg) { @@ -8918,33 +8938,34 @@ CSL.Attributes["@position"] = function (state, arg) { tryposition = CSL.POSITION_IBID_WITH_LOCATOR; } if ("near-note" === tryposition) { - this.rawtests.push(function (Item, item) { + this.tests.push(function (Item, item) { if (item && item.position === CSL.POSITION_SUBSEQUENT && item["near-note"]) { return true; } return false; }); } else { - this.rawtests.push(maketest(tryposition)); + this.tests.push(maketest(tryposition)); } } }; CSL.Attributes["@type"] = function (state, arg) { var types = arg.split(/\s+/); - var reverses = CSL.Util.setReverseConditions.call(this, types); - var maketest = function (mytype, reverse) { + var maketest = function (mytype) { return function(Item,item) { var ret = (Item.type === mytype); if (ret) { - return reverse ? false : true; + return true; } else { - return reverse ? true : false; + return false; } } } + var tests = []; for (var i=0,ilen=types.length;i<ilen;i+=1) { - this.rawtests.push(maketest(types[i], reverses[i])); + tests.push(maketest(types[i])); } + this.tests.push(state.fun.match.any(this, state, tests)); }; CSL.Attributes["@variable"] = function (state, arg) { var func; @@ -9067,9 +9088,8 @@ CSL.Attributes["@variable"] = function (state, arg) { } }; this.execs.push(func); - } else if (["if", "else-if"].indexOf(this.name) > -1) { - var reverses = CSL.Util.setReverseConditions.call(this, this.variables); - var maketest = function (variable, reverse) { + } else if (["if", "else-if", "condition"].indexOf(this.name) > -1) { + var maketest = function (variable) { return function(Item,item){ var myitem = Item; if (item && ["locator", "locator-revision", "first-reference-note-number", "locator-date"].indexOf(variable) > -1) { @@ -9077,32 +9097,31 @@ CSL.Attributes["@variable"] = function (state, arg) { } if (variable === "hereinafter" && state.sys.getAbbreviation && myitem.id) { if (state.transform.abbrevs["default"].hereinafter[myitem.id]) { - return reverse ? false : true; + return true; } } else if (myitem[variable]) { if ("number" === typeof myitem[variable] || "string" === typeof myitem[variable]) { - return reverse ? false : true; + return true; } else if ("object" === typeof myitem[variable]) { for (key in myitem[variable]) { if (myitem[variable][key]) { - return reverse ? false : true; + return true; } } } } - return reverse ? true : false; + return false; } } for (var i=0,ilen=this.variables.length;i<ilen;i+=1) { - this.rawtests.push(maketest(this.variables[i], reverses[i])); + this.tests.push(maketest(this.variables[i])); } } }; CSL.Attributes["@page"] = function (state, arg) { var trylabels = arg.replace("sub verbo", "sub-verbo"); trylabels = trylabels.split(/\s+/); - var reverses = CSL.Util.setReverseConditions.call(this, trylabels); - var maketest = function (trylabel, reverse) { + var maketest = function (trylabel) { return function(Item, item) { var label; state.processNumber(false, Item, "page", Item.type); @@ -9114,26 +9133,25 @@ CSL.Attributes["@page"] = function (state, arg) { label = state.tmp.shadow_numbers.page.label; } if (trylabel === label) { - return reverse ? false : true; + return true; } else { - return reverse ? true : false; + return false; } } } for (var i=0,ilen=trylabels.length;i<ilen;i+=1) { - this.rawtests.push(maketest(trylabels[i], reverses[i])); + this.tests.push(maketest(trylabels[i])); } }; CSL.Attributes["@jurisdiction"] = function (state, arg) { var tryjurisdictions = arg.split(/\s+/); - var reverses = CSL.Util.setReverseConditions.call(this, tryjurisdictions); for (var i=0,ilen=tryjurisdictions.length;i<ilen;i+=1) { tryjurisdictions[i] = tryjurisdictions[i].split(";"); } - var maketests = function (tryjurisdiction, reverse) { + var maketests = function (tryjurisdiction) { return function(Item,item){ if (!Item.jurisdiction) { - return reverse ? true : false; + return false; } var jurisdictions = Item.jurisdiction.split(";"); for (var i=0,ilen=jurisdictions.length;i<ilen;i+=1) { @@ -9142,16 +9160,16 @@ CSL.Attributes["@jurisdiction"] = function (state, arg) { for (i=tryjurisdiction.length;i>0;i+=-1) { var tryjurisdictionStr = tryjurisdiction.slice(0,i).join(";"); var jurisdiction = jurisdictions.slice(0,i).join(";"); - if (tryjurisdictionStr === jurisdiction) { - return reverse ? false : true; + if (tryjurisdictionStr !== jurisdiction) { + return false; } } - return reverse ? true : false; + return true; } } for (var i=0,ilen=tryjurisdictions.length;i<ilen;i+=1) { var tryjurisdictionSlice = tryjurisdictions[i].slice(); - this.rawtests.push(maketests(tryjurisdictionSlice, reverses[i])); + this.tests.push(maketests(tryjurisdictionSlice)); } }; CSL.Attributes["@context"] = function (state, arg) { @@ -9177,7 +9195,7 @@ CSL.Attributes["@has-year-only"] = function (state, arg) { } } for (var i=0,ilen=trydates.length;i<ilen;i+=1) { - this.rawtests.push(maketest(trydates[i])); + this.tests.push(maketest(trydates[i])); } }; CSL.Attributes["@has-month-or-season-only"] = function (state, arg) { @@ -9193,7 +9211,7 @@ CSL.Attributes["@has-month-or-season-only"] = function (state, arg) { } } for (var i=0,ilen=trydates.length;i<ilen;i+=1) { - this.rawtests.push(maketest(trydates[i])); + this.tests.push(maketest(trydates[i])); } }; CSL.Attributes["@has-day-only"] = function (state, arg) { @@ -9209,7 +9227,7 @@ CSL.Attributes["@has-day-only"] = function (state, arg) { } } for (var i=0,ilen=trydates.length;i<ilen;i+=1) { - this.rawtests.push(maketest(trydates[i])); + this.tests.push(maketest(trydates[i])); }; }; CSL.Attributes["@subjurisdictions"] = function (state, arg) { @@ -9397,22 +9415,7 @@ CSL.Attributes["@delimiter"] = function (state, arg) { } }; CSL.Attributes["@match"] = function (state, arg) { - var match; - if (this.tokentype === CSL.START || CSL.SINGLETON) { - this.match = arg; - this.evaluator = function (token, state, Item, item) { - var record = function (result) { - if (result) { - state.tmp.jump.replace("succeed"); - return token.succeed; - } else { - state.tmp.jump.replace("fail"); - return token.fail; - } - } - return record(state.fun.match[arg](token, state, token.tests, CSL.CONDITION_LEVEL_TOP)(Item, item)); - }; - } + this.match = arg; }; CSL.Attributes["@names-min"] = function (state, arg) { var val = parseInt(arg, 10); @@ -10216,22 +10219,9 @@ CSL.Parallel.prototype.purgeGroupsIfParallel = function (original_condition) { this.parallel_conditional_blobs_list.pop(); } } -CSL.Util = { - setReverseConditions: function (lst) { - reverses = []; - for (var i=0,ilen=lst.length;i<ilen;i+=1) { - if (lst[i].slice(0,4) === "not:") { - lst[i] = lst[i].slice(4); - reverses.push(true); - } else { - reverses.push(false); - } - } - return reverses; - } -}; +CSL.Util = {}; CSL.Util.Match = function () { - this.any = function (token, state, tests, level) { + this.any = function (token, state, tests) { return function (Item, item) { for (var i=0, ilen=tests.length; i < ilen; i += 1) { result = tests[i](Item, item); @@ -10243,10 +10233,7 @@ CSL.Util.Match = function () { }; }; this[undefined] = this.any; - this.none = function (token, state, tests, level) { - if (CSL.CONDITION_LEVEL_TOP !== level) { - return this.any(token, state, tests, level); - } + this.none = function (token, state, tests) { return function (Item, item) { for (var i=0,ilen=tests.length;i<ilen;i+=1) { result = tests[i](Item,item); @@ -10257,7 +10244,7 @@ CSL.Util.Match = function () { return true; }; }; - this.all = function (token, state, tests, level) { + this.all = function (token, state, tests) { return function (Item, item) { for (var i=0,ilen=tests.length;i<ilen;i+=1) { result = tests[i](Item,item); @@ -10268,6 +10255,17 @@ CSL.Util.Match = function () { return true; }; }; + this.nand = function (token, state, tests) { + return function (Item, item) { + for (var i=0,ilen=tests.length;i<ilen;i+=1) { + result = tests[i](Item,item); + if (!result) { + return true; + } + } + return false; + }; + }; }; CSL.Transform = function (state) { var debug = false, abbreviations, token, fieldname, abbrev_family, opt; @@ -10300,7 +10298,7 @@ CSL.Transform = function (state) { var jurisdiction = state.transform.loadAbbreviation(Item.jurisdiction, myabbrev_family, basevalue, Item.type); if (state.transform.abbrevs[jurisdiction][myabbrev_family] && basevalue && state.sys.getAbbreviation) { if (state.transform.abbrevs[jurisdiction][myabbrev_family][basevalue]) { - value = state.transform.abbrevs[jurisdiction][myabbrev_family][basevalue]; + value = state.transform.abbrevs[jurisdiction][myabbrev_family][basevalue].replace("{stet}",basevalue); } } } @@ -11322,18 +11320,7 @@ CSL.Util.substituteStart = function (state, target) { return false; }; if_start.tests.push(func); - if_start.evaluator = function (token, state, Item, item) { - var record = function (result) { - if (result) { - state.tmp.jump.replace("succeed"); - return token.succeed; - } else { - state.tmp.jump.replace("fail"); - return token.fail; - } - } - return record(state.fun.match.any(token, state, token.tests, CSL.CONDITION_LEVEL_BOTTOM)(Item, item)); - }; + if_start.test = state.fun.match.any(this, state, if_start.tests); target.push(if_start); } }; @@ -11646,7 +11633,9 @@ CSL.Engine.prototype.processNumber = function (node, ItemObject, variable, type) if (["page", "page-first"].indexOf(variable) > -1) { var m = num.split(" ")[0].match(CSL.STATUTE_SUBDIV_GROUPED_REGEX); if (m){ - this.tmp.shadow_numbers[variable].label = CSL.STATUTE_SUBDIV_STRINGS[m[0]]; + if (this.opt.development_extensions.static_statute_locator) { + this.tmp.shadow_numbers[variable].label = CSL.STATUTE_SUBDIV_STRINGS[m[0]]; + } var mm = num.match(/[^ ]+\s+(.*)/); if (mm) { num = mm[1]; @@ -12230,12 +12219,6 @@ CSL.getSafeEscape = function(state) { return txt.replace(/\u202f/g, '<span style="white-space:nowrap">&thinsp;</span>'); }); } - if (state.opt.force_parens_char) { - callbacks.push(function (txt) { - return txt.replace(/([\(\<\[])/g, state.opt.force_parens_char + "$1") - .replace(/([\)\>\]])/g, "$1" + state.opt.force_parens_char); - }); - } if (callbacks.length) { return function (txt) { for (var i = 0, ilen = callbacks.length; i < ilen; i += 1) { @@ -12646,6 +12629,7 @@ CSL.Registry = function (state) { this.oldseq = {}; this.return_data = {}; this.ambigcites = {}; + this.ambigresets = {}; this.sorter = new CSL.Registry.Comparifier(state, "bibliography_sort"); this.getSortedIds = function () { ret = []; @@ -12695,6 +12679,7 @@ CSL.Registry.prototype.init = function (itemIDs, uncited_flag) { this.refreshes = {}; this.touched = {}; this.ambigsTouched = {}; + this.ambigresets = {}; }; CSL.Registry.prototype.dopurge = function (myhash) { for (var i=this.mylist.length-1;i>-1;i+=-1) { @@ -12727,6 +12712,7 @@ CSL.Registry.prototype.dodeletes = function (myhash) { if (mypos > -1) { items = this.ambigcites[ambig].slice(); this.ambigcites[ambig] = items.slice(0, mypos).concat(items.slice(mypos+1, items.length)); + this.ambigresets[ambig] = this.ambigcites[ambig].length; } len = this.ambigcites[ambig].length; for (pos = 0; pos < len; pos += 1) { @@ -12828,11 +12814,23 @@ CSL.Registry.prototype.dorefreshes = function () { Item = this.state.retrieveItem(key); var akey = regtoken.ambig; if ("undefined" === typeof akey) { + this.state.tmp.disambig_settings = false; akey = CSL.getAmbiguousCite.call(this.state, Item); + abase = CSL.getAmbigConfig.call(this.state); + this.registerAmbigToken(akey, key, abase); + } + for (var akkey in this.ambigresets) { + if (this.ambigresets[akkey] === 1) { + var loneKey = this.ambigcites[akey][0]; + var Item = this.state.retrieveItem(loneKey); + this.registry[loneKey].disambig = new CSL.AmbigConfig; + this.state.tmp.disambig_settings = false; + var akey = CSL.getAmbiguousCite.call(this.state, Item); + var abase = CSL.getAmbigConfig.call(this.state); + this.registerAmbigToken(akey, loneKey, abase); + } } this.state.tmp.taintedItemIDs[key] = true; - abase = CSL.getAmbigConfig.call(this.state); - this.registerAmbigToken(akey, key, abase); this.ambigsTouched[akey] = true; if (!Item.legislation_id) { this.akeys[akey] = true; @@ -13394,7 +13392,7 @@ CSL.Disambiguation.prototype.incrementDisambig = function () { && increment_names) { if (this.state.opt["disambiguate-add-names"]) { increment_namesets = false; - if (this.base.names[this.gnameset] < this.namesMax) { + if (this.gname < this.namesMax) { this.base.names[this.gnameset] += 1; this.gname += 1; } else { @@ -13414,7 +13412,7 @@ CSL.Disambiguation.prototype.incrementDisambig = function () { } } if (("number" !== typeof this.namesetsMax || this.namesetsMax === -1 || this.gnameset === this.namesetsMax) - && (!this.state.opt["disambiguate-add-names"] || "number" !== typeof this.namesMax || this.base.names[this.gnameset] === this.namesMax) + && (!this.state.opt["disambiguate-add-names"] || "number" !== typeof this.namesMax || this.gname === this.namesMax) && ("number" != typeof this.givensMax || "undefined" === typeof this.base.givens[this.gnameset] || "undefined" === typeof this.base.givens[this.gnameset][this.gname] || this.base.givens[this.gnameset][this.gname] === this.givensMax)) { maxed = true; }