From cf12f1e9ccc3f56a91446e38e8dd0fef856c5a43 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Thu, 15 Mar 2018 10:13:41 -0700 Subject: [PATCH] Update citeproc-js to 1.1.193 --- chrome/content/zotero/xpcom/citeproc.js | 184 +++++++++++++----------- 1 file changed, 100 insertions(+), 84 deletions(-) diff --git a/chrome/content/zotero/xpcom/citeproc.js b/chrome/content/zotero/xpcom/citeproc.js index 89352cc4d..6825bcdeb 100644 --- a/chrome/content/zotero/xpcom/citeproc.js +++ b/chrome/content/zotero/xpcom/citeproc.js @@ -24,7 +24,7 @@ */ var CSL = { - PROCESSOR_VERSION: "1.1.190", + PROCESSOR_VERSION: "1.1.193", CONDITION_LEVEL_TOP: 1, CONDITION_LEVEL_BOTTOM: 2, PLAIN_HYPHEN_REGEX: /(?:[^\\]-|\u2013)/, @@ -3911,6 +3911,10 @@ CSL.Output.Queue.prototype.string = function (state, myblobs, blob) { if ("number" === typeof blobjr.num) { ret.push(blobjr); } else if (blobjr.blobs) { + if (blobjr.particle) { + blobjr.blobs = blobjr.particle + blobjr.blobs; + blobjr.particle = ""; + } b = txt_esc(blobjr.blobs); var blen = b.length; if (!state.tmp.suppress_decorations) { @@ -5509,20 +5513,30 @@ CSL.getAmbiguousCite = function (Item, disambig, visualForm, item) { this.tmp.group_context.replace(oldTermSiblingLayer); return ret; }; -CSL.getSpliceDelimiter = function (last_collapsed, pos) { - if (last_collapsed && ! this.tmp.have_collapsed && "string" === typeof this.citation.opt["after-collapse-delimiter"]) { - this.tmp.splice_delimiter = this.citation.opt["after-collapse-delimiter"]; +CSL.getSpliceDelimiter = function (last_locator, last_collapsed, pos) { + if (undefined !== this.citation.opt["after-collapse-delimiter"]) { + if (last_locator) { + this.tmp.splice_delimiter = this.citation.opt["after-collapse-delimiter"]; + } else if (last_collapsed && !this.tmp.have_collapsed) { + this.tmp.splice_delimiter = this.citation.opt["after-collapse-delimiter"]; + } else if (!last_collapsed && !this.tmp.have_collapsed && this.citation.opt.collapse !== "year-suffix") { + this.tmp.splice_delimiter = this.citation.opt["after-collapse-delimiter"]; + } else { + this.tmp.splice_delimiter = this.citation.opt.layout_delimiter; + } } else if (this.tmp.use_cite_group_delimiter) { this.tmp.splice_delimiter = this.citation.opt.cite_group_delimiter; - } else if (this.tmp.have_collapsed && this.opt.xclass === "in-text" && this.opt.update_mode !== CSL.NUMERIC) { - this.tmp.splice_delimiter = ", "; - } else if (this.tmp.cite_locales[pos - 1]) { - var alt_affixes = this.tmp.cite_affixes[this.tmp.area][this.tmp.cite_locales[pos - 1]]; - if (alt_affixes && alt_affixes.delimiter) { - this.tmp.splice_delimiter = alt_affixes.delimiter; + } else { + if (this.tmp.have_collapsed && this.opt.xclass === "in-text" && this.opt.update_mode !== CSL.NUMERIC) { + this.tmp.splice_delimiter = ", "; + } else if (this.tmp.cite_locales[pos - 1]) { + var alt_affixes = this.tmp.cite_affixes[this.tmp.area][this.tmp.cite_locales[pos - 1]]; + if (alt_affixes && alt_affixes.delimiter) { + this.tmp.splice_delimiter = alt_affixes.delimiter; + } + } else if (!this.tmp.splice_delimiter) { + this.tmp.splice_delimiter = ""; } - } else if (!this.tmp.splice_delimiter) { - this.tmp.splice_delimiter = ""; } return this.tmp.splice_delimiter; }; @@ -5603,6 +5617,10 @@ CSL.getCitationCluster = function (inputList, citationID) { item = inputList[pos][1]; item = CSL.parseLocator.call(this, item); last_collapsed = this.tmp.have_collapsed; + var last_locator = false; + if (pos > 0 && inputList[pos-1][1]) { + last_locator = !!inputList[pos-1][1].locator; + } params = {}; this.tmp.shadow_numbers = {}; if (!this.tmp.just_looking && this.opt.hasPlaceholderTerm) { @@ -5633,7 +5651,7 @@ CSL.getCitationCluster = function (inputList, citationID) { if (pos === (inputList.length - 1)) { this.parallel.ComposeSet(); } - params.splice_delimiter = CSL.getSpliceDelimiter.call(this, last_collapsed, pos); + params.splice_delimiter = CSL.getSpliceDelimiter.call(this, last_locator, last_collapsed, pos); if (item && item["author-only"]) { this.tmp.suppress_decorations = true; } @@ -5768,9 +5786,6 @@ CSL.getCitationCluster = function (inputList, citationID) { if (buffer.length) { if ("string" === typeof buffer[0]) { if (pos > 0) { - if (((myblobs.length-1) > pos && myparams[pos+1].have_collapsed) && !myparams[pos].have_collapsed) { - this.tmp.splice_delimiter = myparams[pos-1].splice_delimiter; - } buffer[0] = txt_esc(this.tmp.splice_delimiter) + buffer[0]; } } else { @@ -13089,8 +13104,8 @@ CSL.Engine.prototype.dateParseArray = function (date_obj) { exts = ["", "_end"]; for (var i = 0, ilen = dp.length; i < ilen; i += 1) { for (var j = 0, jlen = CSL.DATE_PARTS.length; j < jlen; j += 1) { - if ("undefined" === typeof dp[i][j]) { - ret[(CSL.DATE_PARTS[j] + exts[i])] = dp[i][j]; + if (isNaN(parseInt(dp[i][j], 10))) { + ret[(CSL.DATE_PARTS[j] + exts[i])] = undefined; } else { ret[(CSL.DATE_PARTS[j] + exts[i])] = parseInt(dp[i][j], 10); } @@ -13911,9 +13926,9 @@ CSL.Engine.prototype.processNumber = function (node, ItemObject, variable, type) info.plural = 0; info.labelVisibility = false; } - var m = val.match(/^([a-zA-Z0]*)([0-9]+(?:[a-zA-Z]*|[-,a-zA-Z]+))$/); + var m = val.match(/^([0-9]*[a-zA-Z]+0*)?([0-9]+(?:[a-zA-Z]*|[-,a-zA-Z]+))$/); if (m) { - info.particle = m[1]; + info.particle = m[1] ? m[1] : ""; info.value = m[2]; } else { info.particle = ""; @@ -13953,9 +13968,9 @@ CSL.Engine.prototype.processNumber = function (node, ItemObject, variable, type) var label = defaultLabel; var origLabel = ""; for (var i=0,ilen=elems.length;i0;j--) { if (lst[j-1] && (!lst[j].match(/^[0-9]+([-;,:a-zA-Z]*)$/) || !lst[j-1].match(/^[0-9]+([-;,:a-zA-Z]*)$/))) { lst[j-1] = lst[j-1] + m[j-1] + lst[j]; @@ -14035,75 +14050,76 @@ CSL.Engine.prototype.processNumber = function (node, ItemObject, variable, type) if ((mVal && mVal[1]) || (mCurrentLabel && mCurrentLabel[1])) { currentLabelInfo.collapsible = false; } - var isCollapsible = currentLabelInfo.collapsible; - if (!isCollapsible) { - if (i>0 && val.match(/^[ivxlcmIVXLCM]+$/) && values[i-1].value.match(/^[ivxlcmIVXLCM]+$/)) { - isCollapsible = true; - } else if (i>0 && val.match(/^[0-9]+(?:\s|$)/) && values[i-1].value.match(/^[0-9]+(?:\s|$)/)) { - isCollapsible = true; + if (undefined === values[i].collapsible) { + for (var j=i,jlen=i+currentLabelInfo.count;j 1 && isCollapsible) { + var isCollapsible = currentLabelInfo.collapsible; + for (var j=currentLabelInfo.pos,jlen=(currentLabelInfo.pos + currentLabelInfo.count); j 1 && isCollapsible) { values[j].plural = 1; } values[j].numeric = currentLabelInfo.numeric; values[j].collapsible = currentLabelInfo.collapsible; } - currentLabelInfo.label = values[i].label; - currentLabelInfo.count = 1; - currentLabelInfo.pos = i; - currentLabelInfo.numeric = true; - currentLabelInfo.collapsible = true; } - function setPluralsAndNumerics(values) { - var currentLabelInfo = { - label: null, - count: 1, - numeric: true, - collapsible: true, - pos: 0 - } - var masterLabel = values.length ? values[0].label : null; - for (var i=0,ilen=values.length;i 1) { values[0].plural = 1; } } - for (var i=0,ilen=values.length;i