Update citeproc-js to 1.1.96

This commit is contained in:
Dan Stillman 2016-04-16 02:44:33 -04:00
parent 9330b9cd40
commit 5e6b763623

View file

@ -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<ilen;i++) {
elems.push(splt[i]);
elems.push(m[i]);
}
elems.push(splt[splt.length-1])
var names = {};
for (var i=1,ilen=elems.length;i<ilen;i+=2) {
var mm = elems[i].match(CSL.NOTE_FIELD_REGEXP);
var key = mm[1];
var val = mm[2].replace(/^\s+/, "").replace(/\s+$/, "");
if (!Item[key]) {
if (!validFieldsForType || validFieldsForType[key]) {
if (CSL.DATE_VARIABLES.indexOf(key) > -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(/>[ ]+</g, "><").replace(/<\!--.*?-->/g, "");
str = str.split(/(?:\r\n|\n|\r)/).join(" ").replace(/>[ ]+</g, "><").replace(/<\!--.*?-->/g, "");
var lst = str.split("><");
var stylePos = null;
for (var i=0,ilen=lst.length;i<ilen;i++) {
@ -2727,34 +2778,7 @@ CSL.Engine.prototype.retrieveItem = function (id) {
}
}
if (this.opt.development_extensions.field_hack && Item.note) {
m = Item.note.match(CSL.NOTE_FIELDS_REGEXP);
if (m) {
var names = {};
for (pos = 0, len = m.length; pos < len; pos += 1) {
mm = m[pos].match(CSL.NOTE_FIELD_REGEXP);
if (!Item[mm[1]] && CSL.DATE_VARIABLES.indexOf(mm[1]) > -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;