From 5e6b763623d4041ac32830b123b9376ba5c59084 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sat, 16 Apr 2016 02:44:33 -0400 Subject: [PATCH] Update citeproc-js to 1.1.96 --- chrome/content/zotero/xpcom/citeproc.js | 89 ++++++++++++++++--------- 1 file changed, 58 insertions(+), 31 deletions(-) diff --git a/chrome/content/zotero/xpcom/citeproc.js b/chrome/content/zotero/xpcom/citeproc.js index 05d0e04c90..7c52788360 100644 --- a/chrome/content/zotero/xpcom/citeproc.js +++ b/chrome/content/zotero/xpcom/citeproc.js @@ -34,7 +34,7 @@ if (!Array.indexOf) { }; } var CSL = { - PROCESSOR_VERSION: "1.1.91", + PROCESSOR_VERSION: "1.1.96", CONDITION_LEVEL_TOP: 1, CONDITION_LEVEL_BOTTOM: 2, PLAIN_HYPHEN_REGEX: /(?:[^\\]-|\u2013)/, @@ -120,7 +120,9 @@ var CSL = { "vol": "volume" }, MODULE_MACROS: { + "juris-pretitle": true, "juris-title": true, + "juris-pretitle-short": true, "juris-title-short": true, "juris-main": true, "juris-main-short": true, @@ -204,6 +206,55 @@ var CSL = { this["container-phrase"] = {}; this["title-phrase"] = {}; }, + parseNoteFieldHacks: function(Item, validFieldsForType) { + if ("string" !== typeof Item.note) return; + var elems = []; + var m = Item.note.match(CSL.NOTE_FIELDS_REGEXP); + if (m) { + var splt = Item.note.split(CSL.NOTE_FIELDS_REGEXP); + for (var i=0,ilen=(splt.length-1);i -1) { + Item[key] = {raw: val}; + elems[i] = ""; + } else { + Item[key] = val; + } + } else if (CSL.NAME_VARIABLES.indexOf(key) > -1) { + if (!names[key]) { + names[key] = []; + } + var lst = val.split(/\s*\|\|\s*/); + if (lst.length === 1) { + names[key].push({family:lst[0],isInstitution:true}); + } else if (lst.length === 2) { + var name = {family:lst[0],given:lst[1]}; + CSL.parseParticles(name); + names[key].push(name); + } + elems[i] = ""; + } + } + if (name === "type") { + Item.type = val; + } + Item.note = elems.join(""); + } + for (var key in names) { + Item[key] = names[key]; + } + } + }, GENDERS: ["masculine", "feminine"], ERROR_NO_RENDERED_FORM: 1, PREVIEW: "Just for laughs.", @@ -1099,7 +1150,7 @@ CSL.parseXml = function(str) { var _obj = {children:[]}; var _stack = [_obj.children]; function _listifyString(str) { - str = str.split("\n").join(" ").replace(/>[ ]+<").replace(/<\!--.*?-->/g, ""); + str = str.split(/(?:\r\n|\n|\r)/).join(" ").replace(/>[ ]+<").replace(/<\!--.*?-->/g, ""); var lst = str.split("><"); var stylePos = null; for (var i=0,ilen=lst.length;i -1) { - Item[mm[1]] = {raw:mm[2]}; - } else if (!Item[mm[1]] && CSL.NAME_VARIABLES.indexOf(mm[1]) > -1) { - if (!names[mm[1]]) { - names[mm[1]] = []; - } - var lst = mm[2].split(/\s*\|\|\s*/); - if (lst.length === 1) { - names[mm[1]].push({family:lst[0],isInstitution:true}); - } else if (lst.length === 2) { - var name = {family:lst[0],given:lst[1]}; - CSL.parseParticles(name); - names[mm[1]].push(name); - } - } else if (!Item[mm[1]] || mm[1] === "type") { - Item[mm[1]] = mm[2].replace(/^\s+/, "").replace(/\s+$/, ""); - } - Item.note.replace(CSL.NOTE_FIELD_REGEXP, ""); - } - for (var key in names) { - Item[key] = names[key]; - } - } + CSL.parseNoteFieldHacks(Item); } for (var i = 1, ilen = CSL.DATE_VARIABLES.length; i < ilen; i += 1) { var dateobj = Item[CSL.DATE_VARIABLES[i]]; @@ -11892,7 +11916,9 @@ CSL.Transform = function (state) { if (ret.name && !jurisdictionName) { jurisdictionName = state.sys.getHumanForm(Item[field]); } - ret.name = CSL.getSuppressedJurisdictionName.call(state, Item[field], jurisdictionName); + if (jurisdictionName) { + ret.name = CSL.getSuppressedJurisdictionName.call(state, Item[field], jurisdictionName); + } } return ret; } @@ -13205,6 +13231,7 @@ CSL.Engine.prototype.processNumber = function (node, ItemObject, variable, type) var debug = false; var me = this; function normalizeFieldValue(str, defaultLabel) { + str = str.trim(); var m = str.match(/^([^ ]+)/); if (m && !CSL.STATUTE_SUBDIV_STRINGS[m[1]]) { var embeddedLabel = null;