From 4861b2e8410cf24f446e43e54d971be98d926247 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sat, 19 Jan 2019 02:38:56 -0500 Subject: [PATCH] Update citeproc-js to 1.1.212 --- chrome/content/zotero/xpcom/citeproc.js | 303 +++++++++++++++++++++--- 1 file changed, 273 insertions(+), 30 deletions(-) diff --git a/chrome/content/zotero/xpcom/citeproc.js b/chrome/content/zotero/xpcom/citeproc.js index 360ac0447d..59fa7826e9 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.210", + PROCESSOR_VERSION: "1.1.212", CONDITION_LEVEL_TOP: 1, CONDITION_LEVEL_BOTTOM: 2, PLAIN_HYPHEN_REGEX: /(?:[^\\]-|\u2013)/, @@ -171,7 +171,7 @@ var CSL = { "genre":"titles", "medium":"titles", "container-title":"journals", - "collection-title":"journals", + "collection-title":"titles", "archive":"journals", "publisher":"publishers", "authority":"publishers", @@ -179,10 +179,10 @@ var CSL = { "event-place": "places", "archive-place": "places", "jurisdiction": "places", - "number": "number", - "edition":"number", - "issue":"number", - "volume":"number" + "number": "places", + "edition":"places", + "issue":"places", + "volume":"places" }, AbbreviationSegments: function () { this["container-title"] = {}; @@ -489,6 +489,21 @@ var CSL = { "reviewed-author", "translator" ], + CREATORS: [ + "author", + "collection-editor", + "composer", + "container-author", + "director", + "editor", + "editorial-director", + "illustrator", + "interviewer", + "original-author", + "recipient", + "reviewed-author", + "translator" + ], NUMERIC_VARIABLES: [ "call-number", "chapter-number", @@ -750,7 +765,7 @@ var CSL = { "sv-SE":"Swedish", "th-TH":"Thai", "tr-TR":"Turkish", - "uk-UA":"Ukranian", + "uk-UA":"Ukrainian", "vi-VN":"Vietnamese", "zh-CN":"Chinese (CN)", "zh-TW":"Chinese (TW)" @@ -7753,6 +7768,9 @@ CSL.Node.label = { }; this.execs.push(func); } else { + if (!this.strings.form) { + this.strings.form = "long"; + } var namevars = state.build.names_variables.slice(-1)[0]; if (!state.build.name_label) { state.build.name_label = {}; @@ -10215,6 +10233,7 @@ CSL.Node.names = { } if (this.tokentype === CSL.START) { state.build.names_flag = true; + state.build.name_flag = false; state.build.names_level += 1; if (state.build.names_level === 1) { state.build.names_variables = []; @@ -10648,7 +10667,7 @@ CSL.Node.text = { var transfall = false; if (form === "short" || ["country", "jurisdiction"].indexOf(this.variables_real[0]) > -1) { if (this.variables_real[0] === "container-title") { - altvar = "journalAbbreviation"; + altvar = "container-title-short"; } else if (this.variables_real[0] === "title") { altvar = "title-short"; } @@ -10687,20 +10706,22 @@ CSL.Node.text = { if (value) { if (state.opt.development_extensions.wrap_url_and_doi) { if (!this.decorations.length || this.decorations[0][0] !== "@" + this.variables[0]) { - if (this.variables_real[0] === "DOI" && this.strings.prefix === "https://doi.org/") { + if (this.variables_real[0] === "DOI") { var clonetoken = CSL.Util.cloneToken(this); var groupblob = new CSL.Blob(null, null, "url-wrapper"); groupblob.decorations.push(["@DOI", "true"]); - value = value.replace(/^https?:\/\/doi\.org\//, ""); var prefix; - if (value.match(/^https?:\/\//)) { - prefix = ""; - } else { - prefix = "https://doi.org/"; + if (this.strings.prefix && this.strings.prefix.match(/^.*https:\/\/doi\.org\/$/)) { + value = value.replace(/^https?:\/\/doi\.org\//, ""); + if (value.match(/^https?:\/\//)) { + prefix = ""; + } else { + prefix = "https://doi.org/"; + } + clonetoken.strings.prefix = this.strings.prefix.slice(0, clonetoken.strings.prefix.length-16); } var prefixblob = new CSL.Blob(prefix); var valueblob = new CSL.Blob(value); - clonetoken.strings.prefix = ""; groupblob.push(prefixblob); groupblob.push(valueblob); state.output.append(groupblob, clonetoken, false, false, true); @@ -11023,7 +11044,7 @@ CSL.Attributes["@variable"] = function (state, arg) { if (variable === "title") { variable = "title-short"; } else if (variable === "container-title") { - variable = "journalAbbreviation"; + variable = "container-title-short"; } } if (variable === "year-suffix") { @@ -13984,12 +14005,22 @@ CSL.Engine.prototype.processNumber = function (node, ItemObject, variable, type) var m = str.match(/(;\s+|,\s+|\s*\\*[\-\u2013]+\s*|\s*&\s*)/g); if (m) { var lst = str.split(/(?:;\s+|,\s+|\s*\\*[\-\u2013]+\s*|\s*&\s*)/); - for (var i=0,ilen=lst.length-1; i -1) { - rangeDelimiter = me.getTerm("page-range-delimiter") + rangeDelimiter = me.getTerm("page-range-delimiter"); if (!rangeDelimiter) { rangeDelimiter = "\u2013"; } @@ -14243,7 +14274,7 @@ CSL.Engine.prototype.processNumber = function (node, ItemObject, variable, type) currentInfo.count = 1; return; } - if (!me.opt["page-range-format"] && parseInt(values[i-1].value, 10) > parseInt(values[i].value, 10)) { + if (!me.opt["page-range-format"] && (parseInt(values[i-1].value, 10) > parseInt(values[i].value, 10))) { values[i-1].joiningSuffix = fixupRangeDelimiter(variable, values[i], values[i-1].joiningSuffix, true); return; } @@ -14259,7 +14290,7 @@ CSL.Engine.prototype.processNumber = function (node, ItemObject, variable, type) } str = values[i-1].value + stripHyphenBackslash(values[i-1].joiningSuffix) + values[i].value; } - var m = str.match(/^((?:[0-9]*[a-zA-Z]+0*))?([0-9]+)(\s*[^0-9]+\s*)([-,a-zA-Z]?0*)([0-9]+)$/); + var m = str.match(/^((?:[0-9]*[a-zA-Z]+0*))?([0-9]+[a-z]*)(\s*[^0-9]+\s*)([-,a-zA-Z]?0*)([0-9]+[a-z]*)$/); if (m) { var rangeDelimiter = m[3]; rangeDelimiter = fixupRangeDelimiter(variable, val, rangeDelimiter, values[i].numeric); @@ -14462,7 +14493,7 @@ CSL.Util.PageRangeMangler = {}; CSL.Util.PageRangeMangler.getFunction = function (state, rangeType) { var rangerex, pos, len, stringify, listify, expand, minimize, minimize_internal, chicago, lst, m, b, e, ret, begin, end, ret_func, ppos, llen; var range_delimiter = state.getTerm(rangeType + "-range-delimiter"); - rangerex = /([0-9]*[a-zA-Z]+0*)?([0-9]+)\s*(?:\u2013|-)\s*([0-9]*[a-zA-Z]+0*)?([0-9]+)/; + rangerex = /([0-9]*[a-zA-Z]+0*)?([0-9]+[a-z]*)\s*(?:\u2013|-)\s*([0-9]*[a-zA-Z]+0*)?([0-9]+[a-z]*)/; stringify = function (lst) { len = lst.length; for (pos = 1; pos < len; pos += 2) { @@ -14480,8 +14511,8 @@ CSL.Util.PageRangeMangler.getFunction = function (state, rangeType) { var this_range_delimiter = range_delimiter === "-" ? "" : range_delimiter; var delimRex = new RegExp("([^\\\\])[-" + this_range_delimiter + "\\u2013]", "g"); str = str.replace(delimRex, "$1 - ").replace(/\s+-\s+/g, " - "); - var rexm = new RegExp("((?:[0-9]*[a-zA-Z]+0*)?[0-9]+" + hyphens + "(?:[0-9]*[a-zA-Z]+0*)?[0-9]+)", "g"); - var rexlst = new RegExp("(?:[0-9]*[a-zA-Z]+0*)?[0-9]+" + hyphens + "(?:[0-9]*[a-zA-Z]+0*)?[0-9]+"); + var rexm = new RegExp("((?:[0-9]*[a-zA-Z]+0*)?[0-9]+[a-z]*" + hyphens + "(?:[0-9]*[a-zA-Z]+0*)?[0-9]+[a-z]*)", "g"); + var rexlst = new RegExp("(?:[0-9]*[a-zA-Z]+0*)?[0-9]+[a-z]*" + hyphens + "(?:[0-9]*[a-zA-Z]+0*)?[0-9]+[a-z]*"); m = str.match(rexm); lst = str.split(rexlst); if (lst.length === 0) { @@ -15169,7 +15200,10 @@ CSL.Output.Formatters = new function () { var _tagParams = { "": "", "": "", - "": "" + "": "", + "": "", + "": "", + "": "" } function _capitalise (word, force) { var m = word.match(/(^\s*)((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]))(.*)/); @@ -15294,8 +15328,11 @@ CSL.Output.Formatters = new function () { } if (config.lastWordPos) { var lastWords = wordDoppel.split(config.doppel.strings[config.lastWordPos.strings]); - var lastWord = _capitalise(lastWords.strings[config.lastWordPos.words]); - lastWords.strings[config.lastWordPos.words] = lastWord; + var lastWord = lastWords.strings[config.lastWordPos.words]; + if (lastWord.length > 1 && lastWord.toLowerCase().match(config.skipWordsRex)) { + lastWord = _capitalise(lastWord); + lastWords.strings[config.lastWordPos.words] = lastWord; + } config.doppel.strings[config.lastWordPos.strings] = wordDoppel.join(lastWords); } return tagDoppel.join(config.doppel); @@ -15707,6 +15744,212 @@ CSL.Output.Formats.prototype.rtf = { return str; } }; +CSL.Output.Formats.prototype.asciidoc = { + "text_escape": function (text) { + if (!text) { + text = ""; + } + return text.replace("*", "pass:[*]", "g") + .replace("_", "pass:[_]", "g") + .replace("#", "pass:[#]", "g") + .replace("^", "pass:[^]", "g") + .replace("~", "pass:[~]", "g") + .replace("[[", "pass:[[[]", "g") + .replace(" ", "  ", "g") + .replace(CSL.SUPERSCRIPTS_REGEXP, function(aChar) { + return "^" + CSL.SUPERSCRIPTS[aChar] + "^"; + }); + }, + "bibstart": "", + "bibend": "", + "@passthrough/true": CSL.Output.Formatters.passthrough, + "@font-style/italic": "__%%STRING%%__", + "@font-style/oblique": "__%%STRING%%__", + "@font-style/normal": false, + "@font-variant/small-caps": "[small-caps]#%%STRING%%#", + "@font-variant/normal": false, + "@font-weight/bold": "**%%STRING%%**", + "@font-weight/normal": false, + "@font-weight/light": false, + "@text-decoration/none": false, + "@text-decoration/underline": "[underline]##%%STRING%%##", + "@vertical-align/sup": "^^%%STRING%%^^", + "@vertical-align/sub": "~~%%STRING%%~~", + "@vertical-align/baseline": false, + "@strip-periods/true": CSL.Output.Formatters.passthrough, + "@strip-periods/false": CSL.Output.Formatters.passthrough, + "@quotes/true": function (state, str) { + if ("undefined" === typeof str) { + return "``"; + } + return "``" + str + "''"; + }, + "@quotes/inner": function (state, str) { + if ("undefined" === typeof str) { + return "`"; + } + return "`" + str + "'"; + }, + "@quotes/false": false, + "@cite/entry": function (state, str) { + return state.sys.wrapCitationEntry(str, this.item_id, this.locator_txt, this.suffix_txt); + }, + "@bibliography/entry": function (state, str) { + return str + "\n"; + }, + "@display/block": function (state, str) { + return str; + }, + "@display/left-margin": function (state, str) { + return str; + }, + "@display/right-inline": function (state, str) { + return " " + str; + }, + "@display/indent": function (state, str) { + return " " + str; + }, + "@showid/true": function (state, str, cslid) { + if (!state.tmp.just_looking && !state.tmp.suppress_decorations && this.params && "string" === typeof str) { + var prePunct = ""; + if (str) { + var m = str.match(CSL.VARIABLE_WRAPPER_PREPUNCT_REX); + prePunct = m[1]; + str = m[2]; + } + var postPunct = ""; + if (str && CSL.SWAPPING_PUNCTUATION.indexOf(str.slice(-1)) > -1) { + postPunct = str.slice(-1); + str = str.slice(0,-1); + } + return state.sys.variableWrapper(this.params, prePunct, str, postPunct); + } else { + return str; + } + }, + "@URL/true": function (state, str) { + return str; + }, + "@DOI/true": function (state, str) { + var doiurl = str; + if (!str.match(/^https?:\/\//)) { + doiurl = "https://doi.org/" + str; + } + return doiurl + "[" + str + "]"; + } +}; +CSL.Output.Formats.prototype.fo = { + "text_escape": function (text) { + if (!text) { + text = ""; + } + return text.replace(/&/g, "&") + .replace(//g, ">") + .replace(" ", "  ", "g") + .replace(CSL.SUPERSCRIPTS_REGEXP, function(aChar) { + return "" + CSL.SUPERSCRIPTS[aChar] + ""; + }); + }, + "bibstart": "", + "bibend": "", + "@passthrough/true": CSL.Output.Formatters.passthrough, + "@font-style/italic": "%%STRING%%", + "@font-style/oblique": "%%STRING%%", + "@font-style/normal": "%%STRING%%", + "@font-variant/small-caps": "%%STRING%%", + "@font-variant/normal": "%%STRING%%", + "@font-weight/bold": "%%STRING%%", + "@font-weight/normal": "%%STRING%%", + "@font-weight/light": "%%STRING%%", + "@text-decoration/none": "%%STRING%%", + "@text-decoration/underline": "%%STRING%%", + "@vertical-align/sup": "%%STRING%%", + "@vertical-align/sub": "%%STRING%%", + "@vertical-align/baseline": "%%STRING%%", + "@strip-periods/true": CSL.Output.Formatters.passthrough, + "@strip-periods/false": CSL.Output.Formatters.passthrough, + "@quotes/true": function (state, str) { + if ("undefined" === typeof str) { + return state.getTerm("open-quote"); + } + return state.getTerm("open-quote") + str + state.getTerm("close-quote"); + }, + "@quotes/inner": function (state, str) { + if ("undefined" === typeof str) { + return "\u2019"; + } + return state.getTerm("open-inner-quote") + str + state.getTerm("close-inner-quote"); + }, + "@quotes/false": false, + "@cite/entry": function (state, str) { + return state.sys.wrapCitationEntry(str, this.item_id, this.locator_txt, this.suffix_txt); + }, + "@bibliography/entry": function (state, str) { + var indent = ""; + if (state.bibliography && state.bibliography.opt && state.bibliography.opt.hangingindent) { + var hi = state.bibliography.opt.hangingindent; + indent = " start-indent=\"" + hi +"em\" text-indent=\"-" + hi + "em\""; + } + var insert = ""; + if (state.sys.embedBibliographyEntry) { + insert = state.sys.embedBibliographyEntry(this.item_id) + "\n"; + } + return "" + str + "\n" + insert; + }, + "@display/block": function (state, str) { + return "\n " + str + "\n"; + }, + "@display/left-margin": function (state, str) { + return "\n \n " + + "\n " + + "\n " + + "\n " + + "\n " + + "\n " + + "" + str + "\n " + + "\n "; + }, + "@display/right-inline": function (state, str) { + return "\n " + + "" + str + "\n " + + "\n " + + "\n " + + "\n " + + "\n"; + }, + "@display/indent": function (state, str) { + return "" + str + "\n"; + }, + "@showid/true": function (state, str, cslid) { + if (!state.tmp.just_looking && !state.tmp.suppress_decorations && this.params && "string" === typeof str) { + var prePunct = ""; + if (str) { + var m = str.match(CSL.VARIABLE_WRAPPER_PREPUNCT_REX); + prePunct = m[1]; + str = m[2]; + } + var postPunct = ""; + if (str && CSL.SWAPPING_PUNCTUATION.indexOf(str.slice(-1)) > -1) { + postPunct = str.slice(-1); + str = str.slice(0,-1); + } + return state.sys.variableWrapper(this.params, prePunct, str, postPunct); + } else { + return str; + } + }, + "@URL/true": function (state, str) { + return "" + str + ""; + }, + "@DOI/true": function (state, str) { + var doiurl = str; + if (!str.match(/^https?:\/\//)) { + doiurl = "https://doi.org/" + str; + } + return "" + str + ""; + } +}; CSL.Output.Formats = new CSL.Output.Formats(); CSL.Registry = function (state) { var pos, len, ret, i, ilen;