update to citeproc-js 1.0.150

This commit is contained in:
Simon Kornblith 2011-04-18 22:56:33 +00:00
parent faf478e386
commit d6b3c5fed6

View file

@ -702,8 +702,8 @@ CSL.Output.Queue.prototype.string = function (state, myblobs, blob) {
if (blob && blob.new_locale) {
state.opt.lang = blob.new_locale;
}
for (pos = 0, len = blobs.length; pos < len; pos += 1) {
blobjr = blobs[pos];
for (var i = 0, ilen = blobs.length; i < ilen; i += 1) {
blobjr = blobs[i];
if ("string" === typeof blobjr.blobs) {
if ("number" === typeof blobjr.num) {
ret.push(blobjr);
@ -713,8 +713,11 @@ CSL.Output.Queue.prototype.string = function (state, myblobs, blob) {
use_prefix = blobjr.strings.prefix;
if (!state.tmp.suppress_decorations) {
llen = blobjr.decorations.length;
for (ppos = 0; ppos < llen; ppos += 1) {
params = blobjr.decorations[ppos];
for (j = 0, jlen = blobjr.decorations.length; j < jlen; j += 1) {
params = blobjr.decorations[j];
if (CSL.normalDecorIsOrphan(blobjr, params)) {
continue;
}
b = state.fun.decorate[params[0]][params[1]](state, b);
}
}
@ -774,6 +777,9 @@ CSL.Output.Queue.prototype.string = function (state, myblobs, blob) {
if (["@bibliography", "@display"].indexOf(params[0]) === -1) {
continue;
}
if (CSL.normalDecorIsOrphan(blobs_start, params)) {
continue;
}
blobs_start = state.fun.decorate[params[0]][params[1]].call(blob, state, blobs_start);
}
}
@ -857,6 +863,9 @@ CSL.Output.Queue.prototype.renderBlobs = function (blobs, delim) {
llen = blob.decorations.length;
for (ppos = 0; ppos < llen; ppos += 1) {
params = blob.decorations[ppos];
if (CSL.normalDecorIsOrphan(blob, params)) {
continue;
}
str = state.fun.decorate[params[0]][params[1]](state, str);
}
}
@ -1257,6 +1266,24 @@ CSL.setDecorations = function (state, attributes) {
}
return ret;
};
CSL.normalDecorIsOrphan = function (blob, params) {
if (params[1] === "normal") {
var use_param = false;
for (var k = blob.alldecor.length - 1; k > -1; k += -1) {
for (var n = blob.alldecor[k].length - 1; n > -1; n += -1) {
if (blob.alldecor[k][n][0] === params[0]) {
if (blob.alldecor[k][n][1] !== "normal") {
use_param = true;
}
}
}
}
if (!use_param) {
return true;
}
}
return false;
};
CSL.compareAmbigConfig = function(a, b) {
var ret, pos, len, ppos, llen;
if (a.names.length !== b.names.length) {
@ -1277,42 +1304,40 @@ CSL.compareAmbigConfig = function(a, b) {
return 0;
};
CSL.cloneAmbigConfig = function (config, oldconfig, tainters) {
var ret, param, pos, ppos, len, llen;
ret = {};
var ret = {};
ret.names = [];
ret.givens = [];
ret.year_suffix = false;
ret.disambiguate = false;
for (pos = 0, len = config.names.length; pos < len; pos += 1) {
param = config.names[pos];
if (oldconfig && (!oldconfig.names[pos] || oldconfig.names[pos] !== param)) {
for (ppos = 0, llen = tainters.length; ppos < llen; ppos += 1) {
this.tmp.taintedItemIDs[tainters[ppos].id] = true;
for (var i = 0, ilen = config.names.length; i < ilen; i += 1) {
var param = config.names[i];
if (oldconfig && (!oldconfig.names[i] || oldconfig.names[i] !== param)) {
for (var j = 0, jlen = tainters.length; j < jlen; j += 1) {
this.tmp.taintedItemIDs[tainters[j].id] = true;
}
oldconfig = false;
}
ret.names[pos] = param;
ret.names[i] = param;
}
for (pos = 0, len = config.givens.length; pos < len; pos += 1) {
param = [];
llen = config.givens[pos].length;
for (ppos = 0; ppos < llen; ppos += 1) {
if (oldconfig && oldconfig.givens[pos][ppos] !== config.givens[pos][ppos]) {
for (ppos = 0, llen = tainters.length; ppos < llen; ppos += 1) {
this.tmp.taintedItemIDs[tainters[ppos].id] = true;
for (var i = 0, ilen = config.givens.length; i < ilen; i += 1) {
var param = [];
for (var j = 0, jlen = config.givens[i].length; j < jlen; j += 1) {
if (oldconfig && oldconfig.givens[i][j] !== config.givens[i][j]) {
for (var k = 0, klen = tainters.length; k < klen; k += 1) {
this.tmp.taintedItemIDs[tainters[k].id] = true;
}
oldconfig = false;
}
param.push(config.givens[pos][ppos]);
param.push(config.givens[i][j]);
}
ret.givens.push(param);
}
if (tainters && tainters.length > 1) {
if (tainters.length == 2 || (oldconfig && oldconfig.year_suffix !== config.year_suffix)) {
for (pos = 0, len = tainters.length; pos < len; pos += 1) {
var oldYS = this.registry.registry[tainters[pos].id].disambig.year_suffix;
if (tainters && (false === oldYS || oldYS != pos)) {
this.tmp.taintedItemIDs[tainters[pos].id] = true;
for (var i = 0, ilen = tainters.length; i < ilen; i += 1) {
var oldYS = this.registry.registry[tainters[i].id].disambig.year_suffix;
if (tainters && (false === oldYS || oldYS != i)) {
this.tmp.taintedItemIDs[tainters[i].id] = true;
}
}
oldconfig = false;
@ -1781,7 +1806,7 @@ CSL.DateParser = function (txt) {
};
CSL.Engine = function (sys, style, lang, forceLang) {
var attrs, langspec, localexml, locale;
this.processor_version = "1.0.148";
this.processor_version = "1.0.150";
this.csl_version = "1.0";
this.sys = sys;
this.sys.xml = new CSL.System.Xml.Parsing();
@ -2995,21 +3020,20 @@ CSL.Engine.prototype.makeCitationCluster = function (rawList) {
return str;
};
CSL.getAmbiguousCite = function (Item, disambig) {
var use_parallels, ret;
if (disambig) {
this.tmp.disambig_request = disambig;
} else {
this.tmp.disambig_request = false;
}
this.tmp.area = "citation";
use_parallels = this.parallel.use_parallels;
var use_parallels = this.parallel.use_parallels;
this.parallel.use_parallels = false;
this.tmp.suppress_decorations = true;
this.tmp.just_looking = true;
CSL.getCite.call(this, Item, {position: 1});
CSL.Output.Queue.purgeEmptyBlobs(this.output.queue);
CSL.Output.Queue.adjustPunctuation(this, this.output.queue);
ret = this.output.string(this, this.output.queue);
var ret = this.output.string(this, this.output.queue);
this.tmp.just_looking = false;
this.tmp.suppress_decorations = false;
this.parallel.use_parallels = use_parallels;
@ -3177,6 +3201,9 @@ CSL.getCitationCluster = function (inputList, citationID) {
len = this.citation.opt.layout_decorations.length;
for (pos = 0; pos < len; pos += 1) {
params = this.citation.opt.layout_decorations[pos];
if (params[1] === "normal") {
continue;
}
result = this.fun.decorate[params[0]][params[1]](this, result);
}
}
@ -7960,7 +7987,7 @@ CSL.Util.FlipFlopper = function (state) {
var tagdefs, pos, len, p, entry, allTags, ret, def, esc, makeHashes, closeTags, flipTags, openToClose, openToDecorations, okReverse, hashes, allTagsLst, lst;
this.state = state;
this.blob = false;
this.quotechars = ["'", '"'];
this.quotechars = ['"', "'"];
tagdefs = [
["<i>", "</i>", "italics", "@font-style", ["italic", "normal","normal"], true],
["<b>", "</b>", "bold", "@font-weight", ["bold", "normal","normal"], true],
@ -8053,6 +8080,7 @@ CSL.Util.FlipFlopper = function (state) {
};
CSL.Util.FlipFlopper.prototype.init = function (str, blob) {
this.txt_esc = CSL.getSafeEscape(this.state.opt.mode, this.state.tmp.area);
str = this._normalizeString(str);
if (!blob) {
this.strs = this.getSplitStrings(str);
this.blob = new CSL.Blob();
@ -8063,6 +8091,13 @@ CSL.Util.FlipFlopper.prototype.init = function (str, blob) {
}
this.blobstack = new CSL.Stack(this.blob);
};
CSL.Util.FlipFlopper.prototype._normalizeString = function (str) {
for (var i = 0, ilen = 2; i < ilen; i += 1) {
str = str.replace(this.quotechars[i + 2], this.quotechars[0]);
str = str.replace(this.quotechars[i + 4], this.quotechars[1]);
}
return str;
};
CSL.Util.FlipFlopper.prototype.getSplitStrings = function (str) {
var strs, pos, len, newstr, head, tail, expected_closers, expected_openers, expected_flips, tagstack, badTagStack, posA, sameAsOpen, openRev, flipRev, tag, ibeenrunned, posB, wanted_closer, posC, sep, resplice, params, lenA, lenB, lenC, badTagPos, mx, myret;
mx = str.match(this.allTagsRexMatch);
@ -8541,12 +8576,12 @@ CSL.Output.Formats.prototype.rtf = {
"@passthrough/true": CSL.Output.Formatters.passthrough,
"@strip-periods/true": CSL.Output.Formatters.strip_periods,
"@font-style/italic":"\\i %%STRING%%\\i0{}",
"@font-style/normal":false,
"@font-style/normal":"\\i0{}%STRING%%\\i{}",
"@font-style/oblique":"\\i %%STRING%%\\i0{}",
"@font-variant/small-caps":"\\scaps %%STRING%%\\scaps0{}",
"@font-variant/normal":false,
"@font-variant/normal":"\\scaps0{}%%STRING%%\\scaps{}",
"@font-weight/bold":"\\b %%STRING%%\\b0{}",
"@font-weight/normal":false,
"@font-weight/normal":"\\b0{}%STRING%%\\b{}",
"@font-weight/light":false,
"@text-decoration/none":false,
"@text-decoration/underline":"\\ul %%STRING%%\\ul0{}",
@ -8595,6 +8630,7 @@ CSL.Registry = function (state) {
this.reflist = [];
this.namereg = new CSL.Registry.NameReg(state);
this.citationreg = new CSL.Registry.CitationReg(state);
this.cache = {};
this.mylist = [];
this.myhash = {};
this.deletes = [];
@ -9186,16 +9222,22 @@ CSL.Disambiguation.prototype.evalScan = function (ismax) {
};
CSL.Disambiguation.prototype.disNames = function (ismax) {
var pos, len;
if (this.clashes[1] === 0) {
if (this.clashes[1] === 0 && this.nonpartners.length === 1) {
mybase = CSL.cloneAmbigConfig(this.base);
mybase.year_suffix = false;
this.state.registry.registerAmbigToken(this.akey, "" + this.partners[0].id, mybase);
if (this.nonpartners.length === 1) {
this.state.registry.registerAmbigToken(this.akey, "" + this.nonpartners[0].id, this.base);
this.lists[this.listpos] = [this.base,[]];
} else {
this.lists[this.listpos] = [this.base, this.nonpartners];
}
this.state.registry.registerAmbigToken(this.akey, "" + this.nonpartners[0].id, this.base);
this.lists[this.listpos] = [this.base, []];
} else if (this.clashes[1] === 0) {
mybase = CSL.cloneAmbigConfig(this.base);
mybase.year_suffix = false;
this.state.registry.registerAmbigToken(this.akey, "" + this.partners[0].id, mybase);
this.lists[this.listpos] = [this.base, this.nonpartners];
} else if (this.nonpartners.length === 1) {
mybase = CSL.cloneAmbigConfig(this.base);
mybase.year_suffix = false;
this.state.registry.registerAmbigToken(this.akey, "" + this.nonpartners[0].id, this.base);
this.lists[this.listpos] = [this.base, this.partners];
} else if (this.clashes[1] < this.clashes[0]) {
this.lists[this.listpos] = [this.base, this.partners];
if (this.nonpartners.length === 1) {
@ -9218,19 +9260,31 @@ CSL.Disambiguation.prototype.disNames = function (ismax) {
};
CSL.Disambiguation.prototype.disGivens = function (ismax) {
var pos, len;
if (this.clashes[1] === 0) {
if (this.clashes[1] === 0 && this.nonpartners.length === 1) {
if (this.clashes[0] === 1) {
this.base = this.decrementNames();
}
mybase = CSL.cloneAmbigConfig(this.base);
mybase.year_suffix = false;
this.state.registry.registerAmbigToken(this.akey, "" + this.partners[0].id, mybase);
if (this.nonpartners.length === 1) {
this.state.registry.registerAmbigToken(this.akey, "" + this.nonpartners[0].id, this.base);
this.lists[this.listpos] = [this.base,[]];
} else {
this.lists[this.listpos] = [this.base, this.nonpartners];
this.state.registry.registerAmbigToken(this.akey, "" + this.nonpartners[0].id, this.base);
this.lists[this.listpos] = [this.base, []];
} else if (this.clashes[1] === 0) {
if (this.clashes[0] === 1) {
this.base = this.decrementNames();
}
mybase = CSL.cloneAmbigConfig(this.base);
mybase.year_suffix = false;
this.state.registry.registerAmbigToken(this.akey, "" + this.partners[0].id, mybase);
this.lists[this.listpos] = [this.base, this.nonpartners];
} else if (this.nonpartners.length === 1) {
if (this.clashes[0] === 1) {
this.base = this.decrementNames();
}
mybase = CSL.cloneAmbigConfig(this.base);
mybase.year_suffix = false;
this.state.registry.registerAmbigToken(this.akey, "" + this.nonpartners[0].id, this.base);
this.lists[this.listpos] = [this.base, this.partners];
} else if (this.clashes[1] < this.clashes[0]) {
this.lists[this.listpos] = [this.base, this.partners];
if (this.nonpartners.length === 1) {