From 30f7ef093a82b16f96bb21f65fa7057795a4cceb Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Mon, 26 Sep 2016 01:08:52 -0400 Subject: [PATCH 1/2] Remove Extra field parsing when generating CSL JSON Now done by the processor in 1.1.133 (#1099) --- chrome/content/zotero/xpcom/utilities.js | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/chrome/content/zotero/xpcom/utilities.js b/chrome/content/zotero/xpcom/utilities.js index a764ec3f0a..6bfc22458f 100644 --- a/chrome/content/zotero/xpcom/utilities.js +++ b/chrome/content/zotero/xpcom/utilities.js @@ -1627,17 +1627,6 @@ Zotero.Utilities = { cslItem.title = Zotero.Notes.noteToTitle(zoteroItem.note); } - // extract PMID - var extra = zoteroItem.extra; - if(typeof extra === "string") { - var m = /(?:^|\n)PMID:\s*([0-9]+)/.exec(extra); - if(m) cslItem.PMID = m[1]; - m = /(?:^|\n)PMCID:\s*((?:PMC)?[0-9]+)/.exec(extra); - if(m) cslItem.PMCID = m[1]; - m = /(?:^|\n)DOI:\s*(10\.[0-9]{4,}\/[^\s]*[^\s\.,])/.exec(extra); - if(m) cslItem.DOI = m[1]; - } - //this._cache[zoteroItem.id] = cslItem; return cslItem; }, From e0b96a873bc6c8e77f37cd156e2baadcf1516c26 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Mon, 26 Sep 2016 14:02:09 -0400 Subject: [PATCH 2/2] Update citeproc-js to 1.1.136 --- chrome/content/zotero/xpcom/citeproc.js | 95 ++++++++++++++++--------- 1 file changed, 63 insertions(+), 32 deletions(-) diff --git a/chrome/content/zotero/xpcom/citeproc.js b/chrome/content/zotero/xpcom/citeproc.js index 7a70efe011..180287a83b 100644 --- a/chrome/content/zotero/xpcom/citeproc.js +++ b/chrome/content/zotero/xpcom/citeproc.js @@ -23,7 +23,7 @@ * respectively. */ var CSL = { - PROCESSOR_VERSION: "1.1.133", + PROCESSOR_VERSION: "1.1.136", CONDITION_LEVEL_TOP: 1, CONDITION_LEVEL_BOTTOM: 2, PLAIN_HYPHEN_REGEX: /(?:[^\\]-|\u2013)/, @@ -227,35 +227,58 @@ var CSL = { } return lst.join("-"); }, - parseNoteFieldHacks: function(Item, validFieldsForType) { + parseNoteFieldHacks: function(Item, allowDateOverride) { 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);i0 || j>1) && !elems[j-1].match(CSL.NOTE_FIELD_REGEXP)) { + break + } else { + elems[j] = '\n' + elems[j].slice(2,-1).trim() + '\n'; + } + } + lines[i] = elems.join(''); } - elems.push(splt[splt.length-1]) - for (var i=1,ilen=elems.length;i -1) { + if (key === "type") { + Item.type = val; + lines[i] = ""; + } else if (CSL.DATE_VARIABLES.indexOf(key) > -1) { + if (allowDateOverride) { Item[key] = {raw: val}; - } else if (CSL.NAME_VARIABLES.indexOf(key) > -1) { + lines[i] = ""; + } + } else if (!Item[key]) { + if (CSL.NAME_VARIABLES.indexOf(key) > -1) { if (!names[key]) { names[key] = []; } @@ -270,16 +293,13 @@ var CSL = { } else { Item[key] = val; } - elems[i] = ""; + lines[i] = ""; } - if (name === "type") { - Item.type = val; - } - Item.note = elems.join(""); } for (var key in names) { Item[key] = names[key]; } + Item.note = lines.join("").trim(); }, GENDERS: ["masculine", "feminine"], ERROR_NO_RENDERED_FORM: 1, @@ -2820,7 +2840,7 @@ CSL.Engine.prototype.retrieveItem = function (id) { } } if (this.opt.development_extensions.field_hack && Item.note) { - CSL.parseNoteFieldHacks(Item); + CSL.parseNoteFieldHacks(Item, this.opt.development_extensions.allow_field_hack_date_override); } for (var i = 1, ilen = CSL.DATE_VARIABLES.length; i < ilen; i += 1) { var dateobj = Item[CSL.DATE_VARIABLES[i]]; @@ -4471,6 +4491,7 @@ CSL.Engine.Opt = function () { this.has_layout_locale = false; this.development_extensions = {}; this.development_extensions.field_hack = true; + this.development_extensions.allow_field_hack_date_override = true; this.development_extensions.locator_date_and_revision = true; this.development_extensions.locator_parsing_for_plurals = true; this.development_extensions.locator_label_parse = true; @@ -13914,11 +13935,21 @@ CSL.Util.outputNumericField = function(state, varname, itemID) { var lastLabelName = null; for (var i=0,ilen=nums.length;i