diff --git a/chrome/content/zotero/xpcom/citeproc.js b/chrome/content/zotero/xpcom/citeproc.js
index f83b3e692d..ea1497980c 100644
--- a/chrome/content/zotero/xpcom/citeproc.js
+++ b/chrome/content/zotero/xpcom/citeproc.js
@@ -1,30 +1,35 @@
/*
-Copyright (c) 2009-2019 Frank Bennett
+ * Copyright (c) 2009-2016 Frank Bennett
+ *
+ * This program is free software: you can redistribute it and/or
+ * modify it under EITHER
+ *
+ * * the terms of the Common Public Attribution License (CPAL) as
+ * published by the Open Source Initiative, either version 1 of
+ * the CPAL, or (at your option) any later version; OR
+ *
+ * * the terms of the GNU Affero General Public License (AGPL)
+ * as published by the Free Software Foundation, either version
+ * 3 of the AGPL, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Affero General Public License for more details.
+ *
+ * You should have received copies of the Common Public Attribution
+ * License and of the GNU Affero General Public License along with
+ * this program. If not, see or
+ * respectively.
+ */
- This program is free software: you can redistribute it and/or
- modify it under EITHER
-
- * the terms of the Common Public Attribution License (CPAL) as
- published by the Open Source Initiative, either version 1 of
- the CPAL, or (at your option) any later version; OR
-
- * the terms of the GNU Affero General Public License (AGPL)
- as published by the Free Software Foundation, either version
- 3 of the AGPL, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Affero General Public License for more details.
-
- You should have received copies of the Common Public Attribution
- License and of the GNU Affero General Public License along with
- this program. If not, see or
- respectively.
-*/
var CSL = {
- PROCESSOR_VERSION: "1.1.226",
+ PROCESSOR_VERSION: "1.1.215",
+ CONDITION_LEVEL_TOP: 1,
+ CONDITION_LEVEL_BOTTOM: 2,
+ PLAIN_HYPHEN_REGEX: /(?:[^\\]-|\u2013)/,
LOCATOR_LABELS_REGEXP: new RegExp("^((art|ch|subch|col|fig|l|n|no|op|p|pp|para|subpara|pt|r|sec|subsec|sv|sch|tit|vrs|vol)\\.)\\s+(.*)"),
+ STATUTE_SUBDIV_GROUPED_REGEX: /((?:^| )(?:art|bk|ch|subch|col|fig|fol|l|n|no|op|p|pp|para|subpara|pt|r|sec|subsec|sv|sch|tit|vrs|vol)\. *)/g,
STATUTE_SUBDIV_PLAIN_REGEX: /(?:(?:^| )(?:art|bk|ch|subch|col|fig|fol|l|n|no|op|p|pp|para|subpara|pt|r|sec|subsec|sv|sch|tit|vrs|vol)\. *)/,
STATUTE_SUBDIV_PLAIN_REGEX_FRONT: /(?:^\s*[.,;]*\s*(?:art|bk|ch|subch|col|fig|fol|l|n|no|op|p|pp|para|subpara|pt|r|sec|subsec|sv|sch|tit|vrs|vol)\. *)/,
STATUTE_SUBDIV_STRINGS: {
@@ -126,33 +131,37 @@ var CSL = {
"regulation": true,
"standard": true
},
+ NestedBraces: [
+ ["(", "["],
+ [")", "]"]
+ ],
checkNestedBrace: function(state) {
if (state.opt.xclass === "note") {
this.depth = 0;
this.update = function(str) {
- var str = str ? str : "";
+ var str = str ? str : '';
var lst = str.split(/([\(\)])/);
for (var i=1,ilen=lst.length;i less && str.length < more && parseInt(str)) {
+ return true
+ } else {
+ return false;
}
+ },
+ isDateString: function(str) {
+ if (!str) return false;
+ var strLst = str.split("-");
+ if (strLst.length > 0) {
+ if (!this.isDatePart(strLst[0], 3, 5)) {
+ return false;
+ }
+ }
+ if (strLst.length > 1) {
+ if (!this.isDatePart(strLst[1], 0, 3)) {
+ return false
+ }
+ }
+ if (strLst.length > 2) {
+ if (!this.isDatePart(strLst[2], 0, 3)) {
+ return false
+ }
+ }
+ if (strLst.length > 3) {
+ return false;
+ }
+ return true;
+ },
+ parseNoteFieldHacks: function(Item, validFieldsForType, allowDateOverride) {
+ if ("string" !== typeof Item.note) return;
var elems = [];
var lines = Item.note.split('\n');
+ var lastline = "";
for (var i=0, ilen=lines.length; i0 || j>1) && !elems[j-1].match(CSL.NOTE_FIELD_REGEXP)) {
- break;
+ break
} else {
elems[j] = '\n' + elems[j].slice(2,-1).trim() + '\n';
}
@@ -303,7 +338,7 @@ var CSL = {
if (key === "type") {
Item.type = val;
lines[i] = "";
- } else if (CSL.DATE_VARIABLES.indexOf(key.replace(/^alt-/, "")) > -1) {
+ } else if (CSL.DATE_VARIABLES.indexOf(key) > -1) {
if (allowDateOverride) {
Item[key] = {raw: val};
if (!validFieldsForType || (validFieldsForType[key] && this.isDateString(val))) {
@@ -311,7 +346,7 @@ var CSL = {
}
}
} else if (!Item[key]) {
- if (CSL.NAME_VARIABLES.indexOf(key.replace(/^alt-/, "")) > -1) {
+ if (CSL.NAME_VARIABLES.indexOf(key) > -1) {
if (!names[key]) {
names[key] = [];
}
@@ -336,7 +371,7 @@ var CSL = {
}
if (validFieldsForType) {
if (lines[offset].trim()) {
- lines[offset] = '\n' + lines[offset];
+ lines[offset] = '\n' + lines[offset]
}
for (var i=offset-1;i>-1;i--) {
if (!lines[i].trim()) {
@@ -346,42 +381,6 @@ var CSL = {
}
Item.note = lines.join("\n").trim();
},
- checkPrefixSpaceAppend: function (state, prefix) {
- if (!prefix) {
- prefix = "";
- }
- var sp = "";
- var test_prefix = prefix.replace(/<[^>]+>/g, "").replace(/["'\u201d\u2019\u00bb\u202f\u00a0 ]+$/g,"");
- var test_char = test_prefix.slice(-1);
- if (test_prefix.match(CSL.ENDSWITH_ROMANESQUE_REGEXP)) {
- sp = " ";
- } else if (CSL.TERMINAL_PUNCTUATION.slice(0,-1).indexOf(test_char) > -1) {
- sp = " ";
- } else if (test_char.match(/[\)\],0-9]/)) {
- sp = " ";
- }
- var prefix = (prefix + sp).replace(/\s+/g, " ");
- return prefix;
- },
- checkIgnorePredecessor: function(state, prefix) {
- var ignorePredecessor = false;
- var test_prefix = prefix.replace(/<[^>]+>/g, "").replace(/["'\u201d\u2019\u00bb\u202f\u00a0 ]+$/g,"");
- var test_char = test_prefix.slice(-1);
- if (CSL.TERMINAL_PUNCTUATION.slice(0,-1).indexOf(test_char) > -1 && prefix.trim().indexOf(" ") > -1) {
- state.tmp.term_predecessor = false;
- return true;
- }
- return false;
- },
- checkSuffixSpacePrepend: function(state, suffix) {
- if (!suffix) {
- return "";
- }
- if (suffix.match(CSL.STARTSWITH_ROMANESQUE_REGEXP) || ['[','('].indexOf(suffix.slice(0,1)) > -1) {
- suffix = " " + suffix;
- }
- return suffix;
- },
GENDERS: ["masculine", "feminine"],
ERROR_NO_RENDERED_FORM: 1,
PREVIEW: "Just for laughs.",
@@ -400,23 +399,30 @@ var CSL = {
AFTER: 2,
DESCENDING: 1,
ASCENDING: 2,
+ ONLY_FIRST: 1,
+ ALWAYS: 2,
+ ONLY_LAST: 3,
+ FINISH: 1,
POSITION_FIRST: 0,
POSITION_SUBSEQUENT: 1,
POSITION_IBID: 2,
POSITION_IBID_WITH_LOCATOR: 3,
+ MARK_TRAILING_NAMES: true,
POSITION_TEST_VARS: ["position", "first-reference-note-number", "near-note"],
- AREAS: ["citation", "citation_sort", "bibliography", "bibliography_sort", "intext"],
+ AREAS: ["citation", "citation_sort", "bibliography", "bibliography_sort"],
CITE_FIELDS: ["first-reference-note-number", "locator", "locator-extra"],
+ MINIMAL_NAME_FIELDS: ["literal", "family"],
SWAPPING_PUNCTUATION: [".", "!", "?", ":", ","],
TERMINAL_PUNCTUATION: [":", ".", ";", "!", "?", " "],
NONE: 0,
NUMERIC: 1,
POSITION: 2,
- TRIGRAPH: 3,
+ COLLAPSE_VALUES: ["citation-number", "year", "year-suffix"],
DATE_PARTS: ["year", "month", "day"],
DATE_PARTS_ALL: ["year", "month", "day", "season"],
DATE_PARTS_INTERNAL: ["year", "month", "day", "year_end", "month_end", "day_end"],
NAME_PARTS: ["non-dropping-particle", "family", "given", "dropping-particle", "suffix", "literal"],
+ DECORABLE_NAME_PARTS: ["given", "family", "suffix"],
DISAMBIGUATE_OPTIONS: [
"disambiguate-add-names",
"disambiguate-add-givenname",
@@ -455,7 +461,7 @@ var CSL = {
PREFIX_PUNCTUATION: /[.;:]\s*$/,
SUFFIX_PUNCTUATION: /^\s*[.;:,\(\)]/,
NUMBER_REGEXP: /(?:^\d+|\d+$)/,
- NAME_INITIAL_REGEXP: /^([A-Z\u0e01-\u0e5b\u00c0-\u017f\u0400-\u042f\u0590-\u05d4\u05d6-\u05ff\u0600-\u06ff\u0370\u0372\u0376\u0386\u0388-\u03ab\u03e2\u03e4\u03e6\u03e8\u03ea\u03ec\u03ee\u03f4\u03f7\u03fd-\u03ff])([a-zA-Z\u0e01-\u0e5b\u00c0-\u017f\u0400-\u052f\u0600-\u06ff\u0370-\u03ff\u1f00-\u1fff]*|)(\.)*/,
+ NAME_INITIAL_REGEXP: /^([A-Z\u0e01-\u0e5b\u00c0-\u017f\u0400-\u042f\u0590-\u05d4\u05d6-\u05ff\u0600-\u06ff\u0370\u0372\u0376\u0386\u0388-\u03ab\u03e2\u03e4\u03e6\u03e8\u03ea\u03ec\u03ee\u03f4\u03f7\u03fd-\u03ff])([a-zA-Z\u0e01-\u0e5b\u00c0-\u017f\u0400-\u052f\u0600-\u06ff\u0370-\u03ff\u1f00-\u1fff]*|)/,
ROMANESQUE_REGEXP: /[-0-9a-zA-Z\u0e01-\u0e5b\u00c0-\u017f\u0370-\u03ff\u0400-\u052f\u0590-\u05d4\u05d6-\u05ff\u1f00-\u1fff\u0600-\u06ff\u200c\u200d\u200e\u0218\u0219\u021a\u021b\u202a-\u202e]/,
ROMANESQUE_NOT_REGEXP: /[^a-zA-Z\u0e01-\u0e5b\u00c0-\u017f\u0370-\u03ff\u0400-\u052f\u0590-\u05d4\u05d6-\u05ff\u1f00-\u1fff\u0600-\u06ff\u200c\u200d\u200e\u0218\u0219\u021a\u021b\u202a-\u202e]/g,
STARTSWITH_ROMANESQUE_REGEXP: /^[&a-zA-Z\u0e01-\u0e5b\u00c0-\u017f\u0370-\u03ff\u0400-\u052f\u0590-\u05d4\u05d6-\u05ff\u1f00-\u1fff\u0600-\u06ff\u200c\u200d\u200e\u0218\u0219\u021a\u021b\u202a-\u202e]/,
@@ -506,7 +512,6 @@ var CSL = {
"page",
"issue",
"locator",
- "locator-extra",
"number",
"number-of-pages",
"number-of-volumes",
@@ -518,12 +523,12 @@ var CSL = {
"issued",
"event-date",
"accessed",
+ "container",
"original-date",
"publication-date",
+ "original-date",
"available-date",
- "submitted",
- "alt-issued",
- "alt-event"
+ "submitted"
],
TITLE_FIELD_SPLITS: function(seg) {
var keys = ["title", "short", "main", "sub"];
@@ -533,6 +538,32 @@ var CSL = {
}
return ret;
},
+ TAG_USEALL: function (str) {
+ var ret, open, close, end;
+ ret = [""];
+ open = str.indexOf("<");
+ close = str.indexOf(">");
+ while (open > -1 && close > -1) {
+ if (open > close) {
+ end = open + 1;
+ } else {
+ end = close + 1;
+ }
+ if (open < close && str.slice(open + 1, close).indexOf("<") === -1) {
+ ret[ret.length - 1] += str.slice(0, open);
+ ret.push(str.slice(open, close + 1));
+ ret.push("");
+ str = str.slice(end);
+ } else {
+ ret[ret.length - 1] += str.slice(0, close + 1);
+ str = str.slice(end);
+ }
+ open = str.indexOf("<");
+ close = str.indexOf(">");
+ }
+ ret[ret.length - 1] += str;
+ return ret;
+ },
demoteNoiseWords: function (state, fld, drop_or_demote) {
var SKIP_WORDS = state.locale[state.opt.lang].opts["leading-noise-words"];
if (fld && drop_or_demote) {
@@ -568,7 +599,7 @@ var CSL = {
langs.push(lang);
}
}
- for (var j=0,jlen=langs.length;j -1; ppos += -1) {
@@ -2930,9 +2957,10 @@ CSL.Engine.prototype.configureTokenList = function (tokens) {
CSL.Node[token.name].configure.call(token, this, ppos);
}
}
-};
+}
CSL.Engine.prototype.refetchItems = function (ids) {
- var ret = [];
+ var ret, pos, len;
+ ret = [];
for (var i = 0, ilen = ids.length; i < ilen; i += 1) {
ret.push(this.refetchItem("" + ids[i]));
}
@@ -2940,7 +2968,7 @@ CSL.Engine.prototype.refetchItems = function (ids) {
};
CSL.ITERATION = 0;
CSL.Engine.prototype.retrieveItem = function (id) {
- var Item, m, i;
+ var Item, m, pos, len, mm, i;
if (!this.tmp.loadedItemIDs[id]) {
this.tmp.loadedItemIDs[id] = true;
} else {
@@ -3001,23 +3029,13 @@ CSL.Engine.prototype.retrieveItem = function (id) {
}
}
}
- if (Item.language && Item.language.match(/[><]/)) {
- var m = Item.language.match(/(.*?)([<>])(.*)/);
- if (m[2] === "<") {
- Item["language-name"] = m[1];
- Item["language-name-original"] = m[3];
- } else {
- Item["language-name"] = m[3];
- Item["language-name-original"] = m[1];
+ if (Item.language) {
+ var lst = Item.language.split("<");
+ if (lst.length > 0) {
+ Item["language-name"] = lst[0];
}
- if (this.opt.multi_layout) {
- if (Item["language-name-original"]) {
- Item.language = Item["language-name-original"];
- }
- } else {
- if (Item["language-name"]) {
- Item.language = Item["language-name"];
- }
+ if (lst.length === 2) {
+ Item["language-name-original"] = lst[1];
}
}
if (Item.page) {
@@ -3031,17 +3049,15 @@ CSL.Engine.prototype.retrieveItem = function (id) {
if (this.opt.development_extensions.field_hack && Item.note) {
CSL.parseNoteFieldHacks(Item, false, this.opt.development_extensions.allow_field_hack_date_override);
}
- for (var key in Item) {
- if (CSL.DATE_VARIABLES.indexOf(key.replace(/^alt-/, "")) > -1) {
- var dateobj = Item[key];
- if (dateobj) {
- if (this.opt.development_extensions.raw_date_parsing) {
- if (dateobj.raw) {
- dateobj = this.fun.dateparser.parseDateToObject(dateobj.raw);
- }
+ for (var i = 1, ilen = CSL.DATE_VARIABLES.length; i < ilen; i += 1) {
+ var dateobj = Item[CSL.DATE_VARIABLES[i]];
+ if (dateobj) {
+ if (this.opt.development_extensions.raw_date_parsing) {
+ if (dateobj.raw) {
+ dateobj = this.fun.dateparser.parseDateToObject(dateobj.raw);
}
- Item[key] = this.dateParseArray(dateobj);
}
+ Item[CSL.DATE_VARIABLES[i]] = this.dateParseArray(dateobj);
}
}
if (this.opt.development_extensions.static_statute_locator) {
@@ -3049,14 +3065,14 @@ CSL.Engine.prototype.retrieveItem = function (id) {
var varname;
var elements = ["type", "title", "jurisdiction", "genre", "volume", "container-title"];
var legislation_id = [];
- for (var i = 0, ilen = elements.length; i < ilen; i += 1) {
+ for (i = 0, ilen = elements.length; i < ilen; i += 1) {
varname = elements[i];
if (Item[varname]) {
legislation_id.push(Item[varname]);
}
}
elements = ["original-date", "issued"];
- for (var i = 0, ilen=elements.length; i < ilen; i += 1) {
+ for (i = 0, elements.length; i < ilen; i += 1) {
varname = elements[i];
if (Item[varname] && Item[varname].year) {
var value = Item[varname].year;
@@ -3076,13 +3092,13 @@ CSL.Engine.prototype.retrieveItem = function (id) {
_key: {}
}
}
- ];
+ ]
if (Item.multi && Item.multi._keys && Item.multi._keys.authority) {
Item.authority[0].multi._key = {};
for (var key in Item.multi._keys.authority) {
Item.authority[0].multi._key[key] = {
literal: Item.multi._keys.authority[key]
- };
+ }
}
}
}
@@ -3111,9 +3127,9 @@ CSL.Engine.prototype.retrieveItem = function (id) {
normalizedKey = Item.title;
}
var jurisdiction = this.transform.loadAbbreviation(Item.jurisdiction, "title", normalizedKey, Item.type);
- if (this.transform.abbrevs[jurisdiction].title) {
- if (this.transform.abbrevs[jurisdiction].title[normalizedKey]) {
- Item["title-short"] = this.transform.abbrevs[jurisdiction].title[normalizedKey];
+ if (this.transform.abbrevs[jurisdiction]["title"]) {
+ if (this.transform.abbrevs[jurisdiction]["title"][normalizedKey]) {
+ Item["title-short"] = this.transform.abbrevs[jurisdiction]["title"][normalizedKey];
}
}
}
@@ -3133,8 +3149,8 @@ CSL.Engine.prototype.retrieveItem = function (id) {
}
}
}
- if (Item.jurisdiction) {
- Item.country = Item.jurisdiction.split(":")[0];
+ if (Item["jurisdiction"]) {
+ Item["country"] = Item["jurisdiction"].split(":")[0];
}
if (this.registry.refhash[id]) {
if (JSON.stringify(this.registry.refhash[id]) != JSON.stringify(Item)) {
@@ -3149,9 +3165,6 @@ CSL.Engine.prototype.retrieveItem = function (id) {
}
return this.registry.refhash[id];
};
-CSL.Engine.prototype.refetchItem = function (id) {
- return this.registry.refhash[id];
-};
CSL.Engine.prototype.refetchItem = function (id) {
return this.registry.refhash[id];
}
@@ -3227,7 +3240,7 @@ CSL.Engine.prototype.remapSectionVariable = function (inputList) {
item.label = "";
}
}
-};
+}
CSL.Engine.prototype.setNumberLabels = function (Item) {
if (Item.number
&& ["bill", "gazette", "legislation","regulation","treaty"].indexOf(Item.type) > -1
@@ -3243,10 +3256,12 @@ CSL.Engine.prototype.setNumberLabels = function (Item) {
var firstword = value.split(/\s+/)[0];
var firstlabel = CSL.STATUTE_SUBDIV_STRINGS[firstword];
if (firstlabel) {
+ var m = value.match(CSL.STATUTE_SUBDIV_GROUPED_REGEX);
var splt = value.split(CSL.STATUTE_SUBDIV_PLAIN_REGEX);
if (splt.length > 1) {
var lst = [];
for (var j=1, jlen=splt.length; j < jlen; j += 1) {
+ var subdiv = m[j - 1].replace(/^\s*/, "");
lst.push(splt[j].replace(/\s*$/, "").replace(/^\s*/, ""));
}
value = lst.join(" ");
@@ -3261,7 +3276,7 @@ CSL.Engine.prototype.setNumberLabels = function (Item) {
this.tmp.shadow_numbers["number"].numeric = true;
}
}
-};
+}
CSL.substituteOne = function (template) {
return function (state, list) {
if (!list) {
@@ -3336,9 +3351,12 @@ CSL.setDecorations = function (state, attributes) {
return ret;
};
CSL.Doppeler = function(rexStr, stringMangler) {
+ var mx, lst, len, pos, m, buf1, buf2, idx, ret, myret;
+ this.split = split;
+ this.join = join;
var matchRex = new RegExp("(" + rexStr + ")", "g");
var splitRex = new RegExp(rexStr, "g");
- this.split = function (str) {
+ function split(str) {
if (stringMangler) {
str = stringMangler(str);
}
@@ -3364,9 +3382,9 @@ CSL.Doppeler = function(rexStr, stringMangler) {
tags: match,
strings: split,
origStrings: split.slice()
- };
- };
- this.join = function (obj) {
+ }
+ }
+ function join(obj) {
var lst = obj.strings.slice(-1);
for (var i=obj.tags.length-1; i>-1; i--) {
lst.push(obj.tags[i]);
@@ -3374,8 +3392,8 @@ CSL.Doppeler = function(rexStr, stringMangler) {
}
lst.reverse();
return lst.join("");
- };
-};
+ }
+}
CSL.Engine.prototype.normalDecorIsOrphan = function (blob, params) {
if (params[1] === "normal") {
var use_param = false;
@@ -3520,9 +3538,9 @@ CSL.Engine.prototype.getSortFunc = function () {
a = a.split("-");
b = b.split("-");
if (a.length < b.length) {
- return 1;
+ return 1
} else if (a.length > b.length) {
- return -1;
+ return -1
} else {
a = a.slice(-1)[0];
b = b.slice(-1)[0];
@@ -3720,7 +3738,7 @@ CSL.Output.Queue.prototype.pushFormats = function (tokenstore) {
tokenstore.empty = this.empty;
this.formats.push(tokenstore);
};
-CSL.Output.Queue.prototype.popFormats = function () {
+CSL.Output.Queue.prototype.popFormats = function (tokenstore) {
this.formats.pop();
};
CSL.Output.Queue.prototype.startTag = function (name, token) {
@@ -3737,8 +3755,8 @@ CSL.Output.Queue.prototype.endTag = function (name) {
this.closeLevel(name);
this.popFormats();
};
-CSL.Output.Queue.prototype.openLevel = function (token) {
- var blob, curr;
+CSL.Output.Queue.prototype.openLevel = function (token, ephemeral) {
+ var blob, curr, x, has_ephemeral;
if ("object" === typeof token) {
blob = new CSL.Blob(undefined, token);
} else if ("undefined" === typeof token) {
@@ -4064,7 +4082,7 @@ CSL.Output.Queue.prototype.clearlevel = function () {
}
};
CSL.Output.Queue.prototype.renderBlobs = function (blobs, delim, in_cite, parent) {
- var state, ret, ret_last_char, use_delim, blob, pos, len, ppos, llen, str, params, txt_esc;
+ var state, ret, ret_last_char, use_delim, i, blob, pos, len, ppos, llen, pppos, lllen, res, str, params, txt_esc;
txt_esc = CSL.getSafeEscape(this.state);
if (!delim) {
delim = "";
@@ -4195,12 +4213,16 @@ CSL.Output.Queue.adjust = function (punctInQuote) {
var NO_SWAP_IN = {
";": true,
":": true
- };
+ }
var NO_SWAP_OUT = {
".": true,
"!": true,
"?": true
- };
+ }
+ this.upward = upward;
+ this.leftward = leftward;
+ this.downward = downward;
+ this.fix = fix;
var LtoR_MAP = {
"!": {
".": "!",
@@ -4244,7 +4266,7 @@ CSL.Output.Queue.adjust = function (punctInQuote) {
",": ";,",
".": ";"
}
- };
+ }
var SWAP_IN = {};
var SWAP_OUT = {};
var PUNCT = {};
@@ -4272,17 +4294,13 @@ CSL.Output.Queue.adjust = function (punctInQuote) {
}
function blobIsNumber(blob) {
return ("number" === typeof blob.num || (blob.blobs && blob.blobs.length === 1 && "number" === typeof blob.blobs[0].num));
- }
+ };
function blobEndsInNumber(blob) {
if ("number" === typeof blob.num) {
return true;
}
- if (!blob.blobs || "object" !== typeof blob.blobs) {
- return false;
- }
- if (blobEndsInNumber(blob.blobs[blob.blobs.length-1])) {
- return true;
- }
+ if (!blob.blobs || "object" !== typeof blob.blobs) return false;
+ if (blobEndsInNumber(blob.blobs[blob.blobs.length-1])) return true;
}
function blobHasDecorations(blob,includeQuotes) {
var ret = false;
@@ -4299,7 +4317,7 @@ CSL.Output.Queue.adjust = function (punctInQuote) {
}
}
return ret;
- }
+ };
function blobHasDescendantQuotes(blob) {
if (blob.decorations) {
for (var i=0,ilen=blob.decorations.length;i-1;i--) {
+ var endFlag = i === (parent.blobs.length-1);
this.upward(parent.blobs[i]);
var parentStrings = parent.strings;
var childStrings = parent.blobs[i].strings;
@@ -4454,7 +4469,7 @@ CSL.Output.Queue.adjust = function (punctInQuote) {
}
}
}
- }
+ };
function leftward (parent) {
if ("object" !== typeof parent || "object" !== typeof parent.blobs || !parent.blobs.length) {
return;
@@ -4479,8 +4494,8 @@ CSL.Output.Queue.adjust = function (punctInQuote) {
}
}
}
- }
- function downward (parent) {
+ };
+ function downward (parent, top) {
if (parent.blobs && "string" == typeof parent.blobs) {
if (PUNCT[parent.strings.suffix.slice(0,1)]
&& parent.strings.suffix.slice(0,1) === parent.blobs.slice(-1)) {
@@ -4510,6 +4525,8 @@ CSL.Output.Queue.adjust = function (punctInQuote) {
parentStrings.delimiter = parentStrings.delimiter.slice(1);
}
}
+ var parentDecorations = blobHasDecorations(parent, true);
+ var parentIsNumber = blobIsNumber(parent);
for (var i=parent.blobs.length-1;i>-1;i--) {
var child = parent.blobs[i];
var childStrings = parent.blobs[i].strings;
@@ -4571,11 +4588,11 @@ CSL.Output.Queue.adjust = function (punctInQuote) {
}
if (!childIsNumber && !childDecorations && PUNCT[childStrings.suffix.slice(0,1)]
&& "string" === typeof child.blobs) {
- mergeChars(child, 'blobs', child, 'suffix');
+ mergeChars(child, 'blobs', child, 'suffix')
}
this.downward(parent.blobs[i]);
}
- }
+ };
function swapToTheLeft (child) {
var childChar = child.strings.suffix.slice(0,1);
if ("string" === typeof child.blobs) {
@@ -4632,12 +4649,8 @@ CSL.Output.Queue.adjust = function (punctInQuote) {
}
}
return lastChar;
- }
- this.upward = upward;
- this.leftward = leftward;
- this.downward = downward;
- this.fix = fix;
-};
+ };
+}
CSL.Engine.Opt = function () {
this.has_disambiguate = false;
this.mode = "html";
@@ -4787,8 +4800,6 @@ CSL.Engine.Opt = function () {
this.development_extensions.spoof_institutional_affiliations = false;
this.development_extensions.force_jurisdiction = false;
this.development_extensions.parse_names = true;
- this.development_extensions.hanging_indent_legacy_number = true;
- this.development_extensions.throw_on_empty = false;
};
CSL.Engine.Tmp = function () {
this.names_max = new CSL.Stack();
@@ -4849,7 +4860,7 @@ CSL.Engine.Tmp = function () {
this.loadedItemIDs = {};
};
CSL.Engine.Fun = function (state) {
- this.match = new CSL.Util.Match();
+ this.match = new CSL.Util.Match;
this.suffixator = new CSL.Util.Suffixator(CSL.SUFFIX_CHARS);
this.romanizer = new CSL.Util.Romanizer();
this.ordinalizer = new CSL.Util.Ordinalizer(state);
@@ -4863,8 +4874,6 @@ CSL.Engine.Build = function () {
this.postponed_macro = false;
this.layout_flag = false;
this.name = false;
- this.names_variables = [[]];
- this.name_label = [{}];
this.form = false;
this.term = false;
this.macro = {};
@@ -4937,26 +4946,6 @@ CSL.Engine.CitationSort = function () {
this.opt.topdecor = [];
this.root = "citation";
};
-CSL.Engine.InText = function () {
- this.opt = {
- inheritedAttributes: {}
- };
- this.tokens = [];
- this.opt.collapse = [];
- this.opt["disambiguate-add-names"] = false;
- this.opt["disambiguate-add-givenname"] = false;
- this.opt["disambiguate-add-year-suffix"] = false;
- this.opt["givenname-disambiguation-rule"] = "by-cite";
- this.opt["near-note-distance"] = 5;
- this.opt.topdecor = [];
- this.opt.layout_decorations = [];
- this.opt.layout_prefix = "";
- this.opt.layout_suffix = "";
- this.opt.layout_delimiter = "";
- this.opt.sort_locales = [];
- this.opt.max_number_of_names = 0;
- this.root = "intext";
-};
CSL.Engine.prototype.previewCitationCluster = function (citation, citationsPre, citationsPost, newMode) {
var oldMode = this.opt.mode;
this.setOutputFormat(newMode);
@@ -5057,7 +5046,7 @@ CSL.Engine.prototype.processCitationCluster = function (citation, citationsPre,
throw err;
}
citationByIndex.push(this.registry.citationreg.citationById[c[0]]);
- citationById[c[0]] = this.registry.citationreg.citationById[c[0]];
+ citationById[c[0]] = this.registry.citationreg.citationById[c[0]];;
}
citationByIndex.push(citation);
citationById[citation.citationID] = citation;
@@ -5205,7 +5194,7 @@ CSL.Engine.prototype.processCitationCluster = function (citation, citationsPre,
item[1]["near-note"] = false;
if (this.registry.citationreg.citationsByItemId[myid]) {
if (this.opt.xclass === 'note' && this.opt.has_disambiguate) {
- var oldCount = this.registry.registry[myid]["citation-count"];
+ var oldCount = this.registry.registry[myid]["citation-count"]
var newCount = this.registry.citationreg.citationsByItemId[myid].length;
this.registry.registry[myid]["citation-count"] = this.registry.citationreg.citationsByItemId[myid].length;
if ("number" === typeof oldCount) {
@@ -5226,7 +5215,7 @@ CSL.Engine.prototype.processCitationCluster = function (citation, citationsPre,
}
}
var oldlastid;
- if ("undefined" === typeof first_ref[myid] && onecitation.properties.mode !== "author-only") {
+ if ("undefined" === typeof first_ref[myid]) {
first_ref[myid] = onecitation.properties.noteIndex;
if (this.registry.registry[myid]) {
this.registry.registry[myid]['first-reference-note-number'] = onecitation.properties.noteIndex;
@@ -5238,11 +5227,7 @@ CSL.Engine.prototype.processCitationCluster = function (citation, citationsPre,
var suprame = false;
if (j > 0) {
try {
- var old_last_id_offset = 1;
- if (citations[j-1].properties.mode === "author-only" && j > 1) {
- old_last_id_offset = 2;
- }
- oldlastid = citations[j - old_last_id_offset].sortedItems.slice(-1)[0][1].id;
+ oldlastid = citations[j - 1].sortedItems.slice(-1)[0][1].id;
} catch (e) {
var err = "CSL Error\n";
err += " " + e;
@@ -5335,9 +5320,6 @@ CSL.Engine.prototype.processCitationCluster = function (citation, citationsPre,
item[1].position = CSL.POSITION_SUBSEQUENT;
}
if (suprame || ibidme) {
- if (onecitation.properties.mode === "author-only") {
- item[1].position = CSL.POSITION_FIRST;
- }
if (first_ref[myid] != onecitation.properties.noteIndex) {
item[1]["first-reference-note-number"] = first_ref[myid];
if (this.registry.registry[myid]) {
@@ -5399,7 +5381,7 @@ CSL.Engine.prototype.processCitationCluster = function (citation, citationsPre,
var ret = [];
if (flag === CSL.PREVIEW) {
try {
- ret = this.process_CitationCluster.call(this, citation.sortedItems, citation);
+ ret = this.process_CitationCluster.call(this, citation.sortedItems, citation.citationID);
} catch (e) {
CSL.error("Error running CSL processor for preview: "+e);
}
@@ -5439,7 +5421,7 @@ CSL.Engine.prototype.processCitationCluster = function (citation, citationsPre,
this.tmp.citation_id = "" + mycitation.citationID;
obj = [];
obj.push(mycitation.properties.index);
- obj.push(this.process_CitationCluster.call(this, mycitation.sortedItems, mycitation));
+ obj.push(this.process_CitationCluster.call(this, mycitation.sortedItems, mycitation.citationID));
obj.push(mycitation.citationID);
ret.push(obj);
}
@@ -5450,7 +5432,7 @@ CSL.Engine.prototype.processCitationCluster = function (citation, citationsPre,
this.tmp.citation_id = "" + citation.citationID;
obj = [];
obj.push(citationsPre.length);
- obj.push(this.process_CitationCluster.call(this, sortedItems, citation));
+ obj.push(this.process_CitationCluster.call(this, sortedItems, citation.citationID));
obj.push(citation.citationID);
ret.push(obj);
ret.sort(function (a, b) {
@@ -5466,33 +5448,10 @@ CSL.Engine.prototype.processCitationCluster = function (citation, citationsPre,
this.registry.return_data.citation_errors = this.tmp.citation_errors.slice();
return [this.registry.return_data, ret];
};
-CSL.Engine.prototype.process_CitationCluster = function (sortedItems, citation) {
- var str = "";
+CSL.Engine.prototype.process_CitationCluster = function (sortedItems, citationID) {
+ var str;
this.parallel.StartCitation(sortedItems);
- if (citation && citation.properties && citation.properties.mode === "composite") {
- citation.properties.mode = "author-only";
- var firstChunk = CSL.getCitationCluster.call(this, sortedItems, citation);
- citation.properties.mode = "suppress-author";
- var secondChunk = "";
- if (citation.properties.infix) {
- this.output.append(citation.properties.infix);
- secondChunk = this.output.string(this, this.output.queue);
- if ("object" === typeof secondChunk) {
- secondChunk = secondChunk.join("");
- }
- }
- var thirdChunk = CSL.getCitationCluster.call(this, sortedItems, citation);
- citation.properties.mode = "composite";
- if (firstChunk && secondChunk && CSL.SWAPPING_PUNCTUATION.concat(["\u2019", "\'"]).indexOf(secondChunk[0]) > -1) {
- firstChunk += secondChunk;
- secondChunk = false;
- }
- str = [firstChunk, secondChunk, thirdChunk].filter(function(obj) {
- return obj;
- }).join(" ");
- } else {
- str = CSL.getCitationCluster.call(this, sortedItems, citation);
- }
+ str = CSL.getCitationCluster.call(this, sortedItems, citationID);
return str;
};
CSL.Engine.prototype.makeCitationCluster = function (rawList) {
@@ -5535,11 +5494,11 @@ CSL.Engine.prototype.makeCitationCluster = function (rawList) {
}
this.tmp.citation_errors = [];
this.parallel.StartCitation(inputList);
- var str = CSL.getCitationCluster.call(this, inputList);
+ str = CSL.getCitationCluster.call(this, inputList);
return str;
};
CSL.getAmbiguousCite = function (Item, disambig, visualForm, item) {
- var ret;
+ var use_parallels, ret;
var flags = this.tmp.group_context.tip;
var oldTermSiblingLayer = {
term_intended: flags.term_intended,
@@ -5551,7 +5510,7 @@ CSL.getAmbiguousCite = function (Item, disambig, visualForm, item) {
condition: flags.condition,
force_suppress: flags.force_suppress,
done_vars: flags.done_vars.slice()
- };
+ }
if (disambig) {
this.tmp.disambig_request = disambig;
} else {
@@ -5577,7 +5536,6 @@ CSL.getAmbiguousCite = function (Item, disambig, visualForm, item) {
this.tmp.area = "citation";
this.tmp.root = "citation";
this.parallel.use_parallels = (this.parallel.use_parallels === true || this.parallel.use_parallels === null) ? null : false;
- var origSuppressDecorations = this.tmp.suppress_decorations;
this.tmp.suppress_decorations = true;
this.tmp.just_looking = true;
CSL.getCite.call(this, Item, itemSupp, null, false);
@@ -5594,7 +5552,7 @@ CSL.getAmbiguousCite = function (Item, disambig, visualForm, item) {
}
var ret = this.output.string(this, this.output.queue);
this.tmp.just_looking = false;
- this.tmp.suppress_decorations = origSuppressDecorations;
+ this.tmp.suppress_decorations = false;
this.parallel.use_parallels = this.parallel.use_parallels === null ? true : false;
this.tmp.group_context.replace(oldTermSiblingLayer);
return ret;
@@ -5626,20 +5584,8 @@ CSL.getSpliceDelimiter = function (last_locator, last_collapsed, pos) {
}
return this.tmp.splice_delimiter;
};
-CSL.getCitationCluster = function (inputList, citation) {
- var result, objects, myparams, len, pos, item, last_collapsed, params, empties, composite, compie, myblobs, Item, llen, ppos, obj, preceding_item, txt_esc, error_object, citationID, authorOnly, suppressAuthor;
- var citation_prefix = "";
- this.output.checkNestedBrace = new CSL.checkNestedBrace(this);
- if (citation) {
- citationID = citation.citationID;
- authorOnly = citation.properties.mode === "author-only" ? !!citation.properties.mode : false;
- if (this.opt.xclass !== "note") {
- suppressAuthor = citation.properties.mode === "suppress-author" ? !!citation.properties.mode : false;
- }
- if (citation.properties.prefix) {
- citation_prefix = CSL.checkPrefixSpaceAppend(this, citation.properties.prefix);
- }
- }
+CSL.getCitationCluster = function (inputList, citationID) {
+ var result, objects, myparams, len, pos, item, last_collapsed, params, empties, composite, compie, myblobs, Item, llen, ppos, obj, preceding_item, txt_esc, error_object;
inputList = inputList ? inputList : [];
this.tmp.last_primary_names_string = false;
txt_esc = CSL.getSafeEscape(this);
@@ -5652,7 +5598,8 @@ CSL.getCitationCluster = function (inputList, citation) {
this.tmp.last_years_used = [];
this.tmp.backref_index = [];
this.tmp.cite_locales = [];
- var use_layout_prefix = this.output.checkNestedBrace.update(this.citation.opt.layout_prefix + citation_prefix);
+ this.output.checkNestedBrace = new CSL.checkNestedBrace(this);
+ var use_layout_prefix = this.output.checkNestedBrace.update(this.citation.opt.layout_prefix);
var suppressTrailingPunctuation = false;
if (this.opt.xclass === "note" && this.citation.opt.suppressTrailingPunctuation) {
suppressTrailingPunctuation = true;
@@ -5709,15 +5656,6 @@ CSL.getCitationCluster = function (inputList, citation) {
}
myparams = [];
len = inputList.length;
- if (inputList[0] && inputList[0][1]) {
- if (authorOnly) {
- delete inputList[0][1]["suppress-author"];
- inputList[0][1]["author-only"] = true;
- } else if (suppressAuthor) {
- delete inputList[0][1]["author-only"];
- inputList[0][1]["suppress-author"] = true;
- }
- }
for (pos = 0; pos < len; pos += 1) {
Item = inputList[pos][0];
item = inputList[pos][1];
@@ -5777,18 +5715,17 @@ CSL.getCitationCluster = function (inputList, citation) {
params.suppress_decorations = this.tmp.suppress_decorations;
params.have_collapsed = this.tmp.have_collapsed;
myparams.push(params);
- if (item["author-only"]) {
- break;
- }
}
this.tmp.has_purged_parallel = false;
this.parallel.PruneOutputQueue(this);
empties = 0;
myblobs = this.output.queue.slice();
- var citation_suffix = "";
- if (citation) {
- citation_suffix = CSL.checkSuffixSpacePrepend(this, citation.properties.suffix);
- }
+ var fakeblob = {
+ strings: {
+ suffix: this.citation.opt.layout_suffix,
+ delimiter: this.citation.opt.layout_delimiter
+ }
+ };
var suffix = this.citation.opt.layout_suffix;
var last_locale = this.tmp.cite_locales[this.tmp.cite_locales.length - 1];
if (last_locale && this.tmp.cite_affixes[this.tmp.area][last_locale] && this.tmp.cite_affixes[this.tmp.area][last_locale].suffix) {
@@ -5797,7 +5734,14 @@ CSL.getCitationCluster = function (inputList, citation) {
if (CSL.TERMINAL_PUNCTUATION.slice(0, -1).indexOf(suffix.slice(0, 1)) > -1) {
suffix = suffix.slice(0, 1);
}
- suffix = this.output.checkNestedBrace.update(citation_suffix + suffix);
+ var delimiter = this.citation.opt.layout_delimiter;
+ if (!delimiter) {
+ delimiter = "";
+ }
+ if (CSL.TERMINAL_PUNCTUATION.slice(0, -1).indexOf(delimiter.slice(0, 1)) > -1) {
+ delimiter = delimiter.slice(0, 1);
+ }
+ suffix = this.output.checkNestedBrace.update(suffix);
for (var i=0,ilen=this.output.queue.length;i 0) {
- this.tmp.area = "intext";
- }
this.tmp.cite_renders_content = false;
- this.tmp.probably_rendered_something = false;
this.parallel.StartCite(Item, item, prevItemID);
CSL.citeStart.call(this, Item, item, blockShadowNumberReset);
next = 0;
@@ -5962,7 +5883,6 @@ CSL.getCite = function (Item, item, prevItemID, blockShadowNumberReset) {
this.tmp.bibliography_errors.push(error_object);
}
}
- this.tmp.area = areaOrig;
return "" + Item.id;
};
CSL.citeStart = function (Item, item, blockShadowNumberReset) {
@@ -6062,7 +5982,7 @@ CSL.citeEnd = function (Item, item) {
this.tmp.issued_date.list.push(buf.pop());
}
if (this.parallel.use_parallels) {
- this.parallel.cite.issued = false;
+ this.parallel.cite["issued"] = false;
}
}
this.tmp.issued_date = false;
@@ -6071,28 +5991,6 @@ CSL.citeEnd = function (Item, item) {
CSL.Engine.prototype.makeBibliography = function (bibsection) {
var debug, ret, params, maxoffset, item, len, pos, tok, tokk, tokkk, entry_ids, entry_strings;
debug = false;
- if (!bibsection && (this.bibliography.opt.exclude_types || this.bibliography.opt.exclude_with_fields)) {
- bibsection = {
- exclude: []
- };
- if (this.bibliography.opt.exclude_types) {
- for (var i in this.bibliography.opt.exclude_types) {
- var val = this.bibliography.opt.exclude_types[i];
- bibsection.exclude.push({
- field: "type",
- value: val
- });
- }
- }
- if (this.bibliography.opt.exclude_with_fields) {
- for (var i in this.bibliography.opt.exclude_with_fields) {
- var field = this.bibliography.opt.exclude_with_fields[i];
- bibsection.exclude.push({
- field: field, value: true
- });
- }
- }
- }
if (!this.bibliography.tokens.length) {
return false;
}
@@ -6163,20 +6061,15 @@ CSL.getBibliographyEntries = function (bibsection) {
return false;
}
function eval_spec(a, b) {
- if ("boolean" === typeof a || !a) {
- if (a) {
- return !!b;
- } else {
- return !b;
- }
+ if ((a === "none" || !a) && !b) {
+ return true;
+ }
+ if ("string" === typeof b) {
+ return eval_string(a, b);
+ } else if (!b) {
+ return false;
} else {
- if ("string" === typeof b) {
- return eval_string(a, b);
- } else if (!b) {
- return false;
- } else {
- return eval_list(a, b);
- }
+ return eval_list(a, b);
}
}
skips = {};
@@ -6402,7 +6295,7 @@ CSL.Engine.prototype.rebuildProcessorState = function (citations, mode, uncitedI
this.updateUncitedItems(uncitedItemIDs);
this.setOutputFormat(oldMode);
return ret;
-};
+}
CSL.Engine.prototype.restoreProcessorState = function (citations) {
var i, ilen, j, jlen, item, Item, newitem, citationList, itemList, sortedItems;
citationList = [];
@@ -6502,6 +6395,7 @@ CSL.Engine.prototype.updateItems = function (idList, nosort, rerun_ambigs, impli
};
CSL.Engine.prototype.updateUncitedItems = function (idList, nosort) {
var idHash;
+ var debug = false;
var oldArea = this.tmp.area;
var oldRoot = this.tmp.root;
var oldExtension = this.tmp.extension;
@@ -6509,8 +6403,8 @@ CSL.Engine.prototype.updateUncitedItems = function (idList, nosort) {
nosort = true;
}
this.tmp.area = "citation";
- this.tmp.root = "citation";
- this.tmp.extension = "";
+ this.tmp.root = "citation"
+ this.tmp.extension = ""
this.tmp.loadedItemIDs = {};
if (!idList) {
idList = [];
@@ -6615,7 +6509,7 @@ CSL.Engine.prototype.localeConfigure = function (langspec, beShy) {
}
};
CSL.Engine.prototype.localeSet = function (myxml, lang_in, lang_out) {
- var blob, locale, nodes, attributes, pos, term, form, termname, styleopts, date, attrname, len, genderform, target, i, ilen;
+ var blob, locale, nodes, attributes, pos, ppos, term, form, termname, styleopts, attr, date, attrname, len, genderform, target, i, ilen;
lang_in = lang_in.replace("_", "-");
lang_out = lang_out.replace("_", "-");
if (this.opt.development_extensions.normalize_lang_keys_to_lowercase) {
@@ -6672,6 +6566,7 @@ CSL.Engine.prototype.localeSet = function (myxml, lang_in, lang_out) {
termname = "sub-verbo";
}
if (termname.slice(0,7) === "ordinal") {
+ var termstring = myxml.getNodeValue(term);
if (termname === "ordinal") {
ordinals101_toggle = true;
} else {
@@ -6831,7 +6726,7 @@ CSL.getLocaleNames = function (myxml, preferredLocale) {
function extendLocaleList(localeList, locale) {
var forms = ["base", "best"];
if (locale) {
- var normalizedLocale = CSL.localeResolve(locale);
+ normalizedLocale = CSL.localeResolve(locale);
for (var i=0,ilen=forms.length;i 1
- && publisher_lst.length === publisher_place_lst.length) {
- state.publisherOutput = new CSL.PublisherOutput(state, this);
- state.publisherOutput["publisher-list"] = publisher_lst;
- state.publisherOutput["publisher-place-list"] = publisher_place_lst;
- }
+ func = function (state, Item) {
+ if (this.strings["subgroup-delimiter"]
+ && Item.publisher && Item["publisher-place"]) {
+ var publisher_lst = Item.publisher.split(/;\s*/);
+ var publisher_place_lst = Item["publisher-place"].split(/;\s*/);
+ if (publisher_lst.length > 1
+ && publisher_lst.length === publisher_place_lst.length) {
+ state.publisherOutput = new CSL.PublisherOutput(state, this);
+ state.publisherOutput["publisher-list"] = publisher_lst;
+ state.publisherOutput["publisher-place-list"] = publisher_place_lst;
}
- };
- this.execs.push(func);
- }
+ }
+ };
+ this.execs.push(func);
}
if (this.juris) {
+ for (var x=0,xlen=target.length;x -1) {
- var func = function (state) {
+ var func = function (state, Item) {
if ("string" === typeof this.strings.delimiter) {
state.tmp.institution_delimiter = this.strings.delimiter;
} else {
state.tmp.institution_delimiter = state.tmp.name_delimiter;
}
+ var myand, and_default_prefix, and_suffix;
if ("text" === state.inheritOpt(this, "and")) {
this.and_term = state.getTerm("and", "long", 0);
} else if ("symbol" === state.inheritOpt(this, "and")) {
@@ -7710,7 +7591,7 @@ CSL.Node.institution = {
}
target.push(this);
},
- configure: function (state) {
+ configure: function (state, pos) {
if ([CSL.SINGLETON, CSL.START].indexOf(this.tokentype) > -1) {
state.build.has_institution = true;
}
@@ -7721,16 +7602,16 @@ CSL.Node["institution-part"] = {
var func;
if ("long" === this.strings.name) {
if (this.strings["if-short"]) {
- func = function (state) {
+ func = function (state, Item) {
state.nameOutput.institutionpart["long-with-short"] = this;
};
} else {
- func = function (state) {
+ func = function (state, Item) {
state.nameOutput.institutionpart["long"] = this;
};
}
} else if ("short" === this.strings.name) {
- func = function (state) {
+ func = function (state, Item) {
state.nameOutput.institutionpart["short"] = this;
};
}
@@ -7741,19 +7622,19 @@ CSL.Node["institution-part"] = {
CSL.Node.key = {
build: function (state, target) {
target = state[state.build.root + "_sort"].tokens;
- var func;
+ var func, i, ilen;
var debug = false;
var start_key = new CSL.Token("key", CSL.START);
state.tmp.root = state.build.root;
start_key.strings["et-al-min"] = state.inheritOpt(this, "et-al-min");
start_key.strings["et-al-use-first"] = state.inheritOpt(this, "et-al-use-first");
start_key.strings["et-al-use-last"] = state.inheritOpt(this, "et-al-use-last");
- func = function (state) {
+ func = function (state, Item) {
state.tmp.done_vars = [];
};
start_key.execs.push(func);
state.opt.citation_number_sort_direction = this.strings.sort_direction;
- func = function (state) {
+ func = function (state, Item) {
state.output.openLevel("empty");
};
start_key.execs.push(func);
@@ -7769,7 +7650,7 @@ CSL.Node.key = {
if (CSL.DATE_VARIABLES.indexOf(this.variables[0]) > -1) {
state.build.date_key = true;
}
- func = function (state) {
+ func = function (state, Item) {
state.tmp.sort_key_flag = true;
if (state.inheritOpt(this, "et-al-min")) {
state.tmp["et-al-min"] = state.inheritOpt(this, "et-al-min");
@@ -7817,7 +7698,8 @@ CSL.Node.key = {
single_text.dateparts = this.dateparts;
if (CSL.NUMERIC_VARIABLES.indexOf(variable) > -1) {
func = function (state, Item) {
- var num = false;
+ var num, m;
+ num = false;
if ("citation-number" === variable) {
num = state.registry.registry[Item.id].seq.toString();
} else {
@@ -7857,7 +7739,7 @@ CSL.Node.key = {
CSL.expandMacro.call(state, token, target);
}
var end_key = new CSL.Token("key", CSL.END);
- func = function (state) {
+ func = function (state, Item) {
var keystring = state.output.string(state, state.output.queue);
if (state.sys.normalizeUnicode) {
keystring = state.sys.normalizeUnicode(keystring);
@@ -7884,12 +7766,12 @@ CSL.Node.key = {
}
var key = CSL.Util.padding("" + year_suffix);
state[state.tmp.area].keys.push(key);
- };
+ }
end_key.execs.push(func);
}
state.build.date_key = false;
}
- func = function (state) {
+ func = function (state, Item) {
state.tmp["et-al-min"] = undefined;
state.tmp["et-al-use-first"] = undefined;
state.tmp["et-al-use-last"] = undefined;
@@ -7901,7 +7783,11 @@ CSL.Node.key = {
};
CSL.Node.label = {
build: function (state, target) {
+ var debug = false;
if (this.strings.term) {
+ var plural = false;
+ if (!this.strings.form) {
+ }
var func = function (state, Item, item) {
var termtxt = CSL.evaluateLabel(this, state, Item, item);
if (item && this.strings.term === "locator") {
@@ -7930,20 +7816,22 @@ CSL.Node.label = {
if (!this.strings.form) {
this.strings.form = "long";
}
- var namevars = state.build.names_variables[state.build.names_variables.length-1];
- var namelabels = state.build.name_label[state.build.name_label.length-1];
+ var namevars = state.build.names_variables.slice(-1)[0];
+ if (!state.build.name_label) {
+ state.build.name_label = {};
+ }
for (var i = 0, ilen = namevars.length; i < ilen; i += 1) {
- if (!namelabels[namevars[i]]) {
- namelabels[namevars[i]] = {};
+ if (!state.build.name_label[namevars[i]]) {
+ state.build.name_label[namevars[i]] = {};
}
}
if (!state.build.name_flag) {
for (var i = 0, ilen = namevars.length; i < ilen; i += 1) {
- namelabels[namevars[i]].before = this;
+ state.build.name_label[namevars[i]].before = this;
}
} else {
for (var i = 0, ilen = namevars.length; i < ilen; i += 1) {
- namelabels[namevars[i]].after = this;
+ state.build.name_label[namevars[i]].after = this;
}
}
}
@@ -7956,7 +7844,8 @@ CSL.Node.layout = {
function setSuffix() {
if (state.build.area === "bibliography") {
suffix_token = new CSL.Token("text", CSL.SINGLETON);
- func = function(state) {
+ func = function(state, Item, item) {
+ var last_locale = state.tmp.cite_locales[state.tmp.cite_locales.length - 1];
var suffix;
if (state.tmp.cite_affixes[state.tmp.area][state.tmp.last_cite_locale]) {
suffix = state.tmp.cite_affixes[state.tmp.area][state.tmp.last_cite_locale].suffix;
@@ -7989,7 +7878,7 @@ CSL.Node.layout = {
&& !state.tmp.just_looking
&& Item.system_id
&& state.tmp.area === "citation") {
- var cite_entry = new CSL.Token("group", CSL.START);
+ cite_entry = new CSL.Token("group", CSL.START);
cite_entry.decorations = [["@cite", "entry"]];
state.output.startTag("cite_entry", cite_entry);
state.output.current.value().item_id = Item.system_id;
@@ -7998,7 +7887,7 @@ CSL.Node.layout = {
state.output.current.value().suffix_txt = item.suffix_txt;
}
}
- };
+ }
this.execs.push(func);
}
if (this.tokentype === CSL.START && !state.tmp.cite_affixes[state.build.area]) {
@@ -8015,11 +7904,11 @@ CSL.Node.layout = {
state.tmp.rendered_name = false;
};
this.execs.push(func);
- func = function (state) {
+ func = function (state, Item) {
state.tmp.sort_key_flag = false;
};
this.execs.push(func);
- func = function (state) {
+ func = function (state, Item) {
state.tmp.nameset_counter = 0;
};
this.execs.push(func);
@@ -8033,7 +7922,7 @@ CSL.Node.layout = {
}
}
state.output.openLevel(tok);
- };
+ }
this.execs.push(func);
target.push(this);
if (state.opt.development_extensions.rtl_support && false) {
@@ -8043,12 +7932,27 @@ CSL.Node.layout = {
if (state.build.area === "citation") {
prefix_token = new CSL.Token("text", CSL.SINGLETON);
func = function (state, Item, item) {
+ var sp;
if (item && item.prefix) {
- var prefix = CSL.checkPrefixSpaceAppend(state, item.prefix);
+ sp = "";
+ var test_prefix = item.prefix.replace(/<[^>]+>/g, "").replace(/["'\u201d\u2019\u00bb\u202f\u00a0 ]+$/g,"");
+ var test_char = test_prefix.slice(-1);
+ if (test_prefix.match(CSL.ENDSWITH_ROMANESQUE_REGEXP)) {
+ sp = " ";
+ } else if (CSL.TERMINAL_PUNCTUATION.slice(0,-1).indexOf(test_char) > -1) {
+ sp = " ";
+ } else if (test_char.match(/[\)\],0-9]/)) {
+ sp = " ";
+ }
+ var ignorePredecessor = false;
+ if (CSL.TERMINAL_PUNCTUATION.slice(0,-1).indexOf(test_char) > -1 && item.prefix.trim().indexOf(" ") > -1) {
+ state.tmp.term_predecessor = false;
+ ignorePredecessor = true;
+ }
+ var prefix = (item.prefix + sp).replace(/\s+/g, " ");
if (!state.tmp.just_looking) {
prefix = state.output.checkNestedBrace.update(prefix);
}
- var ignorePredecessor = CSL.checkIgnorePredecessor(state, prefix);
state.output.append(prefix, this, false, ignorePredecessor);
}
};
@@ -8129,17 +8033,22 @@ CSL.Node.layout = {
func = function (state, Item, item) {
var sp;
if (item && item.suffix) {
- var suffix = CSL.checkSuffixSpacePrepend(state, item.suffix);
+ sp = "";
+ if (item.suffix.match(CSL.STARTSWITH_ROMANESQUE_REGEXP)
+ || ['[','('].indexOf(item.suffix.slice(0,1)) > -1) {
+ sp = " ";
+ }
+ var suffix = item.suffix;
if (!state.tmp.just_looking) {
suffix = state.output.checkNestedBrace.update(suffix);
}
- state.output.append((suffix), this);
+ state.output.append((sp + suffix), this);
}
};
suffix_token.execs.push(func);
target.push(suffix_token);
}
- func = function (state) {
+ func = function (state, Item) {
state.output.closeLevel();
};
this.execs.push(func);
@@ -8151,7 +8060,7 @@ CSL.Node.layout = {
&& state.tmp.area === "citation") {
state.output.endTag(); // closes citation link wrapper
}
- };
+ }
this.execs.push(func);
target.push(this);
state.build.layout_flag = false;
@@ -8161,130 +8070,9 @@ CSL.Node.layout = {
}
};
CSL.Node.macro = {
- build: function () {}
+ build: function (state, target) {}
};
-CSL.Node.alternative = {
- build: function (state, target) {
- if (this.tokentype === CSL.START) {
- var choose_tok = new CSL.Token("choose", CSL.START);
- CSL.Node["choose"].build.call(choose_tok, state, target);
- var if_tok = new CSL.Token("if", CSL.START);
- CSL.Attributes["@alternative-node-internal"].call(if_tok, state);
- CSL.Node["if"].build.call(if_tok, state, target);
- var func = function(state, Item) {
- state.tmp.oldItem = Item;
- state.tmp.oldLang = state.opt.lang;
- state.tmp.abort_alternative = true;
- if (Item["language-name"] && Item["language-name-original"]) {
- var newItem = JSON.parse(JSON.stringify(Item));
- newItem.language = newItem["language-name"];
- var langspec = CSL.localeResolve(newItem.language, state.opt["default-locale"][0]);
- if (state.opt.multi_layout) {
- for (var i in state.opt.multi_layout) {
- var locale_list = state.opt.multi_layout[i];
- var gotlang = false;
- for (var j in locale_list) {
- var tryspec = locale_list[j];
- if (langspec.best === tryspec.best || langspec.base === tryspec.base || langspec.bare === tryspec.bare) {
- gotlang = locale_list[0].best;
- break;
- }
- }
- if (!gotlang) {
- gotlang = state.opt["default-locale"][0];
- }
- state.opt.lang = gotlang;
- }
- }
- for (var key in newItem) {
- if (["id", "type", "language", "multi"].indexOf(key) === -1 && key.slice(0, 4) !== "alt-") {
- if (newItem.multi && newItem.multi._keys[key]) {
- var deleteme = true;
- for (var lang in newItem.multi._keys[key]) {
- if (langspec.bare === lang.replace(/^([a-zA-Z]+).*/, "$1")) {
- deleteme = false;
- break;
- }
- }
- if (deleteme) {
- delete newItem[key];
- }
- } else {
- delete newItem[key];
- }
- }
- }
- for (var key in newItem) {
- if (key.slice(0, 4) === "alt-") {
- newItem[key.slice(4)] = newItem[key];
- state.tmp.abort_alternative = false;
- } else {
- if (newItem.multi && newItem.multi._keys) {
- if (!newItem["alt-" + key] && newItem.multi._keys[key]) {
- if (newItem.multi._keys[key][langspec.best]) {
- newItem[key] = newItem.multi._keys[key][langspec.best];
- state.tmp.abort_alternative = false;
- } else if (newItem.multi._keys[key][langspec.base]) {
- newItem[key] = newItem.multi._keys[key][langspec.base];
- state.tmp.abort_alternative = false;
- } else if (newItem.multi._keys[key][langspec.bare]) {
- newItem[key] = newItem.multi._keys[key][langspec.bare];
- state.tmp.abort_alternative = false;
- }
- }
- }
- }
- }
- }
- state.output.openLevel(this);
- state.registry.refhash[Item.id] = newItem;
- state.nameOutput = new CSL.NameOutput(state, newItem);
- };
- this.execs.push(func);
- target.push(this);
- var choose_tok = new CSL.Token("choose", CSL.START);
- CSL.Node["choose"].build.call(choose_tok, state, target);
- var if_tok = new CSL.Token("if", CSL.START);
- CSL.Attributes["@alternative-node-internal"].call(if_tok, state);
- var func = function(state) {
- state.tmp.abort_alternative = true;
- }
- if_tok.execs.push(func);
- CSL.Node["if"].build.call(if_tok, state, target);
- } else if (this.tokentype === CSL.END) {
- var if_tok = new CSL.Token("if", CSL.END);
- CSL.Node["if"].build.call(if_tok, state, target);
- var choose_tok = new CSL.Token("choose", CSL.END);
- CSL.Node["choose"].build.call(choose_tok, state, target);
- var func = function(state, Item) {
- state.output.closeLevel();
- state.registry.refhash[Item.id] = state.tmp.oldItem;
- state.opt.lang = state.tmp.oldLang;
- state.nameOutput = new CSL.NameOutput(state, state.tmp.oldItem);
- state.tmp.abort_alternative = false;
- };
- this.execs.push(func);
- target.push(this);
- var if_tok = new CSL.Token("if", CSL.END);
- CSL.Node["if"].build.call(if_tok, state, target);
- var choose_tok = new CSL.Token("choose", CSL.END);
- CSL.Node["choose"].build.call(choose_tok, state, target);
- }
- }
-};
-CSL.Node["alternative-text"] = {
- build: function (state, target) {
- if (this.tokentype === CSL.SINGLETON) {
- var func = function(state, Item) {
- var Item = state.refetchItem(Item.id);
- CSL.getCite.call(state, Item);
- };
- this.execs.push(func);
- }
- target.push(this);
- }
-};
-CSL.NameOutput = function(state, Item, item) {
+CSL.NameOutput = function(state, Item, item, variables) {
this.debug = false;
this.state = state;
this.Item = Item;
@@ -8295,7 +8083,6 @@ CSL.NameOutput = function(state, Item, item) {
this._please_chop = false;
};
CSL.NameOutput.prototype.init = function (names) {
- this.requireMatch = names.requireMatch;
if (this.state.tmp.term_predecessor) {
this.state.tmp.subsequent_author_substitute_ok = false;
}
@@ -8324,22 +8111,8 @@ CSL.NameOutput.prototype.init = function (names) {
if (!this.state.tmp.value.length) {
return;
}
- var checkCommonTerm = this.checkCommonAuthor(this.requireMatch);
- if (checkCommonTerm) {
- this.state.tmp.can_substitute.pop();
- this.state.tmp.can_substitute.push(true);
- for (var i in this.variables) {
- var idx = this.state.tmp.done_vars.indexOf(this.variables[i]);
- if (idx > -1) {
- this.state.tmp.done_vars = this.state.tmp.done_vars.slice(0, idx).concat(this.state.tmp.done_vars.slice(i+1));
- }
- }
- this.state.tmp.common_term_match_fail = true;
- this.variables = [];
- }
};
CSL.NameOutput.prototype.reinit = function (names, labelVariable) {
- this.requireMatch = names.requireMatch;
this.labelVariable = labelVariable;
if (this.state.tmp.can_substitute.value()) {
this.nameset_offset = 0;
@@ -8356,18 +8129,6 @@ CSL.NameOutput.prototype.reinit = function (names, labelVariable) {
}
this.state.tmp.value = oldval;
}
- var checkCommonTerm = this.checkCommonAuthor(this.requireMatch);
- if (checkCommonTerm) {
- this.state.tmp.can_substitute.pop();
- this.state.tmp.can_substitute.push(true);
- for (var i in this.variables) {
- var idx = this.state.tmp.done_vars.indexOf(this.variables[i]);
- if (idx > -1) {
- this.state.tmp.done_vars = this.state.tmp.done_vars.slice(0, idx).concat(this.state.tmp.done_vars.slice(i+1));
- }
- }
- this.variables = [];
- }
};
CSL.NameOutput.prototype.outputNames = function () {
var i, ilen;
@@ -8414,7 +8175,7 @@ CSL.NameOutput.prototype.outputNames = function () {
return;
}
this.setEtAlParameters();
- this.setCommonTerm(this.requireMatch);
+ this.setCommonTerm();
this.state.tmp.name_node = {};
this.state.tmp.name_node.children = [];
this.renderAllNames();
@@ -8454,17 +8215,14 @@ CSL.NameOutput.prototype.outputNames = function () {
for (i = 0, ilen = blob_list.length; i < ilen; i += 1) {
this.state.output.append(blob_list[i], "literal", true);
}
- if (!this.state.tmp.just_looking && blob_list.length > 0) {
- this.state.tmp.probably_rendered_something = true;
- }
this.state.output.closeLevel("empty");
var blob = this.state.output.pop();
- this.state.tmp.name_node.top = blob;
var namesToken = CSL.Util.cloneToken(this.names);
this.state.output.append(blob, namesToken);
if (this.state.tmp.term_predecessor_name) {
this.state.tmp.term_predecessor = true;
}
+ this.state.tmp.name_node.top = this.state.output.current.value();
if (variables[0] !== "authority") {
var name_node_string = [];
var nameobjs = this.Item[variables[0]];
@@ -8562,13 +8320,11 @@ CSL.NameOutput.prototype._buildLabel = function (term, plural, position, v) {
};
CSL.NameOutput.prototype._collapseAuthor = function () {
var myqueue, mystr, oldchars;
- if (this.state.tmp.name_node.top.blobs.length === 0) {
- return;
- }
if (this.nameset_base === 0 && this.Item[this.variables[0]] && !this._first_creator_variable) {
this._first_creator_variable = this.variables[0];
}
- if ((this.state[this.state.tmp.area].opt.collapse
+ if ((this.item && this.item["suppress-author"] && this._first_creator_variable == this.variables[0])
+ || (this.state[this.state.tmp.area].opt.collapse
&& this.state[this.state.tmp.area].opt.collapse.length)
|| (this.state[this.state.tmp.area].opt.cite_group_delimiter
&& this.state[this.state.tmp.area].opt.cite_group_delimiter.length)) {
@@ -8582,7 +8338,7 @@ CSL.NameOutput.prototype._collapseAuthor = function () {
this.state.tmp.offset_characters = oldchars;
this.state.registry.authorstrings[this.Item.id] = mystr;
} else if (!this.state.tmp.just_looking
- && !this.state.tmp.suppress_decorations && ((this.state[this.state.tmp.area].opt.collapse && this.state[this.state.tmp.area].opt.collapse.length) || this.state[this.state.tmp.area].opt.cite_group_delimiter && this.state[this.state.tmp.area].opt.cite_group_delimiter)) {
+ && !this.state.tmp.suppress_decorations && (this.item["suppress-author"] || (this.state[this.state.tmp.area].opt.collapse && this.state[this.state.tmp.area].opt.collapse.length) || this.state[this.state.tmp.area].opt.cite_group_delimiter && this.state[this.state.tmp.area].opt.cite_group_delimiter)) {
mystr = "";
myqueue = this.state.tmp.name_node.top.blobs.slice(-1)[0].blobs;
oldchars = this.state.tmp.offset_characters;
@@ -8766,7 +8522,7 @@ CSL.NameOutput.prototype.divideAndTransliterateNames = function () {
}
};
CSL.NameOutput.prototype._normalizeVariableValue = function (Item, variable) {
- var names;
+ var names, name, i, ilen;
if ("string" === typeof Item[variable] || "number" === typeof Item[variable]) {
CSL.debug("name variable \"" + variable + "\" is string or number, not array. Attempting to fix.");
names = [{literal: Item[variable] + ""}];
@@ -8811,9 +8567,7 @@ CSL.NameOutput.prototype._getFreeters = function (v, values) {
CSL.NameOutput.prototype._getPersonsAndInstitutions = function (v, values) {
this.persons[v] = [];
this.institutions[v] = [];
- if (!this.state.opt.development_extensions.spoof_institutional_affiliations) {
- return;
- }
+ if (!this.state.opt.development_extensions.spoof_institutional_affiliations) return;
var persons = [];
var has_affiliates = false;
var first = true;
@@ -8933,7 +8687,7 @@ CSL.NameOutput.prototype._joinEllipsis = function (blobs, tokenname) {
CSL.NameOutput.prototype._joinAnd = function (blobs, tokenname) {
return this._join(blobs, this.state.inheritOpt(this[tokenname], "delimiter", (tokenname + "-delimiter"), ", "), this[tokenname].and.single, this[tokenname].and.multiple, tokenname);
};
-CSL.NameOutput.prototype._join = function (blobs, delimiter, single, multiple) {
+CSL.NameOutput.prototype._join = function (blobs, delimiter, single, multiple, tokenname) {
var i, ilen;
if (!blobs) {
return false;
@@ -8992,45 +8746,13 @@ CSL.NameOutput.prototype._getToken = function (tokenname) {
}
return token;
};
-CSL.NameOutput.prototype.checkCommonAuthor = function(requireMatch) {
- if (!requireMatch) {
- return false;
- }
- var common_term = false;
- if (this.variables.length === 2) {
- var variables = this.variables;
- var varnames = variables.slice();
- varnames.sort();
- common_term = varnames.join("");
- }
- if (!common_term) {
- return false;
- }
- var has_term = false;
- if (this.state.locale[this.state.opt.lang].terms[common_term]) {
- has_term = true;
- }
- if (!has_term) {
- this.state.tmp.done_vars.push(this.variables[0]);
- this.state.tmp.done_vars.push(this.variables[1]);
- return false;
- }
- var firstSet = this.Item[this.variables[0]];
- var secondSet = this.Item[this.variables[1]];
- var perfectMatch = this._compareNamesets(firstSet, secondSet);
- if (perfectMatch === true) {
- this.state.tmp.done_vars.push(this.variables[0]);
- this.state.tmp.done_vars.push(this.variables[1]);
- }
- return !perfectMatch;
-};
CSL.NameOutput.prototype.setCommonTerm = function () {
var variables = this.variables;
var varnames = variables.slice();
varnames.sort();
this.common_term = varnames.join("");
if (!this.common_term) {
- return;
+ return false;
}
var has_term = false;
if (this.label && this.label[this.variables[0]]) {
@@ -9039,7 +8761,7 @@ CSL.NameOutput.prototype.setCommonTerm = function () {
} else if (this.label[this.variables[0]].after) {
has_term = this.state.getTerm(this.common_term, this.label[this.variables[0]].after.strings.form, 0);
}
- }
+ }
if (!this.state.locale[this.state.opt.lang].terms[this.common_term]
|| !has_term
|| this.variables.length < 2) {
@@ -9072,10 +8794,11 @@ CSL.NameOutput.prototype.setCommonTerm = function () {
}
};
CSL.NameOutput.prototype._compareNamesets = function (base_nameset, nameset) {
- if (!base_nameset || !nameset || base_nameset.length !== nameset.length) {
+ if (base_nameset.length !== nameset.length) {
return false;
}
for (var i = 0, ilen = nameset.length; i < ilen; i += 1) {
+ var name = nameset[i];
for (var j = 0, jlen = CSL.NAME_PARTS.length; j < jlen; j += 1) {
var part = CSL.NAME_PARTS[j];
if (!base_nameset[i] || base_nameset[i][part] != nameset[i][part]) {
@@ -9309,7 +9032,7 @@ CSL.NameOutput.prototype._setEtAlParameter = function (type, v, j) {
if (lst.length < count && !this.state.tmp.sort_key_flag) {
if (this.etal_use_last) {
if (type === "persons") {
- this.etal_spec[v].persons[j] = 2;
+ this.etal_spec[v].persons[j] = 2
} else {
this.etal_spec[v][type] = 2;
}
@@ -9351,9 +9074,9 @@ CSL.NameOutput.prototype.renderInstitutionNames = function () {
for (var i = 0, ilen = this.variables.length; i < ilen; i += 1) {
var v = this.variables[i];
for (var j = 0, jlen = this.institutions[v].length; j < jlen; j += 1) {
- var institution;
+ var institution, institution_short, institution_long, short_style, long_style;
var name = this.institutions[v][j];
- var j, jlen, localesets;
+ var j, ret, optLangTag, jlen, key, localesets;
if (this.state.tmp.extension) {
localesets = ["sort"];
} else if (name.isInstitution || name.literal) {
@@ -9382,12 +9105,13 @@ CSL.NameOutput.prototype.renderInstitutionNames = function () {
slot.secondary = false;
slot.tertiary = false;
}
+ var res;
this.setRenderedName(name);
var institution = this._renderInstitutionName(v, name, slot, j);
this.institutions[v][j] = institution;
}
}
-};
+}
CSL.NameOutput.prototype._renderInstitutionName = function (v, name, slot, j) {
var secondary, tertiary, long_style, short_style, institution, institution_short, institution_long;
var res = this.getName(name, slot.primary, true);
@@ -9470,7 +9194,7 @@ CSL.NameOutput.prototype._renderInstitutionName = function (v, name, slot, j) {
this.state.tmp.name_node.children.push(blob);
return blob;
};
-CSL.NameOutput.prototype._composeOneInstitutionPart = function (names, slot, style) {
+CSL.NameOutput.prototype._composeOneInstitutionPart = function (names, slot, style, v) {
var primary = false, secondary = false, tertiary = false, primary_tok, secondary_tok, tertiary_tok;
if (names[0]) {
primary_tok = CSL.Util.cloneToken(style);
@@ -9484,7 +9208,7 @@ CSL.NameOutput.prototype._composeOneInstitutionPart = function (names, slot, sty
}
}
if (!hasItalic) {
- primary_tok.decorations.push(["@font-style", "italic"]);
+ primary_tok.decorations.push(["@font-style", "italic"])
}
}
}
@@ -9534,7 +9258,7 @@ CSL.NameOutput.prototype._composeOneInstitutionPart = function (names, slot, sty
institutionblob = primary;
}
return institutionblob;
-};
+}
CSL.NameOutput.prototype._renderOneInstitutionPart = function (blobs, style) {
for (var i = 0, ilen = blobs.length; i < ilen; i += 1) {
if (blobs[i]) {
@@ -9570,7 +9294,7 @@ CSL.NameOutput.prototype._renderNames = function (v, values, pos, j) {
var names = [];
for (var i = 0, ilen = values.length; i < ilen; i += 1) {
var name = values[i];
- var ret, localesets;
+ var ret, optLangTag, jlen, key, localesets;
if (this.state.tmp.extension) {
localesets = ["sort"];
} else if (name.isInstitution || name.literal) {
@@ -9609,8 +9333,8 @@ CSL.NameOutput.prototype._renderNames = function (v, values, pos, j) {
}
ret = this.joinPersons(names, pos, j);
}
- return ret;
-};
+ return ret
+}
CSL.NameOutput.prototype._renderPersonalName = function (v, name, slot, pos, i, j) {
var res = this.getName(name, slot.primary, true);
var primary = this._renderOnePersonalName(res.name, pos, i, j);
@@ -9773,11 +9497,13 @@ CSL.NameOutput.prototype._renderOnePersonalName = function (value, pos, i, j) {
dropping_particle = false;
}
}
+ if (!this.state.tmp.term_predecessor) {
+ }
var space = " ";
if (this.state.inheritOpt(this.name, "initialize-with")
&& this.state.inheritOpt(this.name, "initialize-with").match(/[\u00a0\ufeff]/)
&& ["fr", "ru", "cs"].indexOf(this.state.opt["default-locale"][0].slice(0, 2)) > -1) {
- space = "\u00a0";
+ space = "\u00a0"
}
if (has_hyphenated_non_dropping_particle) {
second = this._join([non_dropping_particle, family], "");
@@ -9890,8 +9616,9 @@ CSL.NameOutput.prototype._familyName = function (name) {
CSL.NameOutput.prototype._givenName = function (name, pos, i) {
var ret;
var formIsShort = this.state.inheritOpt(this.name, "form", "name-form", "long") !== "long";
- var initializeIsTurnedOn = this.state.inheritOpt(this.name, "initialize") !== false;
+ var initializeIsTurnedOn = !(this.state.inheritOpt(this.name, "initialize") === false);
var hasInitializeWith = "string" === typeof this.state.inheritOpt(this.name, "initialize-with") && !name.block_initialize;
+ var inBibliography = this.state.tmp.area.slice(0, 12) === "bibliography";
var defaultLevel;
var useLevel;
if (name["full-form-always"]) {
@@ -9954,8 +9681,8 @@ CSL.NameOutput.prototype._nameSuffix = function (name) {
}
return false;
};
-CSL.NameOutput.prototype._getLongStyle = function (name) {
- var long_style;
+CSL.NameOutput.prototype._getLongStyle = function (name, v, i) {
+ var long_style, short_style;
if (name["short"].length) {
if (this.institutionpart["long-with-short"]) {
long_style = this.institutionpart["long-with-short"];
@@ -9980,6 +9707,7 @@ CSL.NameOutput.prototype._getShortStyle = function () {
return short_style;
};
CSL.NameOutput.prototype._parseName = function (name) {
+ var m, idx;
if (!name["parse-names"] && "undefined" !== typeof name["parse-names"]) {
return name;
}
@@ -10023,7 +9751,7 @@ CSL.NameOutput.prototype.getName = function (name, slotLocaleset, fallback, stop
if (slotLocaleset !== 'locale-orig') {
foundTag = false;
if (name.multi) {
- var langTags = this.state.opt[slotLocaleset];
+ var langTags = this.state.opt[slotLocaleset]
for (var i = 0, ilen = langTags.length; i < ilen; i += 1) {
langTag = langTags[i];
if (name.multi._key[langTag]) {
@@ -10096,14 +9824,14 @@ CSL.NameOutput.prototype.getName = function (name, slotLocaleset, fallback, stop
usedOrig = !foundTag;
}
return {name:name,usedOrig:usedOrig};
-};
+}
CSL.NameOutput.prototype.getNameParams = function (langTag) {
var ret = {};
var langspec = CSL.localeResolve(this.Item.language, this.state.opt["default-locale"][0]);
var try_locale = this.state.locale[langspec.best] ? langspec.best : this.state.opt["default-locale"][0];
- var name_as_sort_order = this.state.locale[try_locale].opts["name-as-sort-order"];
- var name_as_reverse_order = this.state.locale[try_locale].opts["name-as-reverse-order"];
- var name_never_short = this.state.locale[try_locale].opts["name-never-short"];
+ var name_as_sort_order = this.state.locale[try_locale].opts["name-as-sort-order"]
+ var name_as_reverse_order = this.state.locale[try_locale].opts["name-as-reverse-order"]
+ var name_never_short = this.state.locale[try_locale].opts["name-never-short"]
var field_lang_bare = langTag.split("-")[0];
if (name_as_sort_order && name_as_sort_order[field_lang_bare]) {
ret["static-ordering"] = true;
@@ -10120,7 +9848,7 @@ CSL.NameOutput.prototype.getNameParams = function (langTag) {
ret["block-initialize"] = true;
}
return ret;
-};
+}
CSL.NameOutput.prototype.setRenderedName = function (name) {
if (this.state.tmp.area === "bibliography") {
var strname = "";
@@ -10131,7 +9859,7 @@ CSL.NameOutput.prototype.setRenderedName = function (name) {
}
this.state.tmp.rendered_name.push(strname);
}
-};
+}
CSL.NameOutput.prototype.fixupInstitution = function (name, varname, listpos) {
if (this.state.sys.getHumanForm && "legal_case" === this.Item.type && "authority" === varname) {
name.literal = this.state.sys.getHumanForm(this.Item.jurisdiction, name.literal, true);
@@ -10163,7 +9891,7 @@ CSL.NameOutput.prototype.fixupInstitution = function (name, varname, listpos) {
name["short"] = [];
}
return name;
-};
+}
CSL.NameOutput.prototype.getStaticOrder = function (name, refresh) {
var static_ordering_val = false;
if (!refresh && name["static-ordering"]) {
@@ -10182,7 +9910,7 @@ CSL.NameOutput.prototype.getStaticOrder = function (name, refresh) {
}
}
return static_ordering_val;
-};
+}
CSL.NameOutput.prototype._splitInstitution = function (value, v, i) {
var ret = {};
if (!value.literal && value.family) {
@@ -10224,7 +9952,7 @@ CSL.NameOutput.prototype._splitInstitution = function (value, v, i) {
ret["long"] = this._trimInstitution(splitInstitution, v, i);
return ret;
};
-CSL.NameOutput.prototype._trimInstitution = function (subunits, v) {
+CSL.NameOutput.prototype._trimInstitution = function (subunits, v, i) {
var use_first = false;
var append_last = false;
var s = subunits.slice();
@@ -10340,12 +10068,14 @@ CSL.PublisherOutput.prototype.composeElements = function () {
CSL.PublisherOutput.prototype.composePublishers = function () {
var blobs;
for (var i = 0, ilen = this["publisher-list"].length; i < ilen; i += 1) {
+ var ordered_list = [];
blobs = [this[this.varlist[0] + "-list"][i], this[this.varlist[1] + "-list"][i]];
this["publisher-list"][i] = this._join(blobs, this.group_tok.strings.delimiter);
}
};
CSL.PublisherOutput.prototype.joinPublishers = function () {
var blobs = this["publisher-list"];
+ var delim = this.name_delimiter;
var publishers = this._join(blobs, this.group_tok.strings["subgroup-delimiter"], this.and_blob.single, this.and_blob.multiple, this.group_tok);
this.state.output.append(publishers, "literal");
};
@@ -10423,7 +10153,7 @@ CSL.castLabel = function (state, node, term, plural, mode) {
};
CSL.Node.name = {
build: function (state, target) {
- var func;
+ var func, pos, len, attrname;
if ([CSL.SINGLETON, CSL.START].indexOf(this.tokentype) > -1) {
var oldTmpRoot;
if ("undefined" === typeof state.tmp.root) {
@@ -10441,7 +10171,7 @@ CSL.Node.name = {
state.opt.update_mode = CSL.POSITION;
}
state.tmp.root = oldTmpRoot;
- func = function (state) {
+ func = function (state, Item) {
state.tmp.etal_term = "et-al";
state.tmp.name_delimiter = state.inheritOpt(this, "delimiter", "name-delimiter", ", ");
state.tmp["delimiter-precedes-et-al"] = state.inheritOpt(this, "delimiter-precedes-et-al");
@@ -10530,28 +10260,23 @@ CSL.Node.name = {
}
};
CSL.Node["name-part"] = {
- build: function (state) {
+ build: function (state, target) {
state.build[this.strings.name] = this;
}
};
CSL.Node.names = {
build: function (state, target) {
- var func;
+ var func, len, pos, attrname;
+ var debug = false;
if (this.tokentype === CSL.START || this.tokentype === CSL.SINGLETON) {
CSL.Util.substituteStart.call(this, state, target);
state.build.substitute_level.push(1);
}
if (this.tokentype === CSL.SINGLETON) {
- state.build.names_variables[state.build.names_variables.length-1].concat(this.variables);
- for (var i in this.variables) {
- var variable = this.variables[i];
- var name_labels = state.build.name_label[state.build.name_label.length-1];
- if (Object.keys(name_labels).length) {
- name_labels[variable] = name_labels[Object.keys(name_labels)[0]];
- }
- }
- func = function (state) {
- state.nameOutput.reinit(this, this.variables_real[0]);
+ state.build.names_variables.push(this.variables);
+ func = function (state, Item, item) {
+ var labelVariable = state.nameOutput.labelVariable;
+ state.nameOutput.reinit(this, labelVariable);
};
this.execs.push(func);
}
@@ -10559,9 +10284,12 @@ CSL.Node.names = {
state.build.names_flag = true;
state.build.name_flag = false;
state.build.names_level += 1;
+ if (state.build.names_level === 1) {
+ state.build.names_variables = [];
+ state.build.name_label = {};
+ }
state.build.names_variables.push(this.variables);
- state.build.name_label.push({});
- func = function (state) {
+ func = function (state, Item, item) {
state.tmp.can_substitute.push(true);
state.parallel.StartVariable("names",this.variables[0]);
state.nameOutput.init(this);
@@ -10576,11 +10304,13 @@ CSL.Node.names = {
state.build[key] = undefined;
}
}
- this.label = state.build.name_label[state.build.name_label.length-1];
+ this.label = state.build.name_label;
+ if (state.build.names_level === 1) {
+ state.build.name_label = {};
+ }
state.build.names_level += -1;
state.build.names_variables.pop();
- state.build.name_label.pop();
- func = function (state) {
+ func = function (state, Item, item) {
if (state.tmp.etal_node) {
this.etal_style = state.tmp.etal_node;
} else {
@@ -10647,7 +10377,7 @@ CSL.Node.names = {
state.tmp["et-al-use-last"] = undefined;
};
this.execs.push(func);
- func = function (state) {
+ func = function (state, Item) {
if (!state.tmp.can_substitute.pop()) {
state.tmp.can_substitute.replace(false, CSL.LITERAL);
}
@@ -10684,13 +10414,14 @@ CSL.Node.number = {
this.splice_prefix = state[state.build.area].opt.layout_delimiter;
}
func = function (state, Item, item) {
+ var i, ilen, newlst, lst;
if (this.variables.length === 0) {
return;
}
if ("undefined" === typeof item) {
var item = {};
}
- var varname;
+ var varname, num, number, m, j, jlen;
varname = this.variables[0];
if (varname === "locator" && state.tmp.just_looking) {
return;
@@ -10701,14 +10432,16 @@ CSL.Node.number = {
} else {
state.parallel.AppendToVariable(Item[this.variables[0]]);
}
+ var rex = new RegExp("(?:&|, | and |" + state.getTerm("page-range-delimiter") + ")");
if (varname === 'collection-number' && Item.type === 'legal_case') {
state.tmp.renders_collection_number = true;
}
+ var value = Item[this.variables[0]];
var node = this;
if (state.tmp.group_context.tip.force_suppress) {
return false;
}
- if (["locator", "locator-extra"].indexOf(varname) > -1) {
+ if (varname === "locator") {
state.processNumber(node, item, varname, Item.type);
} else {
if (!state.tmp.group_context.tip.condition && Item[varname]) {
@@ -10759,18 +10492,18 @@ CSL.Node.sort = {
state.tmp.lang_sort_hold = state.opt.lang;
state.opt.lang = langForItem;
}
- };
+ }
this.execs.push(func);
}
if (this.tokentype === CSL.END) {
state.build.area = state.build.root;
state.build.extension = "";
- var func = function (state) {
+ var func = function (state, Item) {
if (state.opt.has_layout_locale) {
state.opt.lang = state.tmp.lang_sort_hold;
delete state.tmp.lang_sort_hold;
}
- };
+ }
this.execs.push(func);
}
target.push(this);
@@ -10780,12 +10513,11 @@ CSL.Node.substitute = {
build: function (state, target) {
var func;
if (this.tokentype === CSL.START) {
- func = function (state) {
+ func = function (state, Item) {
state.tmp.can_block_substitute = true;
- if (state.tmp.value.length && !state.tmp.common_term_match_fail) {
+ if (state.tmp.value.length) {
state.tmp.can_substitute.replace(false, CSL.LITERAL);
}
- state.tmp.common_term_match_fail = false;
};
this.execs.push(func);
}
@@ -10794,7 +10526,7 @@ CSL.Node.substitute = {
};
CSL.Node.text = {
build: function (state, target) {
- var func, form, plural, id, num, number, formatter, firstoutput, specialdelimiter, label, suffix, term;
+ var variable, func, form, plural, id, num, number, formatter, firstoutput, specialdelimiter, label, myname, names, name, year, suffix, term, dp, len, pos, n, m, value, flag;
if (this.postponed_macro) {
var group_start = CSL.Util.cloneToken(this);
group_start.name = "group";
@@ -10844,7 +10576,20 @@ CSL.Node.text = {
id = "" + Item.id;
if (!state.tmp.just_looking) {
if (item && item["author-only"]) {
- state.tmp.element_trace.replace("suppress-me");
+ state.tmp.element_trace.replace("do-not-suppress-me");
+ var reference_term = state.getTerm("reference", "long", "singular");
+ if ("undefined" === typeof reference_term) {
+ reference_term = "reference";
+ }
+ term = CSL.Output.Formatters["capitalize-first"](state, reference_term);
+ state.output.append(term + " ");
+ state.tmp.last_element_trace = true;
+ }
+ if (item && item["suppress-author"]) {
+ if (state.tmp.last_element_trace) {
+ state.tmp.element_trace.replace("suppress-me");
+ }
+ state.tmp.last_element_trace = false;
}
num = state.registry.registry[id].seq;
if (state.opt.citation_number_slug) {
@@ -10852,6 +10597,8 @@ CSL.Node.text = {
} else {
number = new CSL.NumericBlob(false, num, this, Item.id);
if (state.tmp.in_cite_predecessor) {
+ if (!state.tmp.just_looking) {
+ }
number.suppress_splice_prefix = true;
}
state.output.append(number, "literal");
@@ -10894,9 +10641,6 @@ CSL.Node.text = {
};
this.execs.push(func);
} else if (this.variables_real[0] === "citation-label") {
- if (state.build.root === "bibliography") {
- state.opt.bib_mode = CSL.TRIGRAPH;
- }
state.opt.has_year_suffix = true;
func = function (state, Item) {
label = Item["citation-label"];
@@ -10917,7 +10661,7 @@ CSL.Node.text = {
}
} else {
if (this.strings.term) {
- func = function (state, Item) {
+ func = function (state, Item, item) {
var gender = state.opt.gender[Item.type];
var term = this.strings.term;
term = state.getTerm(term, form, plural, gender, CSL.TOLERANT, this.default_locale);
@@ -10948,7 +10692,7 @@ CSL.Node.text = {
state.build.form = false;
state.build.plural = false;
} else if (this.variables_real.length) {
- func = function (state, Item) {
+ func = function (state, Item, item) {
if (this.variables_real[0] !== "locator") {
state.tmp.have_collapsed = false;
}
@@ -11000,7 +10744,7 @@ CSL.Node.text = {
func = function(state, Item) {
state.processNumber(this, Item, this.variables[0], Item.type);
CSL.Util.outputNumericField(state, this.variables[0], Item.id);
- };
+ }
} else if (["URL", "DOI"].indexOf(this.variables_real[0]) > -1) {
func = function (state, Item) {
var value;
@@ -11063,7 +10807,7 @@ CSL.Node.text = {
state.output.append(value, this);
state.tmp.group_context.tip.variable_success = true;
}
- };
+ }
} else {
func = function (state, Item) {
var value;
@@ -11079,12 +10823,12 @@ CSL.Node.text = {
}
}
this.execs.push(func);
- func = function (state) {
+ func = function (state, Item) {
state.parallel.CloseVariable("text");
};
this.execs.push(func);
} else if (this.strings.value) {
- func = function (state) {
+ func = function (state, Item) {
state.tmp.group_context.tip.term_intended = true;
CSL.UPDATE_GROUP_CONTEXT_CONDITION(state, this.strings.value, true);
state.output.append(this.strings.value, this);
@@ -11097,51 +10841,22 @@ CSL.Node.text = {
}
}
};
-CSL.Node.intext = {
- build: function (state, target) {
- if (this.tokentype === CSL.START) {
- state.build.area = "intext";
- state.build.root = "intext";
- state.build.extension = "";
- var func = function(state, Item) {
- state.tmp.area = "intext";
- state.tmp.root = "intext";
- state.tmp.extension = "";
- }
- this.execs.push(func);
- }
- if (this.tokentype === CSL.END) {
- state.opt.grouped_sort = state.opt.xclass === "in-text"
- && (state.citation.opt.collapse
- && state.citation.opt.collapse.length)
- || (state.citation.opt.cite_group_delimiter
- && state.citation.opt.cite_group_delimiter.length)
- && state.opt.update_mode !== CSL.POSITION
- && state.opt.update_mode !== CSL.NUMERIC;
- if (state.opt.grouped_sort
- && state.citation_sort.opt.sort_directions.length) {
- state.intext_sort.opt.sort_directions = state.citation_sort.opt.sort_directions;
- }
- state.intext.srt = state.citation.srt;
- }
- target.push(this);
- }
-};
CSL.Attributes = {};
CSL.Attributes["@genre"] = function (state, arg) {
arg = arg.replace("-", " ");
- var func = function (Item) {
+ var func = function (Item, item) {
+ var ret;
if (arg === Item.genre) {
return true;
}
return false;
- };
+ }
this.tests.push(func);
-};
+}
CSL.Attributes["@disambiguate"] = function (state, arg) {
if (arg === "true") {
state.opt.has_disambiguate = true;
- var func = function (Item) {
+ var func = function (Item, item) {
if (state.tmp.area === "bibliography") {
if (state.tmp.disambiguate_count < state.registry.registry[Item.id].disambig.disambiguate) {
state.tmp.disambiguate_count += 1;
@@ -11159,7 +10874,7 @@ CSL.Attributes["@disambiguate"] = function (state, arg) {
};
this.tests.push(func);
} else if (arg === "check-ambiguity-and-backreference") {
- var func = function (Item) {
+ var func = function (Item, item) {
if (state.registry.registry[Item.id].disambig.disambiguate && state.registry.registry[Item.id]["citation-count"] > 1) {
return true;
}
@@ -11168,7 +10883,7 @@ CSL.Attributes["@disambiguate"] = function (state, arg) {
this.tests.push(func);
}
};
-CSL.Attributes["@is-numeric"] = function (state, arg) {
+CSL.Attributes["@is-numeric"] = function (state, arg, joiner) {
var variables = arg.split(/\s+/);
var maketest = function(variable) {
return function (Item, item) {
@@ -11194,8 +10909,8 @@ CSL.Attributes["@is-numeric"] = function (state, arg) {
}
}
return false;
- };
- };
+ }
+ }
for (var i=0; i= CSL.POSITION_SUBSEQUENT && item["near-note"]) {
- return true;
- }
- return false;
- };
- var testSubsequentNotNear = function (Item, item) {
- if (item && item.position == CSL.POSITION_SUBSEQUENT && !item["near-note"]) {
- return true;
- }
- return false;
- };
var maketest = function(tryposition) {
return function (Item, item) {
if (state.tmp.area === "bibliography") {
@@ -11269,8 +10972,8 @@ CSL.Attributes["@position"] = function (state, arg) {
return true;
}
return false;
- };
- };
+ }
+ }
for (var i=0,ilen=trypositions.length;i= CSL.POSITION_SUBSEQUENT && item["near-note"]) {
+ return true;
+ }
+ return false;
+ });
} else if ("far-note" === tryposition) {
- this.tests.push(testSubsequentNotNear);
+ this.tests.push(function (Item, item) {
+ if (item && item.position == CSL.POSITION_SUBSEQUENT && !item["near-note"]) {
+ return true;
+ }
+ return false;
+ });
} else {
this.tests.push(maketest(tryposition));
}
@@ -11294,15 +11007,15 @@ CSL.Attributes["@position"] = function (state, arg) {
CSL.Attributes["@type"] = function (state, arg) {
var types = arg.split(/\s+/);
var maketest = function (mytype) {
- return function(Item) {
+ return function(Item,item) {
var ret = (Item.type === mytype);
if (ret) {
return true;
} else {
return false;
}
- };
- };
+ }
+ }
var tests = [];
for (var i=0,ilen=types.length;i -1
&& "string" === typeof Item[variable]
&& "names" === this.name) {
+ var creatorParents = [];
var isValid = true;
var rawNames = Item[variable].split(/\s*;\s*/);
var rawMultiNames = {};
@@ -11364,7 +11080,7 @@ CSL.Attributes["@variable"] = function (state, arg) {
for (var langTag in rawMultiNames) {
var creatorChild = {
literal:rawMultiNames[langTag][j]
- };
+ }
creatorParent.multi._key[langTag] = creatorChild;
}
rawNames[j] = creatorParent;
@@ -11426,6 +11142,8 @@ CSL.Attributes["@variable"] = function (state, arg) {
}
break;
} else if ("object" === typeof Item[variable]) {
+ if (Item[variable].length) {
+ }
break;
} else if ("string" === typeof Item[variable] && Item[variable]) {
output = true;
@@ -11481,8 +11199,8 @@ CSL.Attributes["@variable"] = function (state, arg) {
}
}
return false;
- };
- };
+ }
+ }
for (var i=0,ilen=this.variables.length;i -1) {
- var area = state.tmp.area.slice(0, arg.length);
- if (area === arg) {
- return true;
- }
- return false;
- } else if ("alternative" === arg) {
- return !!state.tmp.abort_alternative;
- }
+ var func = function (Item, item) {
+ var area = state.tmp.area.slice(0, arg.length);
+ if (area === arg) {
+ return true;
+ }
+ return false;
};
this.tests.push(func);
};
CSL.Attributes["@has-year-only"] = function (state, arg) {
var trydates = arg.split(/\s+/);
var maketest = function (trydate) {
- return function(Item) {
+ return function(Item,item){
var date = Item[trydate];
if (!date || date.month || date.season) {
return false;
} else {
return true;
}
- };
- };
+ }
+ }
for (var i=0,ilen=trydates.length;i 0) {
@@ -11762,21 +11467,12 @@ CSL.Attributes["@authority-residue"] = function (state, arg) {
} else {
return !succeed;
}
- };
- };
+ }
+ }
this.tests.push(maketest());
-};
-CSL.Attributes["@alternative-node-internal"] = function (state) {
- var maketest = function () {
- return function() {
- return !state.tmp.abort_alternative;
- };
- };
- var me = this;
- this.tests.push(maketest(me));
-};
+}
CSL.Attributes["@locale-internal"] = function (state, arg) {
- var langspec, lang, lst, i, ilen;
+ var func, ret, len, pos, variable, myitem, langspec, lang, lst, i, ilen, fallback;
lst = arg.split(/\s+/);
this.locale_bares = [];
for (i = 0, ilen = lst.length; i < ilen; i += 1) {
@@ -11792,8 +11488,8 @@ CSL.Attributes["@locale-internal"] = function (state, arg) {
this.locale = lst[0].best;
this.locale_list = lst.slice();
var maketest = function (me) {
- return function (Item) {
- var ret, res;
+ return function (Item, item) {
+ var key, res;
ret = [];
res = false;
var langspec = false;
@@ -11824,11 +11520,11 @@ CSL.Attributes["@locale-internal"] = function (state, arg) {
}
}
return res;
- };
- };
+ }
+ }
var me = this;
this.tests.push(maketest(me));
-};
+}
CSL.Attributes["@is-parallel"] = function (state, arg) {
var values = arg.split(" ");
for (var i = 0, ilen = values.length; i < ilen; i += 1) {
@@ -11845,13 +11541,13 @@ CSL.Attributes["@jurisdiction-depth"] = function (state, arg) {
};
CSL.Attributes["@require"] = function (state, arg) {
this.strings.require = arg;
-};
+}
CSL.Attributes["@reject"] = function (state, arg) {
this.strings.reject = arg;
-};
+}
CSL.Attributes["@gender"] = function (state, arg) {
this.gender = arg;
-};
+}
CSL.Attributes["@cslid"] = function (state, arg) {
this.cslid = parseInt(arg, 10);
};
@@ -11904,14 +11600,15 @@ CSL.Attributes["@term"] = function (state, arg) {
this.strings.term = arg;
}
};
-CSL.Attributes["@xmlns"] = function () {};
+CSL.Attributes["@xmlns"] = function (state, arg) {};
CSL.Attributes["@lang"] = function (state, arg) {
if (arg) {
state.build.lang = arg;
}
};
-CSL.Attributes["@lingo"] = function () {};
-CSL.Attributes["@macro-has-date"] = function () {
+CSL.Attributes["@lingo"] = function (state, arg) {
+};
+CSL.Attributes["@macro-has-date"] = function (state, arg) {
this["macro-has-date"] = true;
};
CSL.Attributes["@suffix"] = function (state, arg) {
@@ -11957,7 +11654,7 @@ CSL.Attributes["@plural"] = function (state, arg) {
this.strings.plural = false;
}
};
-CSL.Attributes["@has-publisher-and-publisher-place"] = function () {
+CSL.Attributes["@has-publisher-and-publisher-place"] = function (state, arg) {
this.strings["has-publisher-and-publisher-place"] = true;
};
CSL.Attributes["@publisher-delimiter-precedes-last"] = function (state, arg) {
@@ -11969,7 +11666,8 @@ CSL.Attributes["@publisher-delimiter"] = function (state, arg) {
CSL.Attributes["@publisher-and"] = function (state, arg) {
this.strings["publisher-and"] = arg;
};
-CSL.Attributes["@newdate"] = function () {};
+CSL.Attributes["@newdate"] = function (state, arg) {
+};
CSL.Attributes["@givenname-disambiguation-rule"] = function (state, arg) {
if (CSL.GIVENNAME_DISAMBIGUATION_RULES.indexOf(arg) > -1) {
state.citation.opt["givenname-disambiguation-rule"] = arg;
@@ -12063,17 +11761,6 @@ CSL.Attributes["@name-as-sort-order"] = function (state, arg) {
CSL.Attributes["@sort-separator"] = function (state, arg) {
state.setOpt(this, "sort-separator", arg);
};
-CSL.Attributes["@require-match"] = function (state, arg) {
- if (arg === "true") {
- this.requireMatch = true;
- }
-};
-CSL.Attributes["@exclude-types"] = function (state, arg) {
- state.bibliography.opt.exclude_types = arg.split(/\s+/);
-};
-CSL.Attributes["@exclude-with-fields"] = function (state, arg) {
- state.bibliography.opt.exclude_with_fields = arg.split(/\s+/);
-};
CSL.Attributes["@year-suffix-delimiter"] = function (state, arg) {
state[this.name].opt["year-suffix-delimiter"] = arg;
};
@@ -12108,11 +11795,7 @@ CSL.Attributes["@second-field-align"] = function (state, arg) {
};
CSL.Attributes["@hanging-indent"] = function (state, arg) {
if (arg === "true") {
- if (state.opt.development_extensions.hanging_indent_legacy_number) {
- state[this.name].opt.hangingindent = 2;
- } else {
- state[this.name].opt.hangingindent = true;
- }
+ state[this.name].opt.hangingindent = 2;
}
};
CSL.Attributes["@line-spacing"] = function (state, arg) {
@@ -12135,6 +11818,8 @@ CSL.Attributes["@text-case"] = function (state, arg) {
} else {
this.strings["text-case"] = arg;
if (arg === "title") {
+ var m = false;
+ var default_locale = state.opt["default-locale"][0].slice(0, 2);
if (Item.jurisdiction) {
this.strings["text-case"] = "passthrough";
}
@@ -12179,6 +11864,7 @@ CSL.Attributes["@default-locale"] = function (state, arg) {
}
};
CSL.Attributes["@default-locale-sort"] = function (state, arg) {
+ var lst, len, pos, m, ret;
state.opt["default-locale-sort"] = arg;
};
CSL.Attributes["@demote-non-dropping-particle"] = function (state, arg) {
@@ -12298,7 +11984,7 @@ CSL.Parallel.prototype.StartCitation = function (sortedItems, out) {
}
};
CSL.Parallel.prototype.StartCite = function (Item, item, prevItemID) {
- var position, len, pos, curr, master, last_id, prev_locator, curr_locator;
+ var position, len, pos, x, curr, master, last_id, prev_locator, curr_locator, is_master, parallel;
if (this.use_parallels) {
if (this.sets.value().length && this.sets.value()[0].itemId == Item.id) {
this.ComposeSet();
@@ -12477,7 +12163,7 @@ CSL.Parallel.prototype.AppendBlobPointer = function (blob) {
}
}
};
-CSL.Parallel.prototype.AppendToVariable = function (str) {
+CSL.Parallel.prototype.AppendToVariable = function (str, varname) {
if (this.use_parallels) {
if (this.ignoreVars.indexOf(this.variable) > -1) {
return;
@@ -12544,7 +12230,7 @@ CSL.Parallel.prototype.CloseVariable = function () {
}
};
CSL.Parallel.prototype.CloseCite = function () {
- var x, pos, len, use_journal_info, volume_pos, container_title_pos, section_pos;
+ var x, pos, len, has_issued, use_journal_info, volume_pos, container_title_pos, section_pos;
if (this.use_parallels && (this.force_collapse || this.try_cite)) {
use_journal_info = false;
if (!this.cite.front_collapse["container-title"]) {
@@ -12611,8 +12297,8 @@ CSL.Parallel.prototype.CloseCite = function () {
this.sets.value().push(this.cite);
}
};
-CSL.Parallel.prototype.ComposeSet = function () {
- var cite, pos, len;
+CSL.Parallel.prototype.ComposeSet = function (next_output_in_progress) {
+ var cite, pos, master, len;
if (this.use_parallels && (this.force_collapse || this.try_cite)) {
var lengthCheck = this.sets.value().length;
if (this.sets.value().length === 1) {
@@ -12747,7 +12433,7 @@ CSL.Parallel.prototype.purgeGroupsIfParallel = function (original_condition) {
}
this.parallel_conditional_blobs_list.pop();
}
-};
+}
CSL.Util = {};
CSL.Util.Match = function () {
this.any = function (token, state, tests) {
@@ -12797,8 +12483,10 @@ CSL.Util.Match = function () {
};
};
CSL.Transform = function (state) {
+ var debug = false, abbreviations, token, fieldname, abbrev_family, opt;
this.abbrevs = {};
this.abbrevs["default"] = new state.sys.AbbreviationSegments();
+ this.getTextSubField = getTextSubField;
function getCountryOrJurisdiction(variable, normalizedKey, quashCountry) {
var value = "";
if (state.sys.getHumanForm) {
@@ -12816,7 +12504,7 @@ CSL.Transform = function (state) {
}
return value;
}
- function abbreviate(state, tok, Item, altvar, basevalue, family_var, use_field) {
+ function abbreviate(state, tok, Item, altvar, basevalue, family_var, use_field, form) {
var value = "";
var myabbrev_family = CSL.FIELD_CATEGORY_REMAP[family_var];
var preferredJurisdiction;
@@ -12868,7 +12556,7 @@ CSL.Transform = function (state) {
return value;
}
function getFieldLocale(Item,field) {
- var ret = state.opt["default-locale"][0].slice(0, 2);
+ var ret = state.opt["default-locale"][0].slice(0, 2)
var localeRex;
if (state.opt.development_extensions.strict_text_case_locales) {
localeRex = new RegExp("^([a-zA-Z]{2})(?:$|-.*| .*)");
@@ -12891,9 +12579,9 @@ CSL.Transform = function (state) {
ret = ret.toLowerCase();
}
return ret;
- }
+ };
function getTextSubField (Item, field, locale_type, use_default, stopOrig) {
- var opt, o, ret, opts;
+ var m, lst, opt, o, oo, pos, key, ret, len, myret, opts;
var usedOrig = stopOrig;
var usingOrig = false;
if (!Item[field]) {
@@ -12906,6 +12594,7 @@ CSL.Transform = function (state) {
ret = {name:"", usedOrig:stopOrig,locale:getFieldLocale(Item,field)};
opts = state.opt[locale_type];
var hasVal = false;
+ var jurisdictionName = false;
if (locale_type === 'locale-orig') {
if (stopOrig) {
ret = {name:"", usedOrig:stopOrig};
@@ -12953,8 +12642,8 @@ CSL.Transform = function (state) {
}
return ret;
}
- this.getTextSubField = getTextSubField;
function loadAbbreviation(jurisdiction, category, orig, itemType) {
+ var pos, len;
if (!jurisdiction) {
jurisdiction = "default";
}
@@ -12997,21 +12686,7 @@ CSL.Transform = function (state) {
}
return false;
}
- function quashCheck(value) {
- var m = value.match(/^!([-,_a-z]+)>>>/);
- if (m) {
- var fields = m[1].split(",");
- value = value.slice(m[0].length);
- for (var i = 0, ilen = fields.length; i < ilen; i += 1) {
- if (state.tmp.done_vars.indexOf(fields[i]) === -1) {
- state.tmp.done_vars.push(fields[i]);
- }
- }
- }
- return value;
- }
- this.quashCheck = quashCheck;
- function getOutputFunction(variables, family_var, abbreviation_fallback, alternative_varname) {
+ function getOutputFunction(variables, family_var, abbreviation_fallback, alternative_varname, transform_fallback) {
var localesets;
var langPrefs = CSL.LangPrefsMap[variables[0]];
if (!langPrefs) {
@@ -13019,21 +12694,16 @@ CSL.Transform = function (state) {
} else {
localesets = state.opt['cite-lang-prefs'][langPrefs];
}
- return function (state, Item, item) {
- var primary, primary_locale, secondary, secondary_locale, tertiary, tertiary_locale, primary_tok;
+ return function (state, Item, item, usedOrig) {
+ var primary, primary_locale, secondary, secondary_locale, tertiary, tertiary_locale, primary_tok, group_tok, key;
if (!variables[0] || (!Item[variables[0]] && !Item[alternative_varname])) {
return null;
}
- if (!state.tmp.just_looking && item && item["suppress-author"]) {
- if (!state.tmp.probably_rendered_something && state.tmp.can_substitute.length() > 1) {
- return null;
- }
- }
var slot = {primary:false, secondary:false, tertiary:false};
if (state.tmp.area.slice(-5) === "_sort") {
slot.primary = 'locale-sort';
} else {
- if (localesets && !state.tmp.multi_layout) {
+ if (localesets) {
var slotnames = ["primary", "secondary", "tertiary"];
for (var i = 0, ilen = slotnames.length; i < ilen; i += 1) {
if (localesets.length - 1 < i) {
@@ -13055,10 +12725,6 @@ CSL.Transform = function (state) {
slot.secondary = false;
slot.tertiary = false;
}
- if (state.tmp.multi_layout) {
- slot.secondary = false;
- slot.tertiary = false;
- }
if (state.tmp["publisher-list"]) {
if (variables[0] === "publisher") {
state.tmp["publisher-token"] = this;
@@ -13116,7 +12782,7 @@ CSL.Transform = function (state) {
}
}
if (!hasItalic) {
- primary_tok.decorations.push(["@font-style", "italic"]);
+ primary_tok.decorations.push(["@font-style", "italic"])
}
}
if (primary_locale !== "en" && primary_tok.strings["text-case"] === "title") {
@@ -13129,7 +12795,6 @@ CSL.Transform = function (state) {
state.output.openLevel("empty");
primary_tok.strings.suffix = primary_tok.strings.suffix.replace(/[ .,]+$/,"");
state.output.append(primary, primary_tok);
- state.tmp.probably_rendered_something = true;
if (secondary) {
secondary_tok.strings.prefix = state.opt.citeAffixes[langPrefs][slot.secondary].prefix;
secondary_tok.strings.suffix = state.opt.citeAffixes[langPrefs][slot.secondary].suffix;
@@ -13138,7 +12803,7 @@ CSL.Transform = function (state) {
}
for (var i = secondary_tok.decorations.length - 1; i > -1; i += -1) {
if (['@quotes/true', '@font-style/italic', '@font-style/oblique', '@font-weight/bold'].indexOf(secondary_tok.decorations[i].join('/')) > -1) {
- secondary_tok.decorations = secondary_tok.decorations.slice(0, i).concat(secondary_tok.decorations.slice(i + 1));
+ secondary_tok.decorations = secondary_tok.decorations.slice(0, i).concat(secondary_tok.decorations.slice(i + 1))
}
}
if (secondary_locale !== "en" && secondary_tok.strings["text-case"] === "title") {
@@ -13165,7 +12830,7 @@ CSL.Transform = function (state) {
}
for (var i = tertiary_tok.decorations.length - 1; i > -1; i += -1) {
if (['@quotes/true', '@font-style/italic', '@font-style/oblique', '@font-weight/bold'].indexOf(tertiary_tok.decorations[i].join('/')) > -1) {
- tertiary_tok.decorations = tertiary_tok.decorations.slice(0, i).concat(tertiary_tok.decorations.slice(i + 1));
+ tertiary_tok.decorations = tertiary_tok.decorations.slice(0, i).concat(tertiary_tok.decorations.slice(i + 1))
}
}
if (tertiary_locale !== "en" && tertiary_tok.strings["text-case"] === "title") {
@@ -13187,12 +12852,25 @@ CSL.Transform = function (state) {
state.output.closeLevel();
} else {
state.output.append(primary, primary_tok);
- state.tmp.probably_rendered_something = true;
}
return null;
};
}
this.getOutputFunction = getOutputFunction;
+ function quashCheck(value) {
+ var m = value.match(/^!([-,_a-z]+)>>>/);
+ if (m) {
+ var fields = m[1].split(",");
+ value = value.slice(m[0].length);
+ for (var i = 0, ilen = fields.length; i < ilen; i += 1) {
+ if (state.tmp.done_vars.indexOf(fields[i]) === -1) {
+ state.tmp.done_vars.push(fields[i]);
+ }
+ }
+ }
+ return value;
+ }
+ this.quashCheck = quashCheck;
};
CSL.Token = function (name, tokentype) {
this.name = name;
@@ -13370,7 +13048,7 @@ CSL.NumericBlob.prototype.checkLast = function (last) {
return false;
};
CSL.Util.fixDateNode = function (parent, pos, node) {
- var form, variable, datexml, subnode, partname, attr, val, prefix, suffix, children, subchildren, display, cslid;
+ var form, variable, datexml, subnode, partname, attr, val, prefix, suffix, children, key, subchildren, kkey, display, cslid;
var lingo = this.cslXml.getAttributeValue(node, "lingo");
var default_locale = this.cslXml.getAttributeValue(node, "default-locale");
this.build.date_key = true;
@@ -13457,7 +13135,7 @@ CSL.dateMacroAsSortKey = function (state, Item) {
CSL.dateAsSortKey.call(this, state, Item, true);
};
CSL.dateAsSortKey = function (state, Item, isMacro) {
- var dp, elem, value, e, yr, prefix, i, ilen;
+ var dp, elem, value, e, yr, prefix, i, ilen, num;
var variable = this.variables[0];
var macroFlag = "empty";
if (isMacro && state.tmp.extension) {
@@ -13510,7 +13188,7 @@ CSL.dateAsSortKey = function (state, Item, isMacro) {
}
};
CSL.Engine.prototype.dateParseArray = function (date_obj) {
- var ret, field, dp, exts;
+ var ret, field, dpos, ppos, dp, exts, llen, pos, len, pppos, lllen;
ret = {};
for (field in date_obj) {
if (field === "date-parts") {
@@ -13560,7 +13238,7 @@ CSL.Util.Names.unInitialize = function (state, name) {
return ret;
};
CSL.Util.Names.initializeWith = function (state, name, terminator, normalizeOnly) {
- var i, ilen, mm, lst, ret;
+ var i, ilen, j, jlen, n, m, mm, str, lst, ret;
if (!name) {
return "";
}
@@ -13578,19 +13256,8 @@ CSL.Util.Names.initializeWith = function (state, name, terminator, normalizeOnly
}
namelist = namelist.replace(/\s*\-\s*/g, "-").replace(/\s+/g, " ");
namelist = namelist.replace(/-([a-z])/g, "\u2013$1");
- for (var i=namelist.length-2; i>-1; i += -1) {
- if (namelist.slice(i, i+1) === "." && namelist.slice(i+1, i+2) !== " ") {
- namelist = namelist.slice(0, i) + ". " + namelist.slice(i+1);
- }
- }
mm = namelist.match(/[\-\s]+/g);
lst = namelist.split(/[\-\s]+/);
- if (mm === null) {
- var mmm = lst[0].match(/[^\.]+$/);
- if (mmm && mmm[0].length === 1 && mmm[0] !== mmm[0].toLowerCase()) {
- lst[0] += ".";
- }
- }
if (lst.length === 0) {
namelist = mm;
} else {
@@ -13601,6 +13268,20 @@ CSL.Util.Names.initializeWith = function (state, name, terminator, normalizeOnly
}
}
lst = namelist;
+ for (i = lst.length -1; i > -1; i += -1) {
+ if (lst[i] && lst[i].slice(0, -1).indexOf(".") > -1) {
+ var lstend = lst.slice(i + 1);
+ var lstmid = lst[i].slice(0, -1).split(".");
+ lst = lst.slice(0, i);
+ for (j = 0, jlen = lstmid.length; j < jlen; j += 1) {
+ lst.push(lstmid[j] + ".");
+ if (j < lstmid.length - 1) {
+ lst.push(" ");
+ }
+ }
+ lst = lst.concat(lstend);
+ }
+ }
if (normalizeOnly) {
ret = CSL.Util.Names.doNormalize(state, lst, terminator);
} else {
@@ -13609,7 +13290,7 @@ CSL.Util.Names.initializeWith = function (state, name, terminator, normalizeOnly
ret = ret.replace(/\u2013([a-z])/g, "-$1");
return ret;
};
-CSL.Util.Names.doNormalize = function (state, namelist, terminator) {
+CSL.Util.Names.doNormalize = function (state, namelist, terminator, mode) {
var i, ilen;
terminator = terminator ? terminator : "";
var isAbbrev = [];
@@ -13623,11 +13304,20 @@ CSL.Util.Names.doNormalize = function (state, namelist, terminator) {
isAbbrev.push(false);
}
}
+ var ret = [];
for (i = 0, ilen = namelist.length; i < ilen; i += 2) {
if (isAbbrev[i]) {
if (i < namelist.length - 2) {
namelist[i + 1] = "";
- if (!isAbbrev[i+2]) {
+ var onlySpace = terminator.match(/^[\u0009\u000a\u000b\u000c\u000d\u0020\u00a0]+$/)
+ if (
+ onlySpace
+ || (
+ (!terminator || (terminator.slice(-1) && !terminator.slice(-1).match(/[\u0009\u000a\u000b\u000c\u000d\u0020\u00a0]/)))
+ && namelist[i].length && namelist[i].match(CSL.ALL_ROMANESQUE_REGEXP)
+ && (namelist[i].length > 1 || namelist[i + 2].length > 1)
+ )
+ ) {
namelist[i + 1] = " ";
}
if (namelist[i + 2].length > 1) {
@@ -13643,7 +13333,7 @@ CSL.Util.Names.doNormalize = function (state, namelist, terminator) {
}
return namelist.join("").replace(/[\u0009\u000a\u000b\u000c\u000d\u0020\ufeff\u00a0]+$/,"").replace(/\s*\-\s*/g, "-").replace(/[\u0009\u000a\u000b\u000c\u000d\u0020]+/g, " ");
};
-CSL.Util.Names.doInitialize = function (state, namelist, terminator) {
+CSL.Util.Names.doInitialize = function (state, namelist, terminator, mode) {
var i, ilen, m, j, jlen, lst, n;
for (i = 0, ilen = namelist.length; i < ilen; i += 2) {
n = namelist[i];
@@ -13654,11 +13344,7 @@ CSL.Util.Names.doInitialize = function (state, namelist, terminator) {
if (!m && (!n.match(CSL.STARTSWITH_ROMANESQUE_REGEXP) && n.length > 1 && terminator.match("%s"))) {
m = n.match(/(.)(.*)/);
}
- if (m && m[2] && m[3]) {
- m[1] = m[1] + m[2];
- m[2] = "";
- }
- if (m && m[1].slice(0, 1) === m[1].slice(0, 1).toUpperCase()) {
+ if (m && m[1] === m[1].toUpperCase()) {
var extra = "";
if (m[2]) {
var s = "";
@@ -13675,7 +13361,7 @@ CSL.Util.Names.doInitialize = function (state, namelist, terminator) {
extra = s.toLocaleLowerCase();
}
}
- namelist[i] = m[1] + extra;
+ namelist[i] = m[1].toLocaleUpperCase() + extra;
if (i < (ilen - 1)) {
if (terminator.match("%s")) {
namelist[i] = terminator.replace("%s", namelist[i]);
@@ -13693,7 +13379,7 @@ CSL.Util.Names.doInitialize = function (state, namelist, terminator) {
namelist.push(terminator);
}
}
- } else if (n.match(CSL.ROMANESQUE_REGEXP) && (!m || !m[3])) {
+ } else if (n.match(CSL.ROMANESQUE_REGEXP)) {
namelist[i] = " " + n;
}
}
@@ -13723,7 +13409,7 @@ CSL.Util.Dates.year["long"] = function (state, num) {
}
return num.toString();
};
-CSL.Util.Dates.year.imperial = function (state, num, end) {
+CSL.Util.Dates.year.imperial = function (state, num, end, makeShort) {
var year = "";
if (!num) {
if ("boolean" === typeof num) {
@@ -13769,7 +13455,7 @@ CSL.Util.Dates.year.imperial = function (state, num, end) {
}
if (state.transform.abbrevs['default']['number'][normalizedKey]) {
label = state.transform.abbrevs['default']['number'][normalizedKey];
- }
+ };
year = label + (num - offset);
}
return year;
@@ -13808,16 +13494,14 @@ CSL.Util.Dates.normalizeMonth = function (num, useSeason) {
num = parseInt(num, 10);
if (useSeason) {
var res = {stub: "month-", num: num};
- if (res.num < 1 || res.num > 24) {
+ if (res.num < 1 || res.num > 20) {
res.num = 0;
- } else {
- while (res.num > 16) {
- res.num = res.num - 4;
- }
- if (res.num > 12) {
- res.stub = "season-";
- res.num = res.num - 12;
- }
+ } else if (res.num > 16) {
+ res.stub = "season-";
+ res.num = res.num - 16;
+ } else if (res.num > 12) {
+ res.stub = "season-";
+ res.num = res.num - 12;
}
ret = res;
} else {
@@ -13827,7 +13511,7 @@ CSL.Util.Dates.normalizeMonth = function (num, useSeason) {
ret = num;
}
return ret;
-};
+}
CSL.Util.Dates.month = {};
CSL.Util.Dates.month.numeric = function (state, num) {
var num = CSL.Util.Dates.normalizeMonth(num);
@@ -13908,7 +13592,7 @@ CSL.Util.Sort.strip_prepositions = function (str) {
};
CSL.Util.substituteStart = function (state, target) {
var element_trace, display, bib_first, func, choose_start, if_start, nodetypes;
- func = function (state) {
+ func = function (state, Item) {
for (var i = 0, ilen = this.decorations.length; i < ilen; i += 1) {
if ("@strip-periods" === this.decorations[i][0] && "true" === this.decorations[i][1]) {
state.tmp.strip_periods += 1;
@@ -13926,30 +13610,13 @@ CSL.Util.substituteStart = function (state, target) {
if (("text" === this.name && !this.postponed_macro) || nodetypes.indexOf(this.name) > -1) {
element_trace = function (state, Item, item) {
if (state.tmp.element_trace.value() === "author" || "names" === this.name) {
- if (!state.tmp.just_looking && item && item["author-only"] && state.tmp.area !== "intext") {
- if (!state.tmp.probably_rendered_something) {
- } else {
- state.tmp.element_trace.push("suppress-me");
- }
- }
- if (!state.tmp.just_looking && item && item["suppress-author"]) {
- if (!state.tmp.probably_rendered_something) {
- state.tmp.element_trace.push("suppress-me");
- }
- }
- }
- else if ("date" === this.name) {
- if (!state.tmp.just_looking && item && item["author-only"] && state.tmp.area !== "intext") {
- if (state.tmp.probably_rendered_something) {
- state.tmp.element_trace.push("suppress-me");
- }
+ if (item && item["author-only"]) {
+ state.tmp.element_trace.push("do-not-suppress-me");
+ } else if (item && item["suppress-author"]) {
}
} else {
- if (!state.tmp.just_looking && item && item["author-only"] && state.tmp.area !== "intext") {
- if (!state.tmp.probably_rendered_something && state.tmp.can_block_substitute) {
- } else {
- state.tmp.element_trace.push("suppress-me");
- }
+ if (item && item["author-only"]) {
+ state.tmp.element_trace.push("suppress-me");
} else if (item && item["suppress-author"]) {
state.tmp.element_trace.push("do-not-suppress-me");
}
@@ -13988,7 +13655,7 @@ CSL.Util.substituteStart = function (state, target) {
choose_start = new CSL.Token("choose", CSL.START);
CSL.Node.choose.build.call(choose_start, state, target);
if_start = new CSL.Token("if", CSL.START);
- func = function () {
+ func = function (Item,item) {
if (state.tmp.can_substitute.value()) {
return true;
}
@@ -14010,15 +13677,13 @@ CSL.Util.substituteStart = function (state, target) {
if (item) {
position = item.position;
}
- if (!position) {
- position = 0;
- }
+ if (!position) position = 0;
var positionMap = [
"first",
"subsequent",
"ibid",
"ibid-with-locator"
- ];
+ ]
var noteNumber = 0;
if (item && item.noteIndex) {
noteNumber = item.noteIndex;
@@ -14049,22 +13714,22 @@ CSL.Util.substituteStart = function (state, target) {
};
state.output.current.value().params = params;
}
- };
+ }
this.execs.push(func);
}
};
CSL.Util.substituteEnd = function (state, target) {
- var func, bib_first_end, bib_other, if_end, choose_end, author_substitute, str;
+ var func, bib_first_end, bib_other, if_end, choose_end, toplevel, hasval, author_substitute, str;
if (state.sys.variableWrapper
&& (this.hasVariable || (this.variables_real && this.variables_real.length))) {
- func = function (state) {
+ func = function (state,Item) {
if (!state.tmp.just_looking && !state.tmp.suppress_decorations) {
state.output.endTag("variable_entry");
}
- };
+ }
this.execs.push(func);
}
- func = function (state) {
+ func = function (state, Item) {
for (var i = 0, ilen = this.decorations.length; i < ilen; i += 1) {
if ("@strip-periods" === this.decorations[i][0] && "true" === this.decorations[i][1]) {
state.tmp.strip_periods += -1;
@@ -14076,14 +13741,14 @@ CSL.Util.substituteEnd = function (state, target) {
state.build.render_nesting_level += -1;
if (state.build.render_nesting_level === 0) {
if (state.build.cls) {
- func = function (state) {
+ func = function (state, Item) {
state.output.endTag("bib_first");
};
this.execs.push(func);
state.build.cls = false;
} else if (state.build.area === "bibliography" && state.bibliography.opt["second-field-align"]) {
bib_first_end = new CSL.Token("group", CSL.END);
- func = function (state) {
+ func = function (state, Item) {
if (!state.tmp.render_seen) {
state.output.endTag("bib_first"); // closes bib_first
}
@@ -14092,7 +13757,7 @@ CSL.Util.substituteEnd = function (state, target) {
target.push(bib_first_end);
bib_other = new CSL.Token("group", CSL.START);
bib_other.decorations = [["@display", "right-inline"]];
- func = function (state) {
+ func = function (state, Item) {
if (!state.tmp.render_seen) {
state.tmp.render_seen = true;
state.output.startTag("bib_other", bib_other);
@@ -14111,15 +13776,9 @@ CSL.Util.substituteEnd = function (state, target) {
if ("names" === this.name || ("text" === this.name && this.variables_real !== "title")) {
author_substitute = new CSL.Token("text", CSL.SINGLETON);
func = function (state, Item) {
- if (state.tmp.area !== "bibliography") {
- return;
- }
- if ("string" !== typeof state.bibliography.opt["subsequent-author-substitute"]) {
- return;
- }
- if (this.variables_real && !Item[this.variables_real]) {
- return;
- }
+ if (state.tmp.area !== "bibliography") return;
+ if ("string" !== typeof state.bibliography.opt["subsequent-author-substitute"]) return;
+ if (this.variables_real && !Item[this.variables_real]) return;
if (state.tmp.substituted_variable !== this.variables_real) {
return;
}
@@ -14183,9 +13842,7 @@ CSL.Util.substituteEnd = function (state, target) {
}
if (("text" === this.name && !this.postponed_macro) || ["number", "date", "names"].indexOf(this.name) > -1) {
func = function (state, Item) {
- if (state.tmp.element_trace.mystack.length>1) {
- state.tmp.element_trace.pop();
- }
+ state.tmp.element_trace.pop();
};
this.execs.push(func);
}
@@ -14328,15 +13985,16 @@ CSL.Util.Suffixator.prototype.format = function (N) {
} while ( N !== 0 );
return key;
};
-CSL.Engine.prototype.processNumber = function (node, ItemObject, variable) {
- var val;
+CSL.Engine.prototype.processNumber = function (node, ItemObject, variable, type) {
+ var val, m, i, ilen, j, jlen;
+ var debug = false;
var me = this;
- function normalizeFieldValue(str) {
+ function normalizeFieldValue(str, defaultLabel) {
str = str.trim();
var m = str.match(/^([^ ]+)/);
if (m && !CSL.STATUTE_SUBDIV_STRINGS[m[1]]) {
var embeddedLabel = null;
- if (["locator", "locator-extra"].indexOf(variable) > -1) {
+ if (variable === "locator" ) {
if (ItemObject.label) {
embeddedLabel = CSL.STATUTE_SUBDIV_STRINGS_REVERSE[ItemObject.label];
} else {
@@ -14375,7 +14033,7 @@ CSL.Engine.prototype.processNumber = function (node, ItemObject, variable) {
}
info.joiningSuffix = joiningSuffix.replace(/\s*-\s*/, "-");
return info;
- }
+ };
function fixupSubsections(elems) {
for (var i=elems.length-2;i>-1;i-=2) {
if (elems[i] === "-"
@@ -14423,20 +14081,20 @@ CSL.Engine.prototype.processNumber = function (node, ItemObject, variable) {
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));
+ lst = lst.slice(0,j).concat(lst.slice(j+1))
+ m = m.slice(0,j-1).concat(m.slice(j))
}
}
if (m.length > 0) {
var slug = m[0].trim();
var notAlabel = !CSL.STATUTE_SUBDIV_STRINGS[slug]
|| !me.getTerm(CSL.STATUTE_SUBDIV_STRINGS[slug])
- || (["locator", "number", "locator-extra"].indexOf(variable) === -1 && CSL.STATUTE_SUBDIV_STRINGS[slug] !== variable);
+ || (["locator", "number"].indexOf(variable) === -1 && CSL.STATUTE_SUBDIV_STRINGS[slug] !== variable);
if (notAlabel) {
if (i === 0) {
m = m.slice(1);
lst[0] = lst[0] + " " + slug + " " + lst[1];
- lst = lst.slice(0,1).concat(lst.slice(2));
+ lst = lst.slice(0,1).concat(lst.slice(2))
}
} else {
origLabel = slug;
@@ -14521,12 +14179,12 @@ CSL.Engine.prototype.processNumber = function (node, ItemObject, variable) {
function fixLabelVisibility(values, groupStartPos, currentLabelInfo) {
if (currentLabelInfo.label.slice(0, 4) !== "var:") {
if (currentLabelInfo.pos === 0) {
- if (["locator", "number", "locator-extra"].indexOf(variable) > -1) {
+ if (variable === "locator" || variable === "number") {
if (!me.getTerm(CSL.STATUTE_SUBDIV_STRINGS[currentLabelInfo.label])) {
values[currentLabelInfo.pos].labelVisibility = true;
}
}
- if (["locator", "number", "locator-extra"].indexOf(variable) === -1) {
+ if (["locator", "number"].indexOf(variable) === -1) {
if (CSL.STATUTE_SUBDIV_STRINGS[currentLabelInfo.label] !== variable) {
values[0].labelVisibility = true;
}
@@ -14537,9 +14195,7 @@ CSL.Engine.prototype.processNumber = function (node, ItemObject, variable) {
}
}
function setPluralsAndNumerics(values) {
- if (values.length === 0) {
- return;
- }
+ if (values.length === 0) return;
var groupStartPos = 0;
var groupCount = 1;
for (var i=1,ilen=values.length;i-1;j--) {
+ if (masterNode.decorations[j][0] === "@quotes") {
+ masterStyling.decorations = masterStyling.decorations.concat(masterNode.decorations.slice(j, j+1));
+ masterNode.decorations = masterNode.decorations.slice(0, j).concat(masterNode.decorations.slice(j+1))
+ }
+ }
masterStyling.strings.prefix = masterNode.strings.prefix;
masterNode.strings.prefix = "";
masterStyling.strings.suffix = masterNode.strings.suffix;
@@ -14611,29 +14268,15 @@ CSL.Engine.prototype.processNumber = function (node, ItemObject, variable) {
}
return masterStyling;
}
- function checkTerm(variable, val) {
- var ret = true;
- if (["locator", "locator-extra"].indexOf(variable) > -1) {
- var label;
- if (val.origLabel) {
- label = val.origLabel;
- } else {
- label = val.label;
- }
- ret = !!me.getTerm(CSL.STATUTE_SUBDIV_STRINGS[label]);
- }
- return ret;
- }
- function checkPage(variable, val) {
- return variable === "page"
- || (["locator", "locator-extra"].indexOf(variable) > -1 && (["p."].indexOf(val.label) > -1 || ["p."].indexOf(val.origLabel) > -1));
+ function stripHyphenBackslash(joiningSuffix) {
+ return joiningSuffix.replace("\\-", "-");
}
function fixupRangeDelimiter(variable, val, rangeDelimiter, isNumeric) {
var isPage = checkPage(variable, val);
var hasTerm = checkTerm(variable, val);
if (hasTerm && rangeDelimiter === "-") {
if (isNumeric) {
- if (isPage || ["locator", "locator-extra", "issue", "volume", "edition", "number"].indexOf(variable) > -1) {
+ if (isPage || ["locator", "issue", "volume", "edition", "number"].indexOf(variable) > -1) {
rangeDelimiter = me.getTerm("page-range-delimiter");
if (!rangeDelimiter) {
rangeDelimiter = "\u2013";
@@ -14649,10 +14292,25 @@ CSL.Engine.prototype.processNumber = function (node, ItemObject, variable) {
}
return rangeDelimiter;
}
- function manglePageNumbers(values, i, currentInfo) {
- if (i<1) {
- return;
+ function checkPage(variable, val) {
+ return variable === "page"
+ || (variable === "locator" && (["p."].indexOf(val.label) > -1 || ["p."].indexOf(val.origLabel) > -1));
+ }
+ function checkTerm(variable, val) {
+ var ret = true;
+ if (variable === "locator") {
+ var label;
+ if (val.origLabel) {
+ label = val.origLabel;
+ } else {
+ label = val.label;
+ }
+ ret = !!me.getTerm(CSL.STATUTE_SUBDIV_STRINGS[label]);
}
+ return ret;
+ }
+ function manglePageNumbers(values, i, currentInfo) {
+ if (i<1) return;
if (currentInfo.count !== 2) {
return;
}
@@ -14692,17 +14350,13 @@ CSL.Engine.prototype.processNumber = function (node, ItemObject, variable) {
currentInfo.count = 0;
}
function fixRanges(values) {
- if (!node) {
- return;
- }
- if (["page", "page-first", "chapter-number", "collection-number", "edition", "issue", "number", "number-of-pages", "number-of-volumes", "volume", "locator", "locator-extra"].indexOf(variable) === -1) {
- return;
- }
+ if (!node) return;
+ if (["page", "page-first", "chapter-number", "collection-number", "edition", "issue", "number", "number-of-pages", "number-of-volumes", "volume", "locator"].indexOf(variable) === -1) return;
var currentInfo = {
count: 0,
label: null,
lastHadRangeDelimiter: false
- };
+ }
for (var i=0,ilen=values.length; i": {
@@ -15137,9 +14792,9 @@ CSL.Util.FlipFlopper = function(state) {
"false": "true"
}
}
- };
- _nestingData["(\""] = _nestingData[" \""];
- _nestingData["(\'"] = _nestingData[" \'"];
+ }
+ _nestingData["(\""] = _nestingData[" \""]
+ _nestingData["(\'"] = _nestingData[" \'"]
var localeOpenQuote = state.getTerm("open-quote");
var localeCloseQuote = state.getTerm("close-quote");
var localeOpenInnerQuote = state.getTerm("open-inner-quote");
@@ -15154,18 +14809,44 @@ CSL.Util.FlipFlopper = function(state) {
_nestingData[localeOpenInnerQuote].opener = localeOpenInnerQuote;
_nestingData[localeOpenInnerQuote].closer = localeCloseInnerQuote;
}
+ var _nestingQuoteReverse = function() {
+ var ret = {};
+ var keys = Object.keys(_nestingData);
+ for (var i = 0, l = keys.length; i < l; i++) {
+ var key = keys[i];
+ if (_nestingData[key].type === "quote") {
+ ret[_nestingData[key].closer] = _nestingData[key];
+ }
+ }
+ return ret;
+ }();
+ var _nestingDataAttr = function() {
+ var ret = {};
+ var keys = Object.keys(_nestingData);
+ for (var i = 0, l = keys.length; i < l; i++) {
+ var key = keys[i];
+ if (_nestingData[key].type === "nocase") continue;
+ var attr = _nestingData[key].attr;
+ var outer = _nestingData[key].outer;
+ var inner = _nestingData[key].flipflop[_nestingData[key].outer];
+ ret[attr + "/" + outer] = _nestingData[key];
+ ret[attr + "/" + inner] = _nestingData[key];
+ }
+ return ret;
+ }();
function _setOuterQuoteForm(quot) {
var flip = {
" \'": " \"",
" \"": " \'",
"(\"": "(\'",
"(\'": "(\""
- };
+ }
_nestingData[quot].outer = "true";
_nestingData[flip[quot]].outer = "inner";
}
function _getNestingOpenerParams(opener) {
var openers = [];
+ var closer;
var keys = Object.keys(_nestingData);
for (var i = 0, l = keys.length; i < l; i++) {
var key = keys[i];
@@ -15174,12 +14855,10 @@ CSL.Util.FlipFlopper = function(state) {
}
}
var ret = _nestingData[opener];
- ret.opener = new RegExp("^(?:" + openers.map(function(str){
- return str.replace("(", "\\(");
- }).join("|") + ")");
+ ret.opener = new RegExp("^(?:" + openers.map(function(str){return str.replace("(", "\\(")}).join("|") + ")");
return ret;
}
- var _nestingParams = (function() {
+ var _nestingParams = function() {
var ret = {};
var keys = Object.keys(_nestingData);
for (var i = 0, l = keys.length; i < l; i++) {
@@ -15187,8 +14866,8 @@ CSL.Util.FlipFlopper = function(state) {
ret[key] = _getNestingOpenerParams(key);
}
return ret;
- }());
- var _tagRex = (function() {
+ }()
+ var _tagRex = function() {
var openers = [];
var closers = [];
var vals = {};
@@ -15201,18 +14880,24 @@ CSL.Util.FlipFlopper = function(state) {
var closer = keys[i];
closers.push(closer);
}
- var all = openers.concat(closers).map(function(str){
- return str.replace("(", "\\(");
- }).join("|");
+ var all = openers.concat(closers).map(function(str){return str.replace("(", "\\(")}).join("|");
return {
matchAll: new RegExp("((?:" + all + "))", "g"),
splitAll: new RegExp("(?:" + all + ")", "g"),
- open: new RegExp("(^(?:" + openers.map(function(str){
- return str.replace("(", "\\(");
- }).join("|") + ")$)"),
+ open: new RegExp("(^(?:" + openers.map(function(str){return str.replace("(", "\\(")}).join("|") + ")$)"),
close: new RegExp("(^(?:" + closers.join("|") + ")$)"),
- };
- }());
+ }
+ }();
+ function _nestingFix (tag, pos) {
+ return _pushNestingState(tag, pos);
+ }
+ function _pushNestingState(tag, pos) {
+ if (tag.match(_tagRex.open)) {
+ return _tryOpen(tag, pos);
+ } else {
+ return _tryClose(tag, pos);
+ }
+ }
function _tryOpen(tag, pos) {
var params = _nestingState[_nestingState.length - 1];
if (!params || tag.match(params.opener)) {
@@ -15224,7 +14909,7 @@ CSL.Util.FlipFlopper = function(state) {
});
return false;
} else {
- _nestingState.pop();
+ _nestingState.pop()
_nestingState.push({
type: _nestingParams[tag].type,
opener: _nestingParams[tag].opener,
@@ -15239,14 +14924,14 @@ CSL.Util.FlipFlopper = function(state) {
function _tryClose(tag, pos) {
var params = _nestingState[_nestingState.length - 1];
if (params && tag === params.closer) {
- _nestingState.pop();
+ _nestingState.pop()
if (params.type === "nocase") {
return {
nocase: {
open: params.pos,
close: pos
}
- };
+ }
} else {
return false;
}
@@ -15262,16 +14947,6 @@ CSL.Util.FlipFlopper = function(state) {
}
}
}
- function _pushNestingState(tag, pos) {
- if (tag.match(_tagRex.open)) {
- return _tryOpen(tag, pos);
- } else {
- return _tryClose(tag, pos);
- }
- }
- function _nestingFix (tag, pos) {
- return _pushNestingState(tag, pos);
- }
function _doppelString(str) {
var forcedSpaces = [];
str = str.replace(/(]*(>)/g, "$1 $2$3;\"$4");
@@ -15288,7 +14963,7 @@ CSL.Util.FlipFlopper = function(state) {
for (var i=0,ilen=match.length-1;i -1) {
- match[i+1] = " " + match[i+1];
+ match[i+1] = " " + match[i+1]
forcedSpaces.push(true);
} else {
forcedSpaces.push(false);
@@ -15299,11 +14974,23 @@ CSL.Util.FlipFlopper = function(state) {
tags: match,
strings: split,
forcedSpaces: forcedSpaces
- };
+ }
}
- var TagReg = function(blob) {
+ function _undoppelString(obj) {
+ var lst = obj.strings.slice(-1);
+ for (var i=obj.tags.length-1; i>-1; i+=-1) {
+ lst.push(obj.tags[i]);
+ lst.push(obj.strings[i]);
+ }
+ lst.reverse();
+ return lst.join("|");
+ }
+ var _TagReg = function(blob) {
+ this.set = set;
+ this.pair = pair;
+ this.pop = pop;
var _stack = [];
- this.set = function (tag) {
+ function set(tag) {
var attr = _nestingData[tag].attr;
var decor = null;
for (var i=_stack.length-1;i>-1;i--) {
@@ -15314,13 +15001,11 @@ CSL.Util.FlipFlopper = function(state) {
}
}
if (!decor) {
- var allTheDecor = [state[state.tmp.area].opt.layout_decorations].concat(blob.alldecor);
+ var allTheDecor = [state[state.tmp.area].opt.layout_decorations].concat(blob.alldecor)
outer:
for (var i=allTheDecor.length-1;i>-1;i--) {
var decorset = allTheDecor[i];
- if (!decorset) {
- continue;
- }
+ if (!decorset) continue;
for (var j=decorset.length-1;j>-1;j--) {
var _decor = decorset[j];
if (_decor[0] === attr) {
@@ -15336,14 +15021,14 @@ CSL.Util.FlipFlopper = function(state) {
decor = [attr, _nestingData[tag].flipflop[decor[1]]];
}
_stack.push(decor);
- };
- this.pair = function () {
+ }
+ function pair() {
return _stack[_stack.length-1];
- };
- this.pop = function () {
+ }
+ function pop() {
_stack.pop();
- };
- };
+ }
+ }
function _apostropheForce(tag, str) {
if (tag === "\'") {
if (str && str.match(/^[^\,\.\?\:\;\ ]/)) {
@@ -15355,13 +15040,14 @@ CSL.Util.FlipFlopper = function(state) {
return false;
}
function _undoppelToQueue(blob, doppel, leadingSpace) {
+ var TOP = blob;
var firstString = true;
- var tagReg = new TagReg(blob);
+ var tagReg = new _TagReg(blob);
blob.blobs = [];
function Stack (blob) {
this.stack = [blob];
this.latest = blob;
- this.addStyling = function(str, decor) {
+ this.addStyling = function(str, decor, forcedSpace) {
if (firstString) {
if (str.slice(0, 1) === " ") {
str = str.slice(1);
@@ -15385,19 +15071,17 @@ CSL.Util.FlipFlopper = function(state) {
if (decor[0] === "@class" && decor[1] === "nodecor") {
var newdecorset = [];
var seen = {};
- var allTheDecor = [state[state.tmp.area].opt.layout_decorations].concat(newblob.alldecor);
+ var allTheDecor = [state[state.tmp.area].opt.layout_decorations].concat(newblob.alldecor)
for (var i=allTheDecor.length-1;i>-1;i--) {
var _decorset = allTheDecor[i];
- if (!_decorset) {
- continue;
- }
+ if (!_decorset) continue;
for (var j=_decorset.length-1;j>-1;j--) {
var _olddecor = _decorset[j];
if (["@font-weight", "@font-style", "@font-variant"].indexOf(_olddecor[0]) > -1
&& !seen[_olddecor[0]]) {
if (decor[1] !== "normal") {
newblob.decorations.push([_olddecor[0], "normal"]);
- newdecorset.push([_olddecor[0], "normal"]);
+ newdecorset.push([_olddecor[0], "normal"])
}
seen[_olddecor[0]] = true;
}
@@ -15426,11 +15110,11 @@ CSL.Util.FlipFlopper = function(state) {
this.latest.blobs.push(child);
}
}
- };
+ }
this.popStyling = function() {
this.stack.pop();
- };
- }
+ }
+ };
var stack = new Stack(blob);
if (doppel.strings.length) {
var str = doppel.strings[0];
@@ -15452,18 +15136,16 @@ CSL.Util.FlipFlopper = function(state) {
}
}
}
- this.processTags = function (blob) {
+ function processTags(blob) {
var str = blob.blobs;
var leadingSpace = false;
if (str.slice(0, 1) === " " && !str.match(/^\s+[\'\"]/)) {
leadingSpace = true;
}
- var rex = new RegExp("(" + CSL.ROMANESQUE_REGEXP.source + ")\u2019(" + CSL.ROMANESQUE_REGEXP.source + ")", "g");
+ var rex = new RegExp("(" + CSL.ROMANESQUE_REGEXP.source + ")\u2019(" + CSL.ROMANESQUE_REGEXP.source + ")", "g")
var str = " " + str.replace(rex, "$1\'$2");
var doppel = _doppelString(str);
- if (doppel.tags.length === 0) {
- return;
- }
+ if (doppel.tags.length === 0) return;
var quoteFormSeen = false;
for (var i=0,ilen=doppel.tags.length;i-1;i--) {
- var tagPos = _nestingState[i].pos;
+ var tagPos = _nestingState[i].pos
var tag = doppel.tags[tagPos];
if (tag === " \'" || tag === "\'") {
doppel.strings[tagPos+1] = " \u2019" + doppel.strings[tagPos+1];
@@ -15547,9 +15229,16 @@ CSL.Util.FlipFlopper = function(state) {
}
}
_undoppelToQueue(blob, doppel, leadingSpace);
- };
-};
-CSL.Output.Formatters = (function () {
+ }
+}
+CSL.Output.Formatters = new function () {
+ this.passthrough = passthrough;
+ this.lowercase = lowercase;
+ this.uppercase = uppercase;
+ this.sentence = sentence;
+ this.title = title;
+ this["capitalize-first"] = capitalizeFirst;
+ this["capitalize-all"] = capitalizeAll;
var rexStr = "(?:\u2018|\u2019|\u201C|\u201D| \"| \'|\"|\'|[-\u2013\u2014\/.,;?!:]|\\[|\\]|\\(|\\)|||<\/span>|<\/?(?:i|sc|b|sub|sup)>)";
var tagDoppel = new CSL.Doppeler(rexStr, function(str) {
return str.replace(/(]*(>)/g, "$1 $2$3").replace(/(]*(>)/g, "$1 $2 $3;$4$5");
@@ -15562,8 +15251,8 @@ CSL.Output.Formatters = (function () {
"": "",
"": "",
"": ""
- };
- function _capitalise (word) {
+ }
+ function _capitalise (word, force) {
var m = word.match(/(^\s*)((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]))(.*)/);
if (m && !(m[2].match(/^[\u0370-\u03FF]$/) && !m[3])) {
return m[1] + m[2].toUpperCase() + m[3];
@@ -15592,31 +15281,11 @@ CSL.Output.Formatters = (function () {
opener: "\u201C",
closer: "\u201D"
},
- };
- function tryOpen(tag, pos) {
- if (config.quoteState.length === 0 || tag === config.quoteState[config.quoteState.length - 1].opener) {
- config.quoteState.push({
- opener: quoteParams[tag].opener,
- closer: quoteParams[tag].closer,
- pos: pos
- });
- return false;
- } else {
- var prevPos = config.quoteState[config.quoteState.length-1].pos;
- config.quoteState.pop();
- config.quoteState.push({
- opener: quoteParams[tag].opener,
- closer: quoteParams[tag].closer,
- positions: pos
- });
- return prevPos;
- }
}
- function tryClose(tag, pos) {
- if (config.quoteState.length > 0 && tag === config.quoteState[config.quoteState.length - 1].closer) {
- config.quoteState.pop();
- } else {
- return pos;
+ function quoteFix (tag, positions) {
+ var m = tag.match(/(^(?:\u2018|\u2019|\u201C|\u201D|\"|\')|(?: \"| \')$)/);
+ if (m) {
+ return pushQuoteState(m[1], positions);
}
}
function pushQuoteState(tag, pos) {
@@ -15627,10 +15296,30 @@ CSL.Output.Formatters = (function () {
return tryClose(tag, pos);
}
}
- function quoteFix (tag, positions) {
- var m = tag.match(/(^(?:\u2018|\u2019|\u201C|\u201D|\"|\')|(?: \"| \')$)/);
- if (m) {
- return pushQuoteState(m[1], positions);
+ function tryOpen(tag, pos) {
+ if (config.quoteState.length === 0 || tag === config.quoteState[config.quoteState.length - 1].opener) {
+ config.quoteState.push({
+ opener: quoteParams[tag].opener,
+ closer: quoteParams[tag].closer,
+ pos: pos
+ });
+ return false;
+ } else {
+ var prevPos = config.quoteState[config.quoteState.length-1].pos;
+ config.quoteState.pop()
+ config.quoteState.push({
+ opener: quoteParams[tag].opener,
+ closer: quoteParams[tag].closer,
+ positions: pos
+ });
+ return prevPos;
+ }
+ }
+ function tryClose(tag, pos) {
+ if (config.quoteState.length > 0 && tag === config.quoteState[config.quoteState.length - 1].closer) {
+ config.quoteState.pop()
+ } else {
+ return pos;
}
}
if (config.doppel.strings.length && config.doppel.strings[0].trim()) {
@@ -15715,7 +15404,7 @@ CSL.Output.Formatters = (function () {
tagState: [],
afterPunct: null,
isFirst: null
- };
+ }
return _textcaseEngine(config, string);
}
function uppercase(state, string) {
@@ -15735,7 +15424,7 @@ CSL.Output.Formatters = (function () {
tagState: [],
afterPunct: null,
isFirst: null
- };
+ }
return _textcaseEngine(config, string);
}
function sentence(state, string) {
@@ -15760,7 +15449,7 @@ CSL.Output.Formatters = (function () {
tagState: [],
afterPunct: null,
isFirst: true
- };
+ }
return _textcaseEngine(config, string);
}
function title(state, string) {
@@ -15773,9 +15462,7 @@ CSL.Output.Formatters = (function () {
var words = wordle.strings;
for (var j=0,jlen=words.length;j 1 && !word.toLowerCase().match(config.skipWordsRex)) {
words[j] = _capitalise(words[j]);
} else if (j === (words.length - 1) && followingTag === "-") {
@@ -15790,7 +15477,7 @@ CSL.Output.Formatters = (function () {
config.lastWordPos = {
strings: i,
words: j
- };
+ }
}
str = wordDoppel.join(wordle);
}
@@ -15800,7 +15487,7 @@ CSL.Output.Formatters = (function () {
tagState: [],
afterPunct: false,
isFirst: true
- };
+ }
return _textcaseEngine(config, string);
}
function capitalizeFirst(state, string) {
@@ -15824,7 +15511,7 @@ CSL.Output.Formatters = (function () {
tagState: [],
afterPunct: null,
isFirst: true
- };
+ }
return _textcaseEngine(config, string);
}
function capitalizeAll (state, string) {
@@ -15844,19 +15531,10 @@ CSL.Output.Formatters = (function () {
tagState: [],
afterPunct: null,
isFirst: null
- };
+ }
return _textcaseEngine(config, string);
}
- return {
- passthrough: passthrough,
- lowercase: lowercase,
- uppercase: uppercase,
- sentence: sentence,
- title: title,
- "capitalize-first": capitalizeFirst,
- "capitalize-all": capitalizeAll
- };
-}());
+}
CSL.Output.Formats = function () {};
CSL.Output.Formats.prototype.html = {
"text_escape": function (text) {
@@ -16016,7 +15694,7 @@ CSL.Output.Formats.prototype.text = {
"@display/indent": function (state, str) {
return "\n "+str;
},
- "@showid/true": function (state, str) {
+ "@showid/true": function (state, str, cslid) {
return str;
},
"@URL/true": function (state, str) {
@@ -16088,7 +15766,7 @@ CSL.Output.Formats.prototype.rtf = {
"@display/indent": function (state, str) {
return "\n\\tab "+str+"\\line\r\n";
},
- "@showid/true": function (state, str) {
+ "@showid/true": function (state, str, cslid) {
if (!state.tmp.just_looking && ! state.tmp.suppress_decorations) {
var prePunct = "";
if (str) {
@@ -16178,7 +15856,7 @@ CSL.Output.Formats.prototype.asciidoc = {
"@display/indent": function (state, str) {
return " " + str;
},
- "@showid/true": function (state, str) {
+ "@showid/true": function (state, str, cslid) {
if (!state.tmp.just_looking && !state.tmp.suppress_decorations && this.params && "string" === typeof str) {
var prePunct = "";
if (str) {
@@ -16290,7 +15968,7 @@ CSL.Output.Formats.prototype.fo = {
"@display/indent": function (state, str) {
return "" + str + "\n";
},
- "@showid/true": function (state, str) {
+ "@showid/true": function (state, str, cslid) {
if (!state.tmp.just_looking && !state.tmp.suppress_decorations && this.params && "string" === typeof str) {
var prePunct = "";
if (str) {
@@ -16319,74 +15997,9 @@ CSL.Output.Formats.prototype.fo = {
return "" + str + "";
}
};
-CSL.Output.Formats.prototype.latex = {
- "text_escape": function (text) {
- if (!text) {
- text = "";
- }
- return text;
- },
- "bibstart": "\\begin{thebibliography}{4}",
- "bibend": "\end{thebibliography}",
- "@font-style/italic": "{\\em %%STRING%%}",
- "@font-style/oblique": false,
- "@font-style/normal": false,
- "@font-variant/small-caps": false,
- "@passthrough/true": CSL.Output.Formatters.passthrough,
- "@font-variant/normal": false,
- "@font-weight/bold": "{\\bf %%STRING%%}",
- "@font-weight/normal": false,
- "@font-weight/light": false,
- "@text-decoration/none": false,
- "@text-decoration/underline": false,
- "@vertical-align/baseline": false,
- "@vertical-align/sup": false,
- "@vertical-align/sub": false,
- "@strip-periods/true": CSL.Output.Formatters.passthrough,
- "@strip-periods/false": CSL.Output.Formatters.passthrough,
- "@quotes/true": function (state, str) {
- if ("undefined" === typeof str) {
- return state.getTerm("open-quote");
- }
- return state.getTerm("open-quote") + str + state.getTerm("close-quote");
- },
- "@quotes/inner": function (state, str) {
- if ("undefined" === typeof str) {
- return "\u2019";
- }
- return state.getTerm("open-inner-quote") + str + state.getTerm("close-inner-quote");
- },
- "@quotes/false": false,
- "@cite/entry": function (state, str) {
- return state.sys.wrapCitationEntry(str, this.item_id, this.locator_txt, this.suffix_txt);
- },
- "@bibliography/entry": function (state, str) {
- return "\\bibitem{" + state.sys.embedBibliographyEntry(this.item_id) + "}\n";
- },
- "@display/block": function (state, str) {
- return "\n"+str;
- },
- "@display/left-margin": function (state, str) {
- return str;
- },
- "@display/right-inline": function (state, str) {
- return str;
- },
- "@display/indent": function (state, str) {
- return "\n "+str;
- },
- "@showid/true": function (state, str, cslid) {
- return str;
- },
- "@URL/true": function (state, str) {
- return str;
- },
- "@DOI/true": function (state, str) {
- return str;
- }
-};
CSL.Output.Formats = new CSL.Output.Formats();
CSL.Registry = function (state) {
+ var pos, len, ret, i, ilen;
this.debug = false;
this.state = state;
this.registry = {};
@@ -16515,7 +16128,7 @@ CSL.Registry.prototype.dodeletes = function (myhash) {
for (var k = this.registry[key].siblings.length - 1; k > -1; k += -1) {
var siblingID = this.registry[key].siblings.pop();
if (removeIDs.indexOf(siblingID) === -1) {
- buffer.push(siblingID);
+ buffer.push(siblingID)
}
}
for (var k = buffer.length - 1; k > -1; k += -1) {
@@ -16535,7 +16148,7 @@ CSL.Registry.prototype.dodeletes = function (myhash) {
}
};
CSL.Registry.prototype.doinserts = function (mylist) {
- var item, Item, akey, newitem, abase, i, ilen;
+ var len, pos, item, Item, akey, newitem, abase, j, jlen, k, klen, i, ilen;
if ("string" === typeof mylist) {
mylist = [mylist];
}
@@ -16571,7 +16184,7 @@ CSL.Registry.prototype.doinserts = function (mylist) {
}
};
CSL.Registry.prototype.rebuildlist = function (nosort) {
- var len, pos, item, Item;
+ var count, len, pos, item, Item;
if (!nosort) {
this.reflist_inserts = [];
len = this.mylist.length;
@@ -16597,7 +16210,7 @@ CSL.Registry.prototype.rebuildlist = function (nosort) {
}
};
CSL.Registry.prototype.dorefreshes = function () {
- var key, regtoken, Item, akey, abase;
+ var key, regtoken, Item, old_akey, akey, abase;
for (var key in this.refreshes) {
regtoken = this.registry[key];
if (!regtoken) {
@@ -16616,7 +16229,7 @@ CSL.Registry.prototype.dorefreshes = function () {
if (this.ambigresets[akkey] === 1) {
var loneKey = this.ambigcites[akey][0];
var Item = this.state.refetchItem(loneKey);
- this.registry[loneKey].disambig = new CSL.AmbigConfig();
+ this.registry[loneKey].disambig = new CSL.AmbigConfig;
this.state.tmp.disambig_settings = false;
var akey = CSL.getAmbiguousCite.call(this.state, Item);
var abase = CSL.getAmbigConfig.call(this.state);
@@ -16632,7 +16245,8 @@ CSL.Registry.prototype.dorefreshes = function () {
}
};
CSL.Registry.prototype.setdisambigs = function () {
- for (var akey in this.ambigsTouched) {
+ var akey, key, pos, len, id;
+ for (akey in this.ambigsTouched) {
this.state.disambiguate.run(akey);
}
this.ambigsTouched = {};
@@ -16670,21 +16284,18 @@ CSL.Registry.prototype._insertItem = function(element, array) {
return array;
};
CSL.Registry.prototype._locationOf = function(element, array, start, end) {
- if (array.length === 0) {
+ if (array.length === 0)
return -1;
- }
start = start || 0;
end = end || array.length;
var pivot = (start + end) >> 1; // should be faster than dividing by 2
var c = this.sorter.compareKeys(element, array[pivot]);
- if (end - start <= 1) {
- return c == -1 ? pivot - 1 : pivot;
- }
+ if (end - start <= 1) return c == -1 ? pivot - 1 : pivot;
switch (c) {
case -1: return this._locationOf(element, array, start, pivot);
case 0: return pivot;
case 1: return this._locationOf(element, array, pivot, end);
- }
+ };
};
CSL.Registry.prototype.sorttokens = function (nosort) {
var len, item, Item, pos;
@@ -16788,10 +16399,11 @@ CSL.Registry.prototype.registerAmbigToken = function (akey, id, ambig_config) {
this.ambigcites[akey].push("" + id);
}
this.registry[id].ambig = akey;
+ var dome = false;
this.registry[id].disambig = CSL.cloneAmbigConfig(ambig_config);
};
CSL.getSortKeys = function (Item, key_type) {
- var area, root, extension, strip_prepositions, len, pos;
+ var area, root, extension, strip_prepositions, use_parallels, len, pos;
area = this.tmp.area;
root = this.tmp.root;
extension = this.tmp.extension;
@@ -16817,7 +16429,7 @@ CSL.getSortKeys = function (Item, key_type) {
return this[key_type].keys;
};
CSL.Registry.NameReg = function (state) {
- var pkey, ikey, skey, dagopt, gdropt, items, strip_periods, set_keys, evalname, delitems, addname, myitems;
+ var pkey, ikey, skey, floor, ceiling, dagopt, gdropt, ret, pos, items, strip_periods, set_keys, evalname, delitems, addname, key, myitems, i, ilen;
this.state = state;
this.namereg = {};
this.nameind = {};
@@ -16842,7 +16454,7 @@ CSL.Registry.NameReg = function (state) {
}
};
evalname = function (item_id, nameobj, namenum, request_base, form, initials) {
- var param;
+ var pos, len, items, param;
if (state.tmp.area.slice(0, 12) === "bibliography" && !form) {
if ("string" === typeof initials) {
return 1;
@@ -16905,7 +16517,7 @@ CSL.Registry.NameReg = function (state) {
}
};
delitems = function (ids) {
- var pos, len, posB, id, fullkey;
+ var item, pos, len, posA, posB, id, fullkey, llen, ppos, otherid;
if ("string" === typeof ids || "number" === typeof ids) {
ids = ["" + ids];
}
@@ -17039,7 +16651,7 @@ CSL.Registry.NameReg = function (state) {
this.delitems = delitems;
this.evalname = evalname;
};
-CSL.Registry.CitationReg = function () {
+CSL.Registry.CitationReg = function (state) {
this.citationById = {};
this.citationByIndex = [];
};
@@ -17061,7 +16673,7 @@ CSL.Disambiguation.prototype.run = function(akey) {
}
};
CSL.Disambiguation.prototype.runDisambig = function () {
- var ismax;
+ var pos, len, ppos, llen, pppos, lllen, ismax;
this.initGivens = true;
while (this.lists.length) {
this.gnameset = 0;
@@ -17072,6 +16684,7 @@ CSL.Disambiguation.prototype.runDisambig = function () {
if (!this.base) {
this.base = this.lists[0][0];
}
+ var names_used = [];
ismax = this.incrementDisambig();
this.scanItems(this.lists[0]);
this.evalScan(ismax);
@@ -17080,7 +16693,7 @@ CSL.Disambiguation.prototype.runDisambig = function () {
}
};
CSL.Disambiguation.prototype.scanItems = function (list) {
- var pos, len, otherItem;
+ var pos, len, Item, otherItem, ItemCite, ignore, base;
this.Item = list[1][0];
this.ItemCite = CSL.getAmbiguousCite.call(this.state, this.Item, this.base, true);
this.scanlist = list[1];
@@ -17112,7 +16725,7 @@ CSL.Disambiguation.prototype.evalScan = function (maxed) {
}
};
CSL.Disambiguation.prototype.disNames = function (ismax) {
- var i, ilen;
+ var pos, len, mybase, i, ilen;
if (this.clashes[1] === 0 && this.nonpartners.length === 1) {
this.captureStepToBase();
this.state.registry.registerAmbigToken(this.akey, "" + this.nonpartners[0].id, this.betterbase);
@@ -17147,6 +16760,7 @@ CSL.Disambiguation.prototype.disNames = function (ismax) {
}
};
CSL.Disambiguation.prototype.disExtraText = function () {
+ var pos, len, mybase;
var done = false;
if (this.clashes[1] === 0 && this.nonpartners.length < 2) {
done = true;
@@ -17184,7 +16798,7 @@ CSL.Disambiguation.prototype.disExtraText = function () {
}
};
CSL.Disambiguation.prototype.disYears = function () {
- var pos, len, tokens, token;
+ var pos, len, tokens, token, item;
tokens = [];
var base = this.lists[this.listpos][0];
if (this.clashes[1]) {
@@ -17211,12 +16825,14 @@ CSL.Disambiguation.prototype.disYears = function () {
this.lists[this.listpos] = [this.betterbase, []];
};
CSL.Disambiguation.prototype.incrementDisambig = function () {
+ var val;
if (this.initGivens) {
this.initGivens = false;
return false;
}
var maxed = false;
var increment_names = true;
+ var increment_givens = true;
if ("disNames" === this.modes[this.modeindex]) {
increment_names = false;
if ("number" !== typeof this.givensMax) {
@@ -17252,6 +16868,8 @@ CSL.Disambiguation.prototype.incrementDisambig = function () {
this.gnameset += 1;
this.base.names[this.gnameset] = 1;
this.gname = 0;
+ } else {
+ var increment_mode = true;
}
}
if (("number" !== typeof this.namesetsMax || this.namesetsMax === -1 || this.gnameset === this.namesetsMax)
@@ -17277,6 +16895,7 @@ CSL.Disambiguation.prototype.initVars = function (akey) {
if (!myIds || !myIds.length) {
return false;
}
+ var Item = false;
var myItem = this.state.refetchItem("" + myIds[0]);
this.getCiteData(myItem);
this.base = CSL.getAmbigConfig.call(this.state);
@@ -17345,7 +16964,7 @@ CSL.Disambiguation.prototype.padBase = function (base) {
}
}
}
-};
+}
CSL.Disambiguation.prototype.configModes = function () {
var dagopt, gdropt;
this.modes = [];
@@ -17378,6 +16997,7 @@ CSL.Disambiguation.prototype.getCiteData = function(Item, base) {
if (base.names.length < this.base.names.length) {
this.base = base;
}
+ var update = false;
for (var i = 0, ilen = base.names.length; i < ilen; i += 1) {
if (base.names[i] > this.base.names[i]) {
this.base.givens[i] = base.givens[i].slice();
@@ -17413,7 +17033,7 @@ CSL.Engine.prototype.getJurisdictionList = function (jurisdiction) {
jurisdictionList.push("us");
}
return jurisdictionList;
-};
+}
CSL.Engine.prototype.retrieveAllStyleModules = function (jurisdictionList) {
var ret = {};
var preferences = this.locale[this.opt.lang].opts["jurisdiction-preference"];
@@ -17423,24 +17043,21 @@ CSL.Engine.prototype.retrieveAllStyleModules = function (jurisdictionList) {
var preference = preferences[i];
for (var j=0,jlen=jurisdictionList.length;j