commit f5661217aa1117c650205bc6444165b01186aa43
parent de56c2567fbc9f8a87be1940c43fa4e8de9ca861
Author: Simon Kornblith <simon@simonster.com>
Date: Thu, 19 May 2011 23:28:31 +0000
update to citeproc-js 1.0.169
Diffstat:
1 file changed, 225 insertions(+), 153 deletions(-)
diff --git a/chrome/content/zotero/xpcom/citeproc.js b/chrome/content/zotero/xpcom/citeproc.js
@@ -438,6 +438,28 @@ CSL_E4X.prototype.insertChildNodeAfter = function (parent,node,pos,datexml) {
delete parent.*[pos];
return parent;
};
+CSL_E4X.prototype.insertPublisherAndPlace = function(myxml) {
+ default xml namespace = "http://purl.org/net/xbiblio/csl"; with({});
+ for each (var node in myxml..group) {
+ if (node.children().length() === 2) {
+ var twovars = [];
+ for each (var child in node.children()) {
+ if (child.children().length() === 0
+) {
+ twovars.push(child.@variable.toString());
+ if (child.@suffix.toString()
+ || child.@prefix.toString()) {
+ twovars = [];
+ break;
+ }
+ }
+ }
+ if (twovars.indexOf("publisher") > -1 && twovars.indexOf("publisher-place") > -1) {
+ node["@has-publisher-and-publisher-place"] = "true";
+ }
+ }
+ }
+};
CSL_E4X.prototype.addInstitutionNodes = function(myxml) {
var institution_long, institution_short, name_part, children, node, xml;
default xml namespace = "http://purl.org/net/xbiblio/csl"; with({});
@@ -528,15 +550,12 @@ CSL.Output.Queue.prototype.pop = function () {
return this.current.value().blobs.pop();
};
CSL.Output.Queue.prototype.getToken = function (name) {
- CSL.debug("XXX loc [1]");
var ret = this.formats.value()[name];
return ret;
};
CSL.Output.Queue.prototype.mergeTokenStrings = function (base, modifier) {
var base_token, modifier_token, ret, key;
- CSL.debug("XXX loc [2]");
base_token = this.formats.value()[base];
- CSL.debug("XXX loc [3]");
modifier_token = this.formats.value()[modifier];
ret = base_token;
if (modifier_token) {
@@ -564,7 +583,6 @@ CSL.Output.Queue.prototype.addToken = function (name, modifier, token) {
var newtok, attr;
newtok = new CSL.Token("output");
if ("string" === typeof token) {
- CSL.debug("XXX loc [4]");
token = this.formats.value()[token];
}
if (token && token.strings) {
@@ -578,23 +596,16 @@ CSL.Output.Queue.prototype.addToken = function (name, modifier, token) {
if ("string" === typeof modifier) {
newtok.strings.delimiter = modifier;
}
- CSL.debug("XXX loc [5]");
this.formats.value()[name] = newtok;
};
-var TESTINGTHING = {};
-TESTINGTHING.counter = 0;
CSL.Output.Queue.prototype.pushFormats = function (tokenstore) {
if (!tokenstore) {
tokenstore = {};
}
- CSL.debug("XXX pushFormats() ["+TESTINGTHING.counter+"]");
- TESTINGTHING.counter += 1;
tokenstore.empty = this.empty;
this.formats.push(tokenstore);
};
CSL.Output.Queue.prototype.popFormats = function (tokenstore) {
- TESTINGTHING.counter += 1;
- CSL.debug("XXX popFormats() ["+TESTINGTHING.counter+"]");
this.formats.pop();
};
CSL.Output.Queue.prototype.startTag = function (name, token) {
@@ -612,14 +623,11 @@ CSL.Output.Queue.prototype.openLevel = function (token, ephemeral) {
if ("object" === typeof token) {
blob = new CSL.Blob(token);
} else if ("undefined" === typeof token) {
- CSL.debug("XXX loc [6]");
blob = new CSL.Blob(this.formats.value().empty, false, "empty");
} else {
- CSL.debug("XXX loc [7]");
if (!this.formats.value() || !this.formats.value()[token]) {
throw "CSL processor error: call to nonexistent format token \"" + token + "\"";
}
- CSL.debug("XXX loc [8]");
blob = new CSL.Blob(this.formats.value()[token], false, token);
}
curr = this.current.value();
@@ -648,13 +656,11 @@ CSL.Output.Queue.prototype.append = function (str, tokname, notSerious) {
}
blob = false;
if (!tokname) {
- CSL.debug("XXX loc [9]");
token = this.formats.value().empty;
} else if (tokname === "literal") {
token = true;
useblob = false;
} else if ("string" === typeof tokname) {
- CSL.debug("XXX loc [10]");
token = this.formats.value()[tokname];
} else {
token = tokname;
@@ -1404,9 +1410,6 @@ CSL.tokenExec = function (token, Item, item) {
next = maybenext;
}
}
- if (false) {
- CSL.debug(token.name + " (" + token.tokentype + ") ---> done");
- }
return next;
};
CSL.expandMacro = function (macro_key_token) {
@@ -1840,7 +1843,7 @@ CSL.DateParser = function () {
};
CSL.Engine = function (sys, style, lang, forceLang) {
var attrs, langspec, localexml, locale;
- this.processor_version = "1.0.165";
+ this.processor_version = "1.0.169";
this.csl_version = "1.0";
this.sys = sys;
this.sys.xml = new CSL.System.Xml.Parsing();
@@ -1868,13 +1871,11 @@ CSL.Engine = function (sys, style, lang, forceLang) {
this.dateput = new CSL.Output.Queue(this);
this.cslXml = this.sys.xml.makeXml(style);
this.sys.xml.addInstitutionNodes(this.cslXml);
+ this.sys.xml.insertPublisherAndPlace(this.cslXml);
attrs = this.sys.xml.attributes(this.cslXml);
if ("undefined" === typeof attrs["@sort-separator"]) {
this.sys.xml.setAttribute(this.cslXml, "sort-separator", ", ");
}
- if ("undefined" === typeof attrs["@name-delimiter"]) {
- this.sys.xml.setAttribute(this.cslXml, "name-delimiter", ", ");
- }
this.opt["initialize-with-hyphen"] = true;
this.setStyleAttributes();
this.opt.xclass = sys.xml.getAttributeValue(this.cslXml, "class");
@@ -2820,18 +2821,7 @@ CSL.Engine.prototype.processCitationCluster = function (citation, citationsPre,
this.tmp.citation_errors = [];
var return_data = {"bibchange": false};
this.registry.return_data = return_data;
- if (citation) {
- CSL.debug("citationID received by processCitationCluster(): ("+citation.citationID+")");
- } else {
- CSL.error("nil citation received by processCitationCluster()");
- }
this.setCitationId(citation);
- if (citation) {
- CSL.debug(" citationID after setCitationId(): ("+citation.citationID+")");
- CSL.debug(" citationreg.citationById object for "+citation.citationID+": ("+this.registry.citationreg.citationById[citation.citationID]+")");
- } else {
- CSL.error(" nil citation after setCitationID()");
- }
var oldCitationList;
var oldItemList;
var oldAmbigs;
@@ -2875,14 +2865,12 @@ CSL.Engine.prototype.processCitationCluster = function (citation, citationsPre,
var citationByIndex = [];
for (i = 0, ilen = citationsPre.length; i < ilen; i += 1) {
c = citationsPre[i];
- CSL.debug(" -- attempting to access Pre citation with ID: ("+c[0]+")");
this.registry.citationreg.citationById[c[0]].properties.noteIndex = c[1];
citationByIndex.push(this.registry.citationreg.citationById[c[0]]);
}
citationByIndex.push(citation);
for (i = 0, ilen = citationsPost.length; i < ilen; i += 1) {
c = citationsPost[i];
- CSL.debug(" -- attempting to access Post citation with ID: ("+c[0]+")");
this.registry.citationreg.citationById[c[0]].properties.noteIndex = c[1];
citationByIndex.push(this.registry.citationreg.citationById[c[0]]);
}
@@ -4010,42 +3998,75 @@ CSL.Node["et-al"] = {
}
};
CSL.Node.group = {
- build: function (state, target, quashquash) {
+ build: function (state, target) {
var func, execs;
if (this.tokentype === CSL.START) {
CSL.Util.substituteStart.call(this, state, target);
if (state.build.substitute_level.value()) {
state.build.substitute_level.replace((state.build.substitute_level.value() + 1));
}
- if (!quashquash || true) {
- func = function (state, Item) {
- state.tmp.term_sibling.push([false, false, false], CSL.LITERAL);
- };
- this.execs.push(func);
- }
+ func = function (state, Item) {
+ state.tmp.term_sibling.push([false, false, false], CSL.LITERAL);
+ };
+ this.execs.push(func);
func = function (state, Item) {
state.output.startTag("group", this);
};
execs = [];
execs.push(func);
this.execs = execs.concat(this.execs);
- } else {
- if (!quashquash || true) {
- func = function (state, Item) {
- var flag = state.tmp.term_sibling.value();
- state.output.endTag();
- if (!flag[2] && (flag[1] || (!flag[1] && !flag[0]))) {
- if (state.output.current.value().blobs) {
- state.output.current.value().blobs.pop();
+ if (this.strings["has-publisher-and-publisher-place"]) {
+ state.build["publisher-special"] = true;
+ var outer_area = state.build.area.replace(/_sort$/, "");
+ if ("string" === typeof state[outer_area].opt["name-delimiter"]) {
+ func = function (state, Item) {
+ if (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);
+ state.publisherOutput["publisher-list"] = publisher_lst;
+ state.publisherOutput["publisher-place-list"] = publisher_place_lst;
+ state.publisherOutput.group_tok = this;
+ }
}
}
- state.tmp.term_sibling.pop();
- if ((flag[2] || (!flag[1] && flag[0])) && state.tmp.term_sibling.mystack.length > 1) {
- state.tmp.term_sibling.replace([false, false, true]);
- }
- };
- this.execs.push(func);
+ this.execs.push(func);
+ }
+ }
+ } else {
+ if (state.build["publisher-special"]) {
+ state.build["publisher-special"] = false;
+ var outer_area = state.build.area.replace(/_sort$/, "");
+ if ("string" === typeof state[outer_area].opt["name-delimiter"]) {
+ func = function (state, Item) {
+ if (state.publisherOutput) {
+ var outer_area = state.tmp.area.replace("_sort", "");
+ state.publisherOutput.name_delimiter = state[outer_area].opt["name-delimiter"];
+ state.publisherOutput.delimiter_precedes_last = state[outer_area].opt["delimiter-precedes-last"];
+ state.publisherOutput.and = state[outer_area].opt["and"];
+ state.publisherOutput.render();
+ state.publisherOutput = false;
+ }
+ };
+ this.execs.push(func);
+ }
}
+ func = function (state, Item) {
+ var flag = state.tmp.term_sibling.value();
+ state.output.endTag();
+ if (!flag[2] && (flag[1] || (!flag[1] && !flag[0]))) {
+ if (state.output.current.value().blobs) {
+ state.output.current.value().blobs.pop();
+ }
+ }
+ state.tmp.term_sibling.pop();
+ if ((flag[2] || (!flag[1] && flag[0])) && state.tmp.term_sibling.mystack.length > 1) {
+ state.tmp.term_sibling.replace([false, false, true]);
+ }
+ };
+ this.execs.push(func);
}
target.push(this);
if (this.tokentype === CSL.END) {
@@ -5436,7 +5457,7 @@ CSL.NameOutput.prototype._renderOnePersonalName = function (value, pos, i) {
} else if (this.name.strings["name-as-sort-order"] === "all" || (this.name.strings["name-as-sort-order"] === "first" && i === 0)) {
if (["always", "display-and-sort"].indexOf(this.state.opt["demote-non-dropping-particle"]) > -1) {
second = this._join([given, dropping_particle, non_dropping_particle], " ");
- if (this.given) {
+ if (second && this.given) {
second.strings.prefix = this.given.strings.prefix;
second.strings.suffix = this.given.strings.suffix;
}
@@ -5448,12 +5469,12 @@ CSL.NameOutput.prototype._renderOnePersonalName = function (value, pos, i) {
blob = this._join([merged, suffix], sort_sep);
} else {
first = this._join([non_dropping_particle, family], " ");
- if (this.family) {
+ if (first && this.family) {
first.strings.prefix = this.family.strings.prefix;
first.strings.suffix = this.family.strings.suffix;
}
second = this._join([given, dropping_particle], " ");
- if (this.given) {
+ if (second && this.given) {
second.strings.prefix = this.given.strings.prefix;
second.strings.suffix = this.given.strings.suffix;
}
@@ -5468,11 +5489,11 @@ CSL.NameOutput.prototype._renderOnePersonalName = function (value, pos, i) {
}
}
second = this._join([dropping_particle, non_dropping_particle, family], " ");
- if (this.family) {
+ if (second && this.family) {
second.strings.prefix = this.family.strings.prefix;
second.strings.suffix = this.family.strings.suffix;
}
- if (this.given) {
+ if (given && this.given) {
given.strings.prefix = this.given.strings.prefix;
given.strings.suffix = this.given.strings.suffix;
}
@@ -5605,7 +5626,7 @@ CSL.NameOutput.prototype._parseName = function (name) {
noparse = false;
}
if (!name["non-dropping-particle"] && name.family && !noparse) {
- m = name.family.match(/^((?:[a-z][ \'\u2019a-z]*[\s+|\'\u2019]|[DVL][^ ]\s+|[DVL][^ ][^ ]\s+))/);
+ m = name.family.match(/^((?:[a-z][ \'\u2019a-z]*[\s+|\'\u2019]|[DVL][^ ]\s+[a-z]*\s*|[DVL][^ ][^ ]\s+[a-z]*\s*))/);
if (m) {
name.family = name.family.slice(m[1].length);
name["non-dropping-particle"] = m[1].replace(/\s+$/, "");
@@ -5702,7 +5723,7 @@ CSL.evaluateLabel = function (node, state, Item, item) {
return CSL.castLabel(state, node, myterm, plural);
};
CSL.evaluateStringPluralism = function (str) {
- if (str && str.match(/(?:[0-9], *[0-9]| and |&|[0-9] *- *[0-9])/)) {
+ if (str && str.match(/(?:[0-9],\s*[0-9]|\s+and\s+|&|[0-9]\s*[\-\u2013]\s*[0-9])/)) {
return 1;
} else {
return 0;
@@ -5715,6 +5736,77 @@ CSL.castLabel = function (state, node, term, plural) {
}
return ret;
};
+CSL.PublisherOutput = function (state) {
+ this.state = state;
+ this.varlist = [];
+};
+CSL.PublisherOutput.prototype.render = function () {
+ this.clearVars();
+ this.composeAndBlob();
+ this.composeElements();
+ this.composePublishers();
+ this.joinPublishers();
+};
+CSL.PublisherOutput.prototype.composeAndBlob = function () {
+ this.and_blob = {};
+ var and_term;
+ if (this.and === "text") {
+ and_term = this.state.getTerm("and");
+ } else if (this.and === "symbol") {
+ and_term = "&";
+ }
+ var tok = new CSL.Token();
+ tok.strings.suffix = " ";
+ tok.strings.prefix = " ";
+ this.state.output.append(and_term, tok, true);
+ var no_delim = this.state.output.pop();
+ tok.strings.prefix = this.name_delimiter;
+ this.state.output.append(and_term, tok, true);
+ var with_delim = this.state.output.pop();
+ if (this.delimiter_precedes_last === "always") {
+ this.and_blob.single = with_delim;
+ } else if (this.delimiter_precedes_last === "never") {
+ this.and_blob.single = no_delim;
+ this.and_blob.multiple = no_delim;
+ } else {
+ this.and_blob.single = no_delim;
+ this.and_blob.multiple = with_delim;
+ }
+};
+CSL.PublisherOutput.prototype.composeElements = function () {
+ for (var i = 0, ilen = 2; i < ilen; i += 1) {
+ var varname = ["publisher", "publisher-place"][i];
+ for (var j = 0, jlen = this["publisher-list"].length; j < jlen; j += 1) {
+ var str = this[varname + "-list"][j];
+ var tok = this[varname + "-token"];
+ this.state.output.append(str, tok, true);
+ this[varname + "-list"][j] = this.state.output.pop();
+ }
+ }
+};
+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, delim, this.and_blob.single, this.and_blob.multiple, this.group_tok);
+ this.state.output.append(publishers, "literal");
+};
+CSL.PublisherOutput.prototype._join = CSL.NameOutput.prototype._join;
+CSL.PublisherOutput.prototype._getToken = CSL.NameOutput.prototype._getToken;
+CSL.PublisherOutput.prototype.clearVars = function () {
+ this.state.tmp["publisher-list"] = false;
+ this.state.tmp["publisher-place-list"] = false;
+ this.state.tmp["publisher-group-token"] = false;
+ this.state.tmp["publisher-token"] = false;
+ this.state.tmp["publisher-place-token"] = false;
+};
CSL.Node.name = {
build: function (state, target) {
var func, pos, len, attrname;
@@ -6405,7 +6497,7 @@ CSL.Attributes["@type"] = function (state, arg) {
this.tests.push(func);
};
CSL.Attributes["@variable"] = function (state, arg) {
- var variables, pos, len, func, output, variable, varlen, needlen, ret, x, myitem, key, flag;
+ var variables, pos, len, func, output, variable, varlen, needlen, ret, myitem, key, flag;
this.variables = arg.split(/\s+/);
this.variables_real = arg.split(/\s+/);
if ("label" === this.name && this.variables[0]) {
@@ -6513,7 +6605,7 @@ CSL.Attributes["@variable"] = function (state, arg) {
this.execs.push(func);
} else if (["if", "else-if"].indexOf(this.name) > -1) {
func = function (state, Item, item) {
- var key;
+ var key, x;
ret = [];
len = this.variables.length;
for (pos = 0; pos < len; pos += 1) {
@@ -6528,7 +6620,7 @@ CSL.Attributes["@variable"] = function (state, arg) {
x = true;
} else if ("object" === typeof myitem[variable]) {
for (key in myitem[variable]) {
- if (myitem[variable].hasOwnProperty(key)) {
+ if (myitem[variable][key]) {
x = true;
} else {
x = false;
@@ -6734,6 +6826,18 @@ CSL.Attributes["@locator"] = function (state, arg) {
this.tests.push(func);
}
};
+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) {
+ this.strings["publisher-delimiter-precedes-last"] = arg;
+};
+CSL.Attributes["@publisher-delimiter"] = function (state, arg) {
+ this.strings["publisher-delimiter"] = arg;
+};
+CSL.Attributes["@publisher-and"] = function (state, arg) {
+ this.strings["publisher-and"] = arg;
+};
CSL.Attributes["@newdate"] = function (state, arg) {
};
CSL.Attributes["@position"] = function (state, arg) {
@@ -7033,19 +7137,16 @@ CSL.Stack.prototype.length = function () {
};
CSL.Util = {};
CSL.Util.Match = function () {
- var func, pos, len, reslist, res, ppos, llen;
this.any = function (token, state, Item, item) {
var ret = false;
- len = token.tests.length;
- for (pos = 0; pos < len; pos += 1) {
- func = token.tests[pos];
- reslist = func.call(token, state, Item, item);
+ for (var i = 0, ilen = token.tests.length; i < ilen; i += 1) {
+ var func = token.tests[i];
+ var reslist = func.call(token, state, Item, item);
if ("object" !== typeof reslist) {
reslist = [reslist];
}
- llen = reslist.length;
- for (ppos = 0; ppos < llen; ppos += 1) {
- if (reslist[ppos]) {
+ for (var j = 0, jlen = reslist.length; j < jlen; j += 1) {
+ if (reslist[j]) {
ret = true;
break;
}
@@ -7065,16 +7166,14 @@ CSL.Util.Match = function () {
};
this.none = function (token, state, Item, item) {
var ret = true;
- len = this.tests.length;
- for (pos = 0; pos < len; pos += 1) {
- func = this.tests[pos];
- reslist = func.call(token, state, Item, item);
+ for (var i = 0, ilen = this.tests.length; i < ilen; i += 1) {
+ var func = this.tests[i];
+ var reslist = func.call(token, state, Item, item);
if ("object" !== typeof reslist) {
reslist = [reslist];
}
- llen = reslist.length;
- for (ppos = 0; ppos < llen; ppos += 1) {
- if (reslist[ppos]) {
+ for (var j = 0, jlen = reslist.length; j < jlen; j += 1) {
+ if (reslist[j]) {
ret = false;
break;
}
@@ -7095,8 +7194,8 @@ CSL.Util.Match = function () {
this.all = function (token, state, Item, item) {
var ret = true;
for (var i = 0, ilen = this.tests.length; i < ilen; i += 1) {
- func = this.tests[i];
- reslist = func.call(token, state, Item, item);
+ var func = this.tests[i];
+ var reslist = func.call(token, state, Item, item);
if ("object" !== typeof reslist) {
reslist = [reslist];
}
@@ -7218,6 +7317,23 @@ CSL.Transform = function (state) {
}
}
this.setAbbreviations = setAbbreviations;
+ function publisherCheck (varname, primary, tok) {
+ if (state.publisherOutput && primary) {
+ if (["publisher","publisher-place"].indexOf(varname) === -1) {
+ return false;
+ } else {
+ state.publisherOutput[varname + "-token"] = tok;
+ state.publisherOutput.varlist.push(varname);
+ var lst = primary.split(/;\s*/);
+ if (lst.length === state.publisherOutput[varname + "-list"].length) {
+ state.tmp[varname + "-list"] = lst;
+ }
+ state.tmp[varname + "-token"] = tok;
+ return true;
+ }
+ }
+ return false;
+ };
function getOutputFunction(variables) {
var mytoken, mysubsection, myfieldname, abbreviation_fallback, alternative_varname, transform_locale, transform_fallback, getTextSubfield;
mytoken = CSL.Util.cloneToken(token); // the token isn't needed, is it?
@@ -7227,20 +7343,18 @@ CSL.Transform = function (state) {
alternative_varname = opt.alternative_varname;
transform_locale = opt.transform_locale;
transform_fallback = opt.transform_fallback;
- if (false && mysubsection) {
+ if (transform_locale === "locale-sec") {
return function (state, Item) {
- var primary;
+ var primary, secondary, primary_tok, secondary_tok, key;
if (!variables[0]) {
return null;
}
- primary = getTextSubField(Item, myfieldname, transform_locale, transform_fallback);
- primary = abbreviate(state, Item, alternative_varname, primary, mysubsection, true);
- state.output.append(primary, this);
- };
- } else if (transform_locale === "locale-sec") {
- return function (state, Item) {
- var primary, secondary, primary_tok, secondary_tok, key;
- if (!variables[0]) {
+ if (state.tmp["publisher-list"]) {
+ if (variables[0] === "publisher") {
+ state.tmp["publisher-token"] = this;
+ } else if (variables[0] === "publisher-place") {
+ state.tmp["publisher-place-token"] = this;
+ }
return null;
}
if (state.opt["locale-suppress-title-transliteration"]
@@ -7280,7 +7394,11 @@ CSL.Transform = function (state) {
return null;
}
primary = getTextSubField(Item, myfieldname, transform_locale, transform_fallback);
- state.output.append(primary, this);
+ if (publisherCheck(variables[0], primary, this)) {
+ return null;
+ } else {
+ state.output.append(primary, this);
+ }
return null;
};
}
@@ -8353,57 +8471,16 @@ CSL.Util.Suffixator = function (slist) {
}
this.slist = slist.split(",");
};
-CSL.Util.Suffixator.prototype.format = function (num) {
- var suffixes = this.get_suffixes(num);
- return suffixes[(suffixes.length - 1)];
-};
-CSL.Util.Suffixator.prototype.get_suffixes = function (num) {
- var suffixes, digits, chrs, pos, len, llen, ppos;
- num = parseInt(num, 10);
- suffixes = [];
- for (pos = 0; pos <= num; pos += 1) {
- if (!pos) {
- suffixes.push([0]);
- } else {
- suffixes.push(this.incrementArray(suffixes[(suffixes.length - 1)], this.slist));
- }
- }
- len = suffixes.length;
- for (pos = 0; pos < len; pos += 1) {
- digits = suffixes[pos];
- chrs = "";
- llen = digits.length;
- for (ppos = 0; ppos < llen; ppos += 1) {
- chrs = chrs + this.slist[digits[ppos]];
- }
- suffixes[pos] = chrs;
- }
- return suffixes;
-};
-CSL.Util.Suffixator.prototype.incrementArray = function (array) {
- var incremented, newdigit, i, pos, len, ppos, llen;
- array = array.slice();
- incremented = false;
- len = array.length - 1;
- for (pos = len; pos > -1; pos += -1) {
- if (array[pos] < (this.slist.length - 1)) {
- array[pos] += 1;
- for (ppos = (pos + 1), llen = array.length; ppos < llen; ppos += 1) {
- array[ppos] = 0;
- }
- incremented = true;
- break;
- }
- }
- if (!incremented) {
- len = array.length;
- for (pos = 0; pos < len; pos += 1) {
- array[pos] = 0;
- }
- newdigit = [0];
- array = newdigit.concat(array);
- }
- return array;
+CSL.Util.Suffixator.prototype.format = function (N) {
+ var X, N;
+ N += 1;
+ var key = "";
+ do {
+ X = ((N % 26) == 0) ? 26 : (N % 26);
+ key = this.slist[X-1] + key;
+ N = (N - X) / 26;
+ } while ( N != 0 );
+ return key;
};
CSL.Util.PageRangeMangler = {};
CSL.Util.PageRangeMangler.getFunction = function (state) {
@@ -8506,7 +8583,7 @@ CSL.Util.PageRangeMangler.getFunction = function (state) {
};
if (!state.opt["page-range-format"]) {
ret_func = function (str) {
- return str.replace("-", "\u2013", "g");
+ return str;
};
} else if (state.opt["page-range-format"] === "expanded") {
ret_func = function (str) {
@@ -8726,11 +8803,9 @@ CSL.Util.FlipFlopper.prototype.getSplitStrings = function (str) {
head = strs.slice(0, (badTagPos - 1));
tail = strs.slice((badTagPos + 2));
sep = strs[badTagPos];
- CSL.debug("sep [1] is: ("+sep+") for badTagPos: ("+badTagPos+") in strs ("+strs+")");
if (sep.length && sep[0] !== "<" && this.openToDecorations[sep] && this.quotechars.indexOf(sep.replace(/\s+/g,"")) === -1) {
params = this.openToDecorations[sep];
sep = this.state.fun.decorate[params[0]][params[1][0]](this.state);
- CSL.debug("sep [2] is: ("+sep+") from params[0] ("+params[0]+") and params[1][0] ("+params[1][0]+") -- params is ("+params+")");
}
resplice = strs[(badTagPos - 1)] + sep + strs[(badTagPos + 1)];
head.push(resplice);
@@ -9409,9 +9484,6 @@ CSL.Registry.prototype.compareRegistryTokens = function (a, b) {
return 0;
};
CSL.Registry.prototype.registerAmbigToken = function (akey, id, ambig_config, tainters) {
- if (!this.registry[id]) {
- CSL.debug("Warning: unregistered item: itemID=("+id+"), akey=("+akey+")");
- }
if (this.registry[id] && this.registry[id].disambig && this.registry[id].disambig.names) {
for (var i = 0, ilen = ambig_config.names.length; i < ilen; i += 1) {
var new_names_params = ambig_config.names[i];
@@ -9592,7 +9664,7 @@ CSL.Registry.NameReg = function (state) {
if (form == "short") {
return 0;
} else if ("string" == typeof initials) {
- return 1
+ return 1;
}
} else {
return param;