Update citeproc-js to 1.1.130
This commit is contained in:
parent
9101cb487f
commit
c8dbe26abe
1 changed files with 96 additions and 16 deletions
|
@ -23,7 +23,7 @@
|
|||
* <http://www.gnu.org/licenses/> respectively.
|
||||
*/
|
||||
var CSL = {
|
||||
PROCESSOR_VERSION: "1.1.121",
|
||||
PROCESSOR_VERSION: "1.1.130",
|
||||
CONDITION_LEVEL_TOP: 1,
|
||||
CONDITION_LEVEL_BOTTOM: 2,
|
||||
PLAIN_HYPHEN_REGEX: /(?:[^\\]-|\u2013)/,
|
||||
|
@ -776,7 +776,6 @@ var CSL = {
|
|||
};
|
||||
if (typeof require !== "undefined" && typeof module !== 'undefined' && "exports" in module) {
|
||||
var CSL_IS_NODEJS = true;
|
||||
var CSL_NODEJS = require("./csl_nodejs_jsdom").CSL_NODEJS_JSDOM;
|
||||
exports.CSL = CSL;
|
||||
}
|
||||
CSL.TERMINAL_PUNCTUATION_REGEXP = new RegExp("^([" + CSL.TERMINAL_PUNCTUATION.slice(0, -1).join("") + "])(.*)");
|
||||
|
@ -2729,6 +2728,11 @@ CSL.Engine.prototype.retrieveItems = function (ids) {
|
|||
CSL.ITERATION = 0;
|
||||
CSL.Engine.prototype.retrieveItem = function (id) {
|
||||
var Item, m, pos, len, mm;
|
||||
if (!this.tmp.loadedItemIDs[id]) {
|
||||
this.tmp.loadedItemIDs[id] = true;
|
||||
} else {
|
||||
return this.registry.refhash[id];
|
||||
}
|
||||
if (this.opt.development_extensions.normalize_lang_keys_to_lowercase &&
|
||||
"boolean" === typeof this.opt.development_extensions.normalize_lang_keys_to_lowercase) {
|
||||
for (var i=0,ilen=this.opt["default-locale"].length; i<ilen; i+=1) {
|
||||
|
@ -2743,7 +2747,7 @@ CSL.Engine.prototype.retrieveItem = function (id) {
|
|||
this.opt.development_extensions.normalize_lang_keys_to_lowercase = 100;
|
||||
}
|
||||
CSL.ITERATION += 1;
|
||||
Item = this.sys.retrieveItem("" + id);
|
||||
Item = JSON.parse(JSON.stringify(this.sys.retrieveItem("" + id)));
|
||||
if (this.opt.development_extensions.normalize_lang_keys_to_lowercase) {
|
||||
if (Item.multi) {
|
||||
if (Item.multi._keys) {
|
||||
|
@ -2906,6 +2910,7 @@ CSL.Engine.prototype.retrieveItem = function (id) {
|
|||
}
|
||||
}
|
||||
}
|
||||
this.registry.refhash[id] = Item;
|
||||
return Item;
|
||||
};
|
||||
CSL.Engine.prototype.setOpt = function (token, name, value) {
|
||||
|
@ -3649,10 +3654,15 @@ CSL.Output.Queue.prototype.string = function (state, myblobs, blob) {
|
|||
} else if (blobjr.blobs.length) {
|
||||
var addtoret = state.output.string(state, blobjr.blobs, blobjr);
|
||||
if (blob) {
|
||||
if (addtoret.length > 1
|
||||
&& "string" === typeof addtoret.slice(-1)[0]
|
||||
&& "string" !== typeof addtoret.slice(-2)[0]) {
|
||||
addtoret[addtoret.length-1] = (blobjr.strings.delimiter + addtoret.slice(-1)[0]);
|
||||
if ("string" !== addtoret && addtoret.length > 1 && blobjr.strings.delimiter) {
|
||||
var numberSeen = false;
|
||||
for (var j=0,jlen=addtoret.length;j<jlen;j++) {
|
||||
if ("string" !== typeof addtoret[j]) {
|
||||
numberSeen = true;
|
||||
} else if (numberSeen) {
|
||||
addtoret[j] = (blobjr.strings.delimiter + addtoret[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ret = ret.concat(addtoret);
|
||||
|
@ -4538,6 +4548,7 @@ CSL.Engine.Tmp = function () {
|
|||
this.strip_periods = 0;
|
||||
this.shadow_numbers = {};
|
||||
this.authority_stop_last = 0;
|
||||
this.loadedItemIDs = {};
|
||||
};
|
||||
CSL.Engine.Fun = function (state) {
|
||||
this.match = new CSL.Util.Match;
|
||||
|
@ -4645,6 +4656,8 @@ CSL.Engine.prototype.appendCitationCluster = function (citation) {
|
|||
CSL.Engine.prototype.processCitationCluster = function (citation, citationsPre, citationsPost, flag) {
|
||||
var c, i, ilen, j, jlen, k, klen, n, nlen, key, Item, item, noteCitations, textCitations, m, citationsInNote;
|
||||
this.debug = false;
|
||||
this.tmp.loadedItemIDs = {};
|
||||
citation = JSON.parse(JSON.stringify(citation));
|
||||
this.tmp.citation_errors = [];
|
||||
var return_data = {"bibchange": false};
|
||||
this.setCitationId(citation);
|
||||
|
@ -4752,7 +4765,7 @@ CSL.Engine.prototype.processCitationCluster = function (citation, citationsPre,
|
|||
}
|
||||
}
|
||||
if (flag !== CSL.ASSUME_ALL_ITEMS_REGISTERED) {
|
||||
this.updateItems(update_items);
|
||||
this.updateItems(update_items, null, null, true);
|
||||
}
|
||||
if (!this.opt.citation_number_sort && sortedItems && sortedItems.length > 1 && this.citation_sort.tokens.length > 0) {
|
||||
for (i = 0, ilen = sortedItems.length; i < ilen; i += 1) {
|
||||
|
@ -5040,7 +5053,7 @@ CSL.Engine.prototype.processCitationCluster = function (citation, citationsPre,
|
|||
for (i = 0, ilen = oldItemList.length; i < ilen; i += 1) {
|
||||
oldItemIds.push("" + oldItemList[i].id);
|
||||
}
|
||||
this.updateItems(oldItemIds);
|
||||
this.updateItems(oldItemIds, null, null, true);
|
||||
for (key in oldAmbigs) {
|
||||
if (oldAmbigs.hasOwnProperty(key)) {
|
||||
this.registry.registry[key].disambig = oldAmbigs[key];
|
||||
|
@ -5499,6 +5512,7 @@ CSL.getCite = function (Item, item, prevItemID, blockShadowNumberReset) {
|
|||
this.parallel.StartCite(Item, item, prevItemID);
|
||||
CSL.citeStart.call(this, Item, item, blockShadowNumberReset);
|
||||
next = 0;
|
||||
this.tmp.name_node = {};
|
||||
this.nameOutput = new CSL.NameOutput(this, Item, item);
|
||||
while (next < this[this.tmp.area].tokens.length) {
|
||||
next = CSL.tokenExec.call(this, this[this.tmp.area].tokens[next], Item, item);
|
||||
|
@ -5987,14 +6001,17 @@ CSL.Engine.prototype.restoreProcessorState = function (citations) {
|
|||
}
|
||||
return ret;
|
||||
};
|
||||
CSL.Engine.prototype.updateItems = function (idList, nosort, rerun_ambigs) {
|
||||
CSL.Engine.prototype.updateItems = function (idList, nosort, rerun_ambigs, implicitUpdate) {
|
||||
var debug = false;
|
||||
var oldArea = this.tmp.area;
|
||||
var oldRoot = this.tmp.root;
|
||||
var oldExtension = this.tmp.extension;
|
||||
this.tmp.area = "citation";
|
||||
this.tmp.root = "citation"
|
||||
this.tmp.extension = ""
|
||||
this.tmp.root = "citation";
|
||||
this.tmp.extension = "";
|
||||
if (!implicitUpdate) {
|
||||
this.tmp.loadedItemIDs = {};
|
||||
}
|
||||
this.registry.init(idList);
|
||||
if (rerun_ambigs) {
|
||||
for (var ambig in this.registry.ambigcites) {
|
||||
|
@ -6024,6 +6041,7 @@ CSL.Engine.prototype.updateUncitedItems = function (idList, nosort) {
|
|||
this.tmp.area = "citation";
|
||||
this.tmp.root = "citation"
|
||||
this.tmp.extension = ""
|
||||
this.tmp.loadedItemIDs = {};
|
||||
if (!idList) {
|
||||
idList = [];
|
||||
}
|
||||
|
@ -6069,7 +6087,6 @@ CSL.localeResolve = function (langstr, defaultLocale) {
|
|||
langlst = langstr.split(/[\-_]/);
|
||||
ret.base = CSL.LANG_BASES[langlst[0]];
|
||||
if ("undefined" === typeof ret.base) {
|
||||
CSL.debug("Warning: unknown locale "+langstr+", setting fallback to "+defaultLocale);
|
||||
return {base:defaultLocale, best:langstr, bare:langlst[0]};
|
||||
}
|
||||
if (langlst.length === 1) {
|
||||
|
@ -6341,6 +6358,42 @@ CSL.Engine.prototype.localeSet = function (myxml, lang_in, lang_out) {
|
|||
}
|
||||
}
|
||||
};
|
||||
CSL.getLocaleNames = function (myxml, preferredLocale) {
|
||||
var stylexml = CSL.setupXml(myxml);
|
||||
function extendLocaleList(localeList, locale) {
|
||||
var forms = ["base", "best"];
|
||||
if (locale) {
|
||||
normalizedLocale = CSL.localeResolve(locale);
|
||||
for (var i=0,ilen=forms.length;i<ilen;i++) {
|
||||
if (normalizedLocale[forms[i]] && localeList.indexOf(normalizedLocale[forms[i]]) === -1) {
|
||||
localeList.push(normalizedLocale[forms[i]]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
function sniffLocaleOnOneNodeName(nodeName) {
|
||||
var nodes = stylexml.getNodesByName(stylexml.dataObj, nodeName);
|
||||
for (var i=0,ilen=nodes.length;i<ilen;i++) {
|
||||
var nodeLocales = stylexml.getAttributeValue(nodes[i], "locale");
|
||||
if (nodeLocales) {
|
||||
nodeLocales = nodeLocales.split(/ +/);
|
||||
for (var j=0,jlen=nodeLocales.length;j<jlen;j++) {
|
||||
this.extendLocaleList(localeIDs, nodeLocales[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var localeIDs = ["en-US"];
|
||||
extendLocaleList(localeIDs, preferredLocale);
|
||||
var styleNode = stylexml.getNodesByName(stylexml.dataObj, "style")[0];
|
||||
var defaultLocale = stylexml.getAttributeValue(styleNode, "default-locale");
|
||||
extendLocaleList(localeIDs, defaultLocale);
|
||||
var nodeNames = ["layout", "if", "else-if", "condition"];
|
||||
for (var i=0,ilen=nodeNames.length;i<ilen;i++) {
|
||||
sniffLocaleOnOneNodeName(stylexml, localeIDs, nodeNames[i]);
|
||||
}
|
||||
return localeIDs;
|
||||
};
|
||||
CSL.Node = {};
|
||||
CSL.Node.bibliography = {
|
||||
build: function (state, target) {
|
||||
|
@ -11953,6 +12006,11 @@ CSL.Transform = function (state) {
|
|||
if (CSL.NUMERIC_VARIABLES.indexOf(myabbrev_family) > -1) {
|
||||
myabbrev_family = "number";
|
||||
}
|
||||
if (myabbrev_family === "jurisdiction") {
|
||||
if (state.opt.suppressedJurisdictions[Item.jurisdiction]) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
if (["publisher-place", "event-place", "jurisdiction", "archive-place", "language-name", "language-name-original"].indexOf(myabbrev_family) > -1) {
|
||||
myabbrev_family = "place";
|
||||
}
|
||||
|
@ -12554,6 +12612,15 @@ CSL.Util.fixDateNode = function (parent, pos, node) {
|
|||
this.cslXml.deleteNodeByNameAttribute(datexml, 'day');
|
||||
} else if ("year-month" === this.cslXml.getAttributeValue(node, "date-parts")) {
|
||||
this.cslXml.deleteNodeByNameAttribute(datexml, 'day');
|
||||
} else if ("month-day" === this.cslXml.getAttributeValue(node, "date-parts")) {
|
||||
var childNodes = this.cslXml.children(datexml);
|
||||
for (var i=1,ilen=childNodes.length;i<ilen;i++) {
|
||||
if (this.cslXml.getAttributeValue(childNodes[i], 'name') === "year") {
|
||||
this.cslXml.setAttribute(childNodes[i-1], "suffix", "");
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.cslXml.deleteNodeByNameAttribute(datexml, 'year');
|
||||
}
|
||||
return this.cslXml.insertChildNodeAfter(parent, node, pos, datexml);
|
||||
};
|
||||
|
@ -13488,7 +13555,14 @@ CSL.Engine.prototype.processNumber = function (node, ItemObject, variable, type)
|
|||
var m = elems[i].match(/((?:^| )(?:[a-z]|[a-z][a-z]|[a-z][a-z][a-z]|[a-z][a-z][a-z][a-z])\. *)/g);
|
||||
if (m) {
|
||||
var lst = elems[i].split(/(?:(?:^| )(?:[a-z]|[a-z][a-z]|[a-z][a-z][a-z]|[a-z][a-z][a-z][a-z])\. *)/);
|
||||
if (i === 0) {
|
||||
for (var j=lst.length-1;j>0;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];
|
||||
lst = lst.slice(0,j).concat(lst.slice(j+1))
|
||||
m = m.slice(0,j-1).concat(m.slice(j))
|
||||
}
|
||||
}
|
||||
if (m.length > 0 && i === 0) {
|
||||
var slug = m[0].trim();
|
||||
if (!CSL.STATUTE_SUBDIV_STRINGS[slug]
|
||||
|| !me.getTerm(CSL.STATUTE_SUBDIV_STRINGS[slug])
|
||||
|
@ -13759,12 +13833,16 @@ CSL.Engine.prototype.processNumber = function (node, ItemObject, variable, type)
|
|||
manglePageNumbers(values, values.length-1, currentInfo);
|
||||
}
|
||||
}
|
||||
function setVariableParams(obj, values) {
|
||||
function setVariableParams(shadow_numbers, variable, values) {
|
||||
var obj = shadow_numbers[variable];
|
||||
if (values.length) {
|
||||
obj.numeric = values[0].numeric;
|
||||
obj.collapsible = values[0].collapsible;
|
||||
obj.plural = values[0].plural;
|
||||
obj.label = CSL.STATUTE_SUBDIV_STRINGS[values[0].label];
|
||||
if (variable === "number" && obj.label === "issue" && me.getTerm("number")) {
|
||||
obj.label = "number";
|
||||
}
|
||||
}
|
||||
}
|
||||
if (node && this.tmp.shadow_numbers[variable] && this.tmp.shadow_numbers[variable].values.length) {
|
||||
|
@ -13814,7 +13892,7 @@ CSL.Engine.prototype.processNumber = function (node, ItemObject, variable, type)
|
|||
fixRanges(values);
|
||||
this.tmp.shadow_numbers[variable].masterStyling = setStyling(values)
|
||||
}
|
||||
setVariableParams(this.tmp.shadow_numbers[variable], values);
|
||||
setVariableParams(this.tmp.shadow_numbers, variable, values);
|
||||
}
|
||||
};
|
||||
CSL.Util.outputNumericField = function(state, varname, itemID) {
|
||||
|
@ -14825,6 +14903,7 @@ CSL.Registry = function (state) {
|
|||
this.state = state;
|
||||
this.registry = {};
|
||||
this.reflist = [];
|
||||
this.refhash = {};
|
||||
this.namereg = new CSL.Registry.NameReg(state);
|
||||
this.citationreg = new CSL.Registry.CitationReg(state);
|
||||
this.authorstrings = {};
|
||||
|
@ -14959,6 +15038,7 @@ CSL.Registry.prototype.dodeletes = function (myhash) {
|
|||
}
|
||||
}
|
||||
delete this.registry[key];
|
||||
delete this.refhash[key];
|
||||
this.return_data.bibchange = true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue