Merge citeproc-js 1.0.57
From Frank's release notes: citeproc-js 1.0.54: - Fix misplacement of labels that (should) appear before the nameset to which they apply. citeproc-js 1.0.55: - Fix bug that triggered "registry[id] undefined" error in some disambiguation operations. - Fix bug affecting voluntary suppression of small caps in rich text parsing engine. - Add methods for setting multilingual transliteration, translation, and sort parameters on configured processor. citeproc-js 1.0.56: - Distinguish between transliterations of (personal) names and transliterations of titles in recently-added multilingual configuration methods. citeproc-js 1.0.57: - Correctly handle singleton conditional nodes (if and else-if).
This commit is contained in:
parent
7f83086e1c
commit
c629a99185
1 changed files with 71 additions and 45 deletions
|
@ -1506,7 +1506,7 @@ CSL.dateParser = function (txt) {
|
|||
};
|
||||
CSL.Engine = function (sys, style, lang, xmlmode) {
|
||||
var attrs, langspec, localexml, locale;
|
||||
this.processor_version = "1.0.53";
|
||||
this.processor_version = "1.0.57";
|
||||
this.csl_version = "1.0";
|
||||
this.sys = sys;
|
||||
this.sys.xml = new CSL.System.Xml.Parsing();
|
||||
|
@ -1674,8 +1674,34 @@ CSL.Engine.prototype.setOutputFormat = function (mode) {
|
|||
this.output[mode].tmp = {};
|
||||
}
|
||||
};
|
||||
CSL.Engine.prototype.setLocale = function (locale) {
|
||||
};
|
||||
CSL.Engine.prototype.setLangTagsForCslSort = function (tags) {
|
||||
var i, ilen;
|
||||
this.opt['locale-sort'] = [];
|
||||
for (i = 0, ilen = tags.length; i < ilen; i += 1) {
|
||||
this.opt['locale-sort'].push(tags[i]);
|
||||
}
|
||||
}
|
||||
CSL.Engine.prototype.setLangTagsForCslNameTransliteration = function (tags) {
|
||||
var i, ilen;
|
||||
this.opt['locale-name'] = [];
|
||||
for (i = 0, ilen = tags.length; i < ilen; i += 1) {
|
||||
this.opt['locale-name'].push(tags[i]);
|
||||
}
|
||||
}
|
||||
CSL.Engine.prototype.setLangTagsForCslTitleTransliteration = function (tags) {
|
||||
var i, ilen;
|
||||
this.opt['locale-pri'] = [];
|
||||
for (i = 0, ilen = tags.length; i < ilen; i += 1) {
|
||||
this.opt['locale-pri'].push(tags[i]);
|
||||
}
|
||||
}
|
||||
CSL.Engine.prototype.setLangTagsForCslTranslation = function (tags) {
|
||||
var i, ilen;
|
||||
this.opt['locale-sec'] = [];
|
||||
for (i = 0, ilen = tags.length; i < ilen; i += 1) {
|
||||
this.opt['locale-sec'].push(tags[i]);
|
||||
}
|
||||
}
|
||||
CSL.Engine.prototype.getTerm = function (term, form, plural) {
|
||||
var ret = CSL.Engine.getField(CSL.LOOSE, this.locale[this.opt.lang].terms, term, form, plural);
|
||||
if (typeof ret === "undefined") {
|
||||
|
@ -3235,7 +3261,7 @@ CSL.Node["date-part"] = {
|
|||
CSL.Node["else-if"] = {
|
||||
build: function (state, target) {
|
||||
var func, tryposition;
|
||||
if (this.tokentype === CSL.START) {
|
||||
if (this.tokentype === CSL.START || this.tokentype === CSL.SINGLETON) {
|
||||
if ("number" === typeof this.strings.position) {
|
||||
tryposition = this.strings.position;
|
||||
func = function (state, Item, item) {
|
||||
|
@ -3268,7 +3294,7 @@ CSL.Node["else-if"] = {
|
|||
this.evaluator = state.fun.match.any;
|
||||
}
|
||||
}
|
||||
if (this.tokentype === CSL.END) {
|
||||
if (this.tokentype === CSL.END || this.tokentype === CSL.SINGLETON) {
|
||||
func = function (state, Item) {
|
||||
var next = this[state.tmp.jump.value()];
|
||||
return next;
|
||||
|
@ -3372,7 +3398,7 @@ CSL.Node.group = {
|
|||
CSL.Node["if"] = {
|
||||
build: function (state, target) {
|
||||
var tryposition, func;
|
||||
if (this.tokentype === CSL.START) {
|
||||
if (this.tokentype === CSL.START || this.tokentype === CSL.SINGLETON) {
|
||||
if ("number" === typeof this.strings.position) {
|
||||
tryposition = this.strings.position;
|
||||
func = function (state, Item, item) {
|
||||
|
@ -3405,7 +3431,7 @@ CSL.Node["if"] = {
|
|||
this.evaluator = state.fun.match.any;
|
||||
}
|
||||
}
|
||||
if (this.tokentype === CSL.END) {
|
||||
if (this.tokentype === CSL.END || this.tokentype === CSL.SINGLETON) {
|
||||
func = function (state, Item) {
|
||||
var next = this[state.tmp.jump.value()];
|
||||
return next;
|
||||
|
@ -4116,12 +4142,33 @@ CSL.Node.names = {
|
|||
state.output.addToken("non-dropping-particle", false, state.output.getToken("family"));
|
||||
state.output.addToken("suffix", false, state.output.getToken("family"));
|
||||
state.output.openLevel("term-join");
|
||||
if (label && state.output.getToken("label").strings.label_position === CSL.BEFORE) {
|
||||
state.output.append(label, "label");
|
||||
}
|
||||
len = namesets.length;
|
||||
for (namesetIndex = 0; namesetIndex < len; namesetIndex += 1) {
|
||||
nameset = namesets[namesetIndex];
|
||||
label = false;
|
||||
if (state.output.getToken("label").strings.label_position) {
|
||||
if (common_term) {
|
||||
termname = common_term;
|
||||
} else {
|
||||
termname = nameset.variable;
|
||||
}
|
||||
if (!state.output.getToken("label").strings.form) {
|
||||
form = "long";
|
||||
} else {
|
||||
form = state.output.getToken("label").strings.form;
|
||||
}
|
||||
if ("number" === typeof state.output.getToken("label").strings.plural) {
|
||||
plural = state.output.getToken("label").strings.plural;
|
||||
} else if (nameset.names.length > 1) {
|
||||
plural = 1;
|
||||
} else {
|
||||
plural = 0;
|
||||
}
|
||||
label = state.getTerm(termname, form, plural);
|
||||
}
|
||||
if (label && state.output.getToken("label").strings.label_position === CSL.BEFORE) {
|
||||
state.output.append(label, "label");
|
||||
}
|
||||
if (!state.tmp.suppress_decorations && (state[state.tmp.area].opt.collapse === "year" || state[state.tmp.area].opt.collapse === "year-suffix" || state[state.tmp.area].opt.collapse === "year-suffix-ranged")) {
|
||||
if (state.tmp.last_names_used.length === state.tmp.names_used.length) {
|
||||
lastones = state.tmp.last_names_used[state.tmp.nameset_counter];
|
||||
|
@ -4262,27 +4309,6 @@ CSL.Node.names = {
|
|||
state.tmp.disambig_settings.givens[state.tmp.nameset_counter][ppos] = param;
|
||||
}
|
||||
}
|
||||
label = false;
|
||||
if (state.output.getToken("label").strings.label_position) {
|
||||
if (common_term) {
|
||||
termname = common_term;
|
||||
} else {
|
||||
termname = nameset.variable;
|
||||
}
|
||||
if (!state.output.getToken("label").strings.form) {
|
||||
form = "long";
|
||||
} else {
|
||||
form = state.output.getToken("label").strings.form;
|
||||
}
|
||||
if ("number" === typeof state.output.getToken("label").strings.plural) {
|
||||
plural = state.output.getToken("label").strings.plural;
|
||||
} else if (nameset.names.length > 1) {
|
||||
plural = 1;
|
||||
} else {
|
||||
plural = 0;
|
||||
}
|
||||
label = state.getTerm(termname, form, plural);
|
||||
}
|
||||
if (namesetIndex > 0 && nameset.variable !== last_variable) {
|
||||
state.output.closeLevel("term-join");
|
||||
}
|
||||
|
@ -4337,7 +4363,7 @@ CSL.Node.names = {
|
|||
state.output.closeLevel("trailing-names");
|
||||
}
|
||||
if (namesets.length === namesetIndex + 1 || namesets[namesetIndex + 1].variable !== namesets[namesetIndex].variable) {
|
||||
if (label && state.tmp.name_label_position !== CSL.BEFORE) {
|
||||
if (label && state.output.getToken("label").strings.label_position !== CSL.BEFORE) {
|
||||
state.output.append(label, "label");
|
||||
}
|
||||
}
|
||||
|
@ -6844,15 +6870,15 @@ CSL.Util.FlipFlopper = function (state) {
|
|||
this.state = state;
|
||||
this.blob = false;
|
||||
tagdefs = [
|
||||
["<i>", "</i>", "italics", "@font-style", ["italic", "normal"], true],
|
||||
["<b>", "</b>", "bold", "@font-weight", ["bold", "normal"], true],
|
||||
["<sup>", "</sup>", "superscript", "@vertical-align", ["sup", "sup"], true],
|
||||
["<sub>", "</sub>", "subscript", "@vertical-align", ["sub", "sub"], true],
|
||||
["<sc>", "</sc>", "smallcaps", "@font-variant", ["small-caps", "small-caps"], true],
|
||||
["<span class=\"nocase\">", "</span>", "passthrough", "@passthrough", ["true", "true"], true],
|
||||
["<span class=\"nodecor\">", "</span>", "passthrough", "@passthrough", ["true", "true"], true],
|
||||
['"', '"', "quotes", "@quotes", ["true", "inner"], "'"],
|
||||
[" '", "'", "quotes", "@quotes", ["inner", "true"], '"']
|
||||
["<i>", "</i>", "italics", "@font-style", ["italic", "normal","normal"], true],
|
||||
["<b>", "</b>", "bold", "@font-weight", ["bold", "normal","normal"], true],
|
||||
["<sup>", "</sup>", "superscript", "@vertical-align", ["sup", "sup","baseline"], true],
|
||||
["<sub>", "</sub>", "subscript", "@vertical-align", ["sub", "sub","baseline"], true],
|
||||
["<sc>", "</sc>", "smallcaps", "@font-variant", ["small-caps", "small-caps","normal"], true],
|
||||
["<span class=\"nocase\">", "</span>", "passthrough", "@passthrough", ["true", "true","true"], true],
|
||||
["<span class=\"nodecor\">", "</span>", "passthrough", "@passthrough", ["true", "true","true"], true],
|
||||
['"', '"', "quotes", "@quotes", ["true", "inner","true"], "'"],
|
||||
[" '", "'", "quotes", "@quotes", ["inner", "true","true"], '"']
|
||||
];
|
||||
for (pos = 0; pos < 2; pos += 1) {
|
||||
p = ["-", "-inner-"][pos];
|
||||
|
@ -6913,7 +6939,7 @@ CSL.Util.FlipFlopper = function (state) {
|
|||
flipTags[tagdefs[pos][1]] = tagdefs[pos][5];
|
||||
openToClose[tagdefs[pos][0]] = tagdefs[pos][1];
|
||||
openToDecorations[tagdefs[pos][0]] = [tagdefs[pos][3], tagdefs[pos][4]];
|
||||
okReverse[tagdefs[pos][3]] = [tagdefs[pos][3], [tagdefs[pos][4][1], tagdefs[pos][1]]];
|
||||
okReverse[tagdefs[pos][3]] = [tagdefs[pos][3], [tagdefs[pos][4][2], tagdefs[pos][1]]];
|
||||
}
|
||||
return [closeTags, flipTags, openToClose, openToDecorations, okReverse];
|
||||
};
|
||||
|
@ -7281,7 +7307,7 @@ CSL.Output.Formats.prototype.html = {
|
|||
"@font-style/normal": "<span style=\"font-style:normal;\">%%STRING%%</span>",
|
||||
"@font-variant/small-caps": "<span style=\"font-variant:small-caps;\">%%STRING%%</span>",
|
||||
"@passthrough/true": CSL.Output.Formatters.passthrough,
|
||||
"@font-variant/normal": false,
|
||||
"@font-variant/normal": "<span style=\"font-variant:normal;\">%%STRING%%</span>",
|
||||
"@font-weight/bold": "<b>%%STRING%%</b>",
|
||||
"@font-weight/normal": "<span style=\"font-weight:normal;\">%%STRING%%</span>",
|
||||
"@font-weight/light": false,
|
||||
|
@ -7575,7 +7601,7 @@ CSL.Registry.prototype.dorefreshes = function () {
|
|||
regtoken.ambig = undefined;
|
||||
Item = this.state.retrieveItem(key);
|
||||
if ("undefined" === typeof akey) {
|
||||
CSL.getAmbiguousCite.call(this.state, Item);
|
||||
akey = CSL.getAmbiguousCite.call(this.state, Item);
|
||||
this.state.tmp.taintedItemIDs[key] = true;
|
||||
}
|
||||
this.registry[key] = regtoken;
|
||||
|
@ -8240,4 +8266,4 @@ CSL.Disambiguation.prototype.decrementNames = function () {
|
|||
CSL.Registry.CitationReg = function (state) {
|
||||
this.citationById = {};
|
||||
this.citationByIndex = [];
|
||||
};
|
||||
};
|
Loading…
Reference in a new issue