diff --git a/chrome/content/zotero/xpcom/citeproc.js b/chrome/content/zotero/xpcom/citeproc.js index d9ee488c0..74b6b3480 100644 --- 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.450", + PROCESSOR_VERSION: "1.0.451", CONDITION_LEVEL_TOP: 1, CONDITION_LEVEL_BOTTOM: 2, PLAIN_HYPHEN_REGEX: /(?:[^\\]-|\u2013)/, @@ -4683,6 +4683,8 @@ CSL.getCite = function (Item, item, prevItemID) { return "" + Item.id; }; CSL.citeStart = function (Item, item) { + this.tmp.disambiguate_count = 0; + this.tmp.disambiguate_maxMax = 0; this.tmp.same_author_as_previous_cite = false; if (!this.tmp.suppress_decorations) { this.tmp.subsequent_author_substitute_ok = true; @@ -6804,7 +6806,7 @@ CSL.NameOutput.prototype._runDisambigNames = function (lst, pos) { if (this.state.tmp.disambig_request) { var val = this.state.tmp.disambig_settings.givens[pos][i]; if (val === 1 && - this.state.opt["givenname-disambiguation-rule"] === "by-cite" && + this.state.citation.opt["givenname-disambiguation-rule"] === "by-cite" && ("undefined" === typeof this.name.strings["initialize-with"] || "undefined" === typeof lst[i].given)) { val = 2; @@ -6955,6 +6957,7 @@ CSL.NameOutput.prototype._imposeNameConstraints = function (lst, count, key, pos } } this.state.tmp.disambig_settings.names[pos] = lst[key].length; + this.state.disambiguate.padBase(this.state.tmp.disambig_settings); }; CSL.NameOutput.prototype.getEtAlConfig = function () { var item = this.item; @@ -8819,7 +8822,10 @@ CSL.Attributes["@disambiguate"] = function (state, arg) { state.opt.has_disambiguate = true; var func = function (Item, item) { var ret; - if (state.tmp.disambig_settings.disambiguate) { + state.tmp.disambiguate_maxMax += 1; + if (state.tmp.disambig_settings.disambiguate + && state.tmp.disambiguate_count < state.tmp.disambig_settings.disambiguate) { + state.tmp.disambiguate_count += 1; return true; } return false; @@ -9581,7 +9587,7 @@ CSL.Attributes["@newdate"] = function (state, arg) { }; CSL.Attributes["@givenname-disambiguation-rule"] = function (state, arg) { if (CSL.GIVENNAME_DISAMBIGUATION_RULES.indexOf(arg) > -1) { - state.opt["givenname-disambiguation-rule"] = arg; + state.citation.opt["givenname-disambiguation-rule"] = arg; } }; CSL.Attributes["@collapse"] = function (state, arg) { @@ -12719,7 +12725,7 @@ CSL.Registry.prototype.dodeletes = function (myhash) { mypos = this.ambigcites[ambig].indexOf(key); if (mypos > -1) { items = this.ambigcites[ambig].slice(); - this.ambigcites[ambig] = items.slice(0, mypos).concat(items.slice([(mypos + 1)], items.length)); + this.ambigcites[ambig] = items.slice(0, mypos).concat(items.slice(mypos+1, items.length)); } len = this.ambigcites[ambig].length; for (pos = 0; pos < len; pos += 1) { @@ -12926,6 +12932,13 @@ CSL.Registry.prototype.registerAmbigToken = function (akey, id, ambig_config) { if (new_names_params !== old_names_params) { this.state.tmp.taintedItemIDs[id] = true; } + for (var j=0,jlen=ambig_config.givens[i].length;j 1) { + } else if (this.state.tmp.disambiguate_count === this.state.tmp.disambiguate_maxMax) { if (this.modeindex === this.modes.length - 1) { var base = this.lists[this.listpos][0]; for (var i = 0, ilen = this.lists[this.listpos][1].length; i < ilen; i += 1) { @@ -13361,17 +13378,22 @@ CSL.Disambiguation.prototype.incrementDisambig = function () { increment_namesets = true; } if ("number" === typeof this.givensMax) { - if (this.base.givens[this.gnameset][this.gname] < this.givensMax) { + if (this.base.givens.length && this.base.givens[this.gnameset][this.gname] < this.givensMax) { this.base.givens[this.gnameset][this.gname] += 1; } else { increment_names = true; } } - if ("number" === typeof this.namesMax && increment_names) { - increment_namesets = false; - if (this.base.names[this.gnameset] < this.namesMax) { - this.base.names[this.gnameset] += 1; - this.gname += 1; + if ("number" === typeof this.namesMax + && increment_names) { + if (this.state.opt["disambiguate-add-names"]) { + increment_namesets = false; + if (this.base.names[this.gnameset] < this.namesMax) { + this.base.names[this.gnameset] += 1; + this.gname += 1; + } else { + increment_namesets = true; + } } else { increment_namesets = true; } @@ -13386,10 +13408,13 @@ CSL.Disambiguation.prototype.incrementDisambig = function () { } } if (("number" !== typeof this.namesetsMax || this.namesetsMax === -1 || this.gnameset === this.namesetsMax) - && ("number" !== typeof this.namesMax || this.base.names[this.gnameset] === this.namesMax) - && ("number" != typeof this.givensMax || "undefined" === typeof this.base.givens[this.gnameset][this.gname] || this.base.givens[this.gnameset][this.gname] === this.givensMax)) { + && (!this.state.opt["disambiguate-add-names"] || "number" !== typeof this.namesMax || this.base.names[this.gnameset] === 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; } + } else if ("disExtraText" === this.modes[this.modeindex]) { + this.base.disambiguate += 1; + this.betterbase.disambiguate += 1; } return maxed; }; @@ -13443,29 +13468,43 @@ CSL.Disambiguation.prototype.initVars = function (akey) { this.Item = this.state.retrieveItem("" + myIds[0]); } this.modeindex = 0; - this.namesMax = this.maxNamesByItemId[this.Item.id][0]; - for (i = 0, ilen = this.base.givens.length; i < ilen; i += 1) { - for (var j = 0, jlen = this.namesMax; j < jlen; j += 1) { - if (!this.base.givens[i][j]) { - this.base.givens[i][j] = 0; - this.betterbase.givens[i][j] = 0; - } + if (this.state.citation.opt["disambiguate-add-names"] || true) { + this.namesMax = this.maxNamesByItemId[this.Item.id][0]; + } else { + var namesMax = this.base.names[0]; + for (var i=1,ilen=this.base.names.length;i this.base.names[i]) { - this.base.givens[i] = this.base.givens[i].concat(this.base.givens[i].slice(this.base.names[i])); + this.base.givens[i] = base.givens[i].slice(); this.base.names[i] = base.names[i]; this.betterbase.names = this.base.names.slice(); + this.betterbase.givens = this.base.givens.slice(); + this.padBase(this.base); + this.padBase(this.betterbase); } } this.betterbase.givens = this.base.givens.slice(); @@ -13505,7 +13550,7 @@ CSL.Disambiguation.prototype.getCiteData = function(Item, base) { } }; CSL.Disambiguation.prototype.captureStepToBase = function() { - if (this.state.opt["givenname-disambiguation-rule"] === "by-cite") { + if (this.state.citation.opt["givenname-disambiguation-rule"] === "by-cite") { this.betterbase.givens[this.gnameset][this.gname] = this.base.givens[this.gnameset][this.gname]; } this.betterbase.names[this.gnameset] = this.base.names[this.gnameset];