Skip to content

Commit

Permalink
Update processor to 1.1.144
Browse files Browse the repository at this point in the history
  • Loading branch information
fbennett committed Jan 9, 2017
1 parent 94c3754 commit 7427823
Showing 1 changed file with 65 additions and 48 deletions.
113 changes: 65 additions & 48 deletions chrome/content/zotero/xpcom/citeproc.js
Expand Up @@ -23,7 +23,7 @@
* <http://www.gnu.org/licenses/> respectively.
*/
var CSL = {
PROCESSOR_VERSION: "1.1.139",
PROCESSOR_VERSION: "1.1.144",
CONDITION_LEVEL_TOP: 1,
CONDITION_LEVEL_BOTTOM: 2,
PLAIN_HYPHEN_REGEX: /(?:[^\\]-|\u2013)/,
Expand Down Expand Up @@ -196,6 +196,37 @@ var CSL = {
this["container-phrase"] = {};
this["title-phrase"] = {};
},
FIELD_CATEGORY_REMAP: {
"title": "title",
"container-title": "container-title",
"collection-title": "collection-title",
"number": "number",
"place": "place",
"archive": "collection-title",
"title-short": "title",
"genre": "title",
"event": "title",
"medium": "title",
"archive-place": "place",
"publisher-place": "place",
"event-place": "place",
"jurisdiction": "place",
"language-name": "place",
"language-name-original": "place",
"call-number": "number",
"chapter-number": "number",
"collection-number": "number",
"edition": "number",
"page": "number",
"issue": "number",
"locator": "number",
"number-of-pages": "number",
"number-of-volumes": "number",
"volume": "number",
"citation-number": "number",
"publisher": "institution-part",
"authority": "institution-part"
},
parseLocator: function(item) {
if (this.opt.development_extensions.locator_date_and_revision) {
if (item.locator) {
Expand Down Expand Up @@ -1753,10 +1784,10 @@ CSL.setupXml = function(xmlObject) {
parser = new CSL.XmlJSON(xmlObject);
}
} else {
print("OUCH!");
CSL.error("unable to parse XML input");
}
if (!parser) {
throw "citeproc-js error: unable to parse style or locale object";
throw "citeproc-js error: unable to parse CSL style or locale object";
}
return parser;
}
Expand Down Expand Up @@ -7753,11 +7784,13 @@ CSL.NameOutput.prototype.init = function (names) {
this.name = undefined;
this.institutionpart = {};
this.state.tmp.group_context.tip.variable_attempt = true;
this.labelVariable = this.variables[0];
if (!this.state.tmp.value.length) {
return;
}
};
CSL.NameOutput.prototype.reinit = function (names) {
CSL.NameOutput.prototype.reinit = function (names, labelVariable) {
this.labelVariable = labelVariable;
if (this.state.tmp.can_substitute.value()) {
this.nameset_offset = 0;
this.variables = names.variables;
Expand Down Expand Up @@ -7911,7 +7944,7 @@ CSL.NameOutput.prototype.outputNames = function () {
};
CSL.NameOutput.prototype._applyLabels = function (blob, v) {
var txt;
if (!this.label || !this.label[v]) {
if (!this.label || !this.label[this.labelVariable]) {
return blob;
}
var plural = 0;
Expand All @@ -7926,24 +7959,24 @@ CSL.NameOutput.prototype._applyLabels = function (blob, v) {
plural = 1;
}
}
if (this.label[v].before) {
if ("number" === typeof this.label[v].before.strings.plural) {
plural = this.label[v].before.strings.plural;
if (this.label[this.labelVariable].before) {
if ("number" === typeof this.label[this.labelVariable].before.strings.plural) {
plural = this.label[this.lableVariable].before.strings.plural;
}
txt = this._buildLabel(v, plural, "before", v);
txt = this._buildLabel(v, plural, "before", this.labelVariable);
this.state.output.openLevel("empty");
this.state.output.append(txt, this.label[v].before, true);
this.state.output.append(txt, this.label[this.labelVariable].before, true);
this.state.output.append(blob, "literal", true);
this.state.output.closeLevel("empty");
blob = this.state.output.pop();
} else if (this.label[v].after) {
if ("number" === typeof this.label[v].after.strings.plural) {
plural = this.label[v].after.strings.plural;
} else if (this.label[this.labelVariable].after) {
if ("number" === typeof this.label[this.labelVariable].after.strings.plural) {
plural = this.label[this.labelVariable].after.strings.plural;
}
txt = this._buildLabel(v, plural, "after", v);
txt = this._buildLabel(v, plural, "after", this.labelVariable);
this.state.output.openLevel("empty");
this.state.output.append(blob, "literal", true);
this.state.output.append(txt, this.label[v].after, true);
this.state.output.append(txt, this.label[this.labelVariable].after, true);
this.state.tmp.label_blob = this.state.output.pop();
this.state.output.append(this.state.tmp.label_blob,"literal",true);
this.state.output.closeLevel("empty");
Expand Down Expand Up @@ -8829,7 +8862,9 @@ CSL.NameOutput.prototype._renderInstitutionName = function (v, name, slot, j) {
institution = [this._composeOneInstitutionPart([n.l.pri, n.l.sec, n.l.ter], slot, long_style, v)];
break;
}
return this._join(institution, " ");
var blob = this._join(institution, " ");
this.state.tmp.name_node.children.push(blob);
return blob;
};
CSL.NameOutput.prototype._composeOneInstitutionPart = function (names, slot, style, v) {
var primary = false, secondary = false, tertiary = false, primary_tok, secondary_tok, tertiary_tok;
Expand Down Expand Up @@ -9852,11 +9887,9 @@ CSL.Node.names = {
}
if (this.tokentype === CSL.SINGLETON) {
state.build.names_variables.push(this.variables);
for (var i = 0, ilen = this.variables.length; i < ilen; i += 1) {
state.build.name_label[this.variables[i]] = state.build.name_label[state.build.names_variables.slice(0)[0]];
}
func = function (state, Item, item) {
state.nameOutput.reinit(this);
var labelVariable = state.nameOutput.labelVariable;
state.nameOutput.reinit(this, labelVariable);
};
this.execs.push(func);
}
Expand Down Expand Up @@ -11440,7 +11473,9 @@ CSL.Attributes["@reverse-order"] = function (state, arg) {
}
};
CSL.Attributes["@display"] = function (state, arg) {
state.opt.using_display = true;
if (state.bibliography.tokens.length === 2) {
state.opt.using_display = true;
}
this.strings.cls = arg;
};
CSL.Stack = function (val, literal) {
Expand Down Expand Up @@ -12026,37 +12061,19 @@ CSL.Transform = function (state) {
this.getTextSubField = getTextSubField;
function abbreviate(state, Item, altvar, basevalue, myabbrev_family, use_field) {
var value;
if (!myabbrev_family) {
return basevalue;
}
var variable = myabbrev_family;
var noHints = false;
if (["title", "title-short"].indexOf(variable) > -1 && !Item.jurisdiction) {
noHints = true;
}
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";
}
if (["publisher", "authority"].indexOf(myabbrev_family) > -1) {
myabbrev_family = "institution-part";
}
if (["genre", "event", "medium", "title-short"].indexOf(myabbrev_family) > -1) {
myabbrev_family = "title";
}
if (["archive"].indexOf(myabbrev_family) > -1) {
myabbrev_family = "collection-title";
myabbrev_family = CSL.FIELD_CATEGORY_REMAP[myabbrev_family];
if (!myabbrev_family) {
return basevalue;
}
var variable = myabbrev_family;
value = "";
if (state.sys.getAbbreviation) {
var jurisdiction = state.transform.loadAbbreviation(Item.jurisdiction, myabbrev_family, basevalue, Item.type, noHints);
var jurisdiction = state.transform.loadAbbreviation(Item.jurisdiction, myabbrev_family, basevalue, Item.type, true);
if (state.transform.abbrevs[jurisdiction][myabbrev_family] && basevalue && state.sys.getAbbreviation) {
if (state.transform.abbrevs[jurisdiction][myabbrev_family][basevalue]) {
value = state.transform.abbrevs[jurisdiction][myabbrev_family][basevalue].replace("{stet}",basevalue);
Expand Down Expand Up @@ -12156,7 +12173,7 @@ CSL.Transform = function (state) {
}
return ret;
}
function loadAbbreviation(jurisdiction, category, orig, itemType, noHints) {
function loadAbbreviation(jurisdiction, category, orig, itemType) {
var pos, len;
if (!jurisdiction) {
jurisdiction = "default";
Expand All @@ -12181,7 +12198,7 @@ CSL.Transform = function (state) {
state.transform.abbrevs[tryList[i]] = new state.sys.AbbreviationSegments();
}
if (!state.transform.abbrevs[tryList[i]][category][orig]) {
state.sys.getAbbreviation(state.opt.styleID, state.transform.abbrevs, tryList[i], category, orig, itemType, noHints);
state.sys.getAbbreviation(state.opt.styleID, state.transform.abbrevs, tryList[i], category, orig, itemType, true);
}
if (!found && state.transform.abbrevs[tryList[i]][category][orig]) {
if (i < tryList.length) {
Expand Down Expand Up @@ -12645,7 +12662,7 @@ CSL.Util.fixDateNode = function (parent, pos, node) {
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++) {
for (var i=1,ilen=this.cslXml.numberofnodes(childNodes);i<ilen;i++) {
if (this.cslXml.getAttributeValue(childNodes[i], 'name') === "year") {
this.cslXml.setAttribute(childNodes[i-1], "suffix", "");
break;
Expand Down Expand Up @@ -13327,7 +13344,7 @@ CSL.Util.substituteEnd = function (state, target) {
} else if ("complete-each" === subrule) {
var rendered_name = state.tmp.rendered_name.join(",");
if (rendered_name) {
if (!rendered_name.localeCompare(state.tmp.last_rendered_name)) {
if (state.tmp.last_rendered_name && !rendered_name.localeCompare(state.tmp.last_rendered_name)) {
for (i = 0, ilen = state.tmp.name_node.children.length; i < ilen; i += 1) {
str = new CSL.Blob(state[state.tmp.area].opt["subsequent-author-substitute"]);
state.tmp.name_node.children[i].blobs = [str];
Expand Down

0 comments on commit 7427823

Please sign in to comment.