commit 437b1f1c8006e406eb249cbcb2960c9d48a3b4a9
parent 051cd3ad300e966549b51a2661f07466625e3213
Author: Frank <biercenator@gmail.com>
Date: Fri, 20 Apr 2012 23:34:38 +0000
Upgrade citeproc-js to version 1.0.324
This fixes an anomaly in the application of text escapes to
output identified by Rintze Zelle.
Diffstat:
1 file changed, 108 insertions(+), 28 deletions(-)
diff --git a/chrome/content/zotero/xpcom/citeproc.js b/chrome/content/zotero/xpcom/citeproc.js
@@ -57,33 +57,41 @@ if (!Array.indexOf) {
};
}
var CSL = {
- STATUTE_SUBDIV_GROUPED_REGEX: /((?:^| )(?:p\.|pp\.|r\.|pt\.|ch\.|subch\.|s\.|sec\.|tit\.|art\.|para\.))/g,
- STATUTE_SUBDIV_PLAIN_REGEX: /(?:(?:^| )(?:p\.|pp\.|r\.|pt\.|ch\.|subch\.|s\.|sec\.|tit\.|art\.|para\.))/,
+ STATUTE_SUBDIV_GROUPED_REGEX: /((?:^| )(?:art|ch|Ch|subch|p|pp|para|subpara|pt|r|sec|subsec|Sec|sch|tit)\.)/g,
+ STATUTE_SUBDIV_PLAIN_REGEX: /(?:(?:^| )(?:art|ch|Ch|subch|p|pp|para|subpara|pt|r|sec|subsec|Sec|sch|tit)\.)/,
STATUTE_SUBDIV_STRINGS: {
+ "art.": "article",
+ "ch.": "chapter",
+ "Ch.": "Chapter",
+ "subch.": "subchapter",
"p.": "page",
"pp.": "page",
- "r.": "rule",
+ "para.": "paragraph",
+ "subpara.": "subparagraph",
"pt.": "part",
- "ch.": "chapter",
- "subch.": "subchapter",
- "s.": "section",
- "sec.": "Section",
- "tit.": "title",
- "art.": "article",
- "para.": "paragraph"
+ "r.": "rule",
+ "sec.": "section",
+ "subsec.": "subsection",
+ "Sec.": "Section",
+ "sch.": "schedule",
+ "tit.": "title"
},
STATUTE_SUBDIV_STRINGS_REVERSE: {
- "page": "p.",
- "page": "pp.",
- "rule": "r.",
- "part": "pt.",
+ "article": "art.",
"chapter": "ch.",
+ "Chapter": "Ch.",
"subchapter": "subch.",
- "Section": "sec.",
- "section": "s.",
- "title": "tit.",
- "article": "art.",
- "paragraph": "para."
+ "page": "p.",
+ "page": "pp.",
+ "paragraph": "para.",
+ "subparagraph": "subpara.",
+ "part": "pt.",
+ "rule": "r.",
+ "section": "sec.",
+ "subsection": "subsec.",
+ "Section": "Sec.",
+ "schedule": "sch.",
+ "title": "tit."
},
NestedBraces: [
["(", "["],
@@ -452,22 +460,29 @@ var CSL = {
"\u06E5": "\u0648",
"\u06E6": "\u064A"
},
- LOCATOR_LABELS_REGEXP: new RegExp("^((ch|col|fig|no|l|n|op|p|pp|para|pt|r|tit|s|sec|sv|vrs|vol)\\.)\\s+(.*)"),
+ LOCATOR_LABELS_REGEXP: new RegExp("^((art|ch|Ch|subch|col|fig|l|n|no|op|p|pp|para|subpara|pt|r|sec|subsec|Sec|sv|sch|tit|vrs|vol)\\.)\\s+(.*)"),
LOCATOR_LABELS_MAP: {
+ "art": "article",
"ch": "chapter",
+ "Ch": "Chapter",
+ "subch": "subchapter",
"col": "column",
"fig": "figure",
- "no": "issue",
"l": "line",
"n": "note",
+ "no": "issue",
"op": "opus",
"p": "page",
"pp": "page",
"para": "paragraph",
+ "subpara": "subparagraph",
"pt": "part",
"r": "rule",
- "s": "section",
- "sec": "Section",
+ "sec": "section",
+ "subsec": "subsection",
+ "Sec": "Section",
+ "sv": "sub-verbo",
+ "sch": "schedule",
"tit": "title",
"vrs": "verse",
"vol": "volume"
@@ -1135,7 +1150,7 @@ CSL.Output.Queue.prototype.string = function (state, myblobs, blob) {
if ("number" === typeof blobjr.num) {
ret.push(blobjr);
} else if (blobjr.blobs) {
- b = blobjr.blobs;
+ b = txt_esc(blobjr.blobs);
var blen = b.length;
if (!state.tmp.suppress_decorations) {
for (j = 0, jlen = blobjr.decorations.length; j < jlen; j += 1) {
@@ -2174,7 +2189,7 @@ CSL.DateParser = function () {
};
CSL.Engine = function (sys, style, lang, forceLang) {
var attrs, langspec, localexml, locale;
- this.processor_version = "1.0.323";
+ this.processor_version = "1.0.324";
this.csl_version = "1.0";
this.sys = sys;
this.sys.xml = new CSL.System.Xml.Parsing();
@@ -2621,7 +2636,7 @@ CSL.Engine.prototype.remapSectionVariable = function (inputList) {
item.label = CSL.STATUTE_SUBDIV_STRINGS[splt[0]];
} else {
item.label = "section";
- value = "s. " + value;
+ value = "sec. " + value;
}
}
if (!later_label) {
@@ -2635,7 +2650,7 @@ CSL.Engine.prototype.remapSectionVariable = function (inputList) {
locator = item.locator;
var firstword = item.locator.split(/\s/)[0];
if (item.label === later_label && firstword && firstword.match(/^[0-9]/)) {
- labelstr = " " + CSL.STATUTE_SUBDIV_STRINGS_REVERSE[later_label];
+ labelstr = ", " + CSL.STATUTE_SUBDIV_STRINGS_REVERSE[later_label];
} else if (item.label !== later_label && firstword && firstword.match(/^[0-9]/)) {
labelstr = " " + CSL.STATUTE_SUBDIV_STRINGS_REVERSE[later_label] + " ";
} else if (CSL.STATUTE_SUBDIV_STRINGS[firstword]) {
@@ -2683,6 +2698,42 @@ CSL.Engine.prototype.remapSectionVariable = function (inputList) {
}
}
}
+CSL.Engine.prototype.setNumberLabels = function (Item) {
+ if (Item.number
+ && ["bill", "gazette", "legislation"].indexOf(Item.type) > -1
+ && this.opt.development_extensions.static_statute_locator
+ && !this.tmp.shadow_numbers["number"]) {
+ this.tmp.shadow_numbers["number"] = {};
+ this.tmp.shadow_numbers["number"].values = [];
+ this.tmp.shadow_numbers["number"].plural = 0;
+ this.tmp.shadow_numbers["number"].numeric = false;
+ this.tmp.shadow_numbers["number"].label = false;
+ var value = "" + Item.number;
+ value = value.replace("\\", "", "g");
+ 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(subdiv.replace("sec.", "Sec.").replace("ch.", "Ch."));
+ lst.push(splt[j].replace(/\s*$/, "").replace(/^\s*/, ""));
+ }
+ value = lst.join(" ");
+ } else {
+ value = splt[0];
+ }
+ this.tmp.shadow_numbers["number"].values.push(["Blob", value, false]);
+ this.tmp.shadow_numbers["number"].numeric = false;
+ } else {
+ this.tmp.shadow_numbers["number"].values.push(["Blob", value, false]);
+ this.tmp.shadow_numbers["number"].numeric = true;
+ }
+ }
+}
CSL.substituteOne = function (template) {
return function (state, list) {
if (!list) {
@@ -4241,6 +4292,7 @@ CSL.citeStart = function (Item, item) {
this.tmp.disambig_restore = CSL.cloneAmbigConfig(this.registry.registry[Item.id].disambig);
}
this.tmp.shadow_numbers = {};
+ this.setNumberLabels(Item);
this.tmp.first_name_string = false;
if (this.opt.development_extensions.flip_parentheses_to_braces && item && item.prefix) {
var openBrace = CSL.checkNestedBraceOpen.exec(item.prefix);
@@ -7623,6 +7675,25 @@ CSL.Node.number = {
} else {
if (values.length) {
state.output.openLevel("empty");
+ if (varname === "number"
+ && ["bill","gazette","legislation"].indexOf(Item.type) > -1) {
+ values = values.slice();
+ values[0] = values[0].slice();
+ var firstword = values[0][1].split(/\s/)[0];
+ if (firstword) {
+ var newlst = [];
+ var str = values[0][1];
+ var m = str.match(CSL.STATUTE_SUBDIV_GROUPED_REGEX);
+ if (m) {
+ var lst = str.split(CSL.STATUTE_SUBDIV_PLAIN_REGEX);
+ for (var i = 1, ilen = lst.length; i < ilen; i += 1) {
+ newlst.push(state.getTerm(CSL.STATUTE_SUBDIV_STRINGS[m[i - 1].replace(/^\s+/, "")], this.strings.label_form_override));
+ newlst.push(lst[i].replace(/^\s+/, ""));
+ }
+ values[0][1] = newlst.join(" ");
+ }
+ }
+ }
for (var i = 0, ilen = values.length; i < ilen; i += 1) {
var blob = new CSL[values[i][0]](values[i][1], values[i][2], Item.id);
if (i > 0) {
@@ -7931,6 +8002,8 @@ CSL.Node.text = {
if (this.variables[0]) {
value = state.getVariable(Item, this.variables[0], form);
if (value) {
+ value = "" + value;
+ value = value.replace("\\", "", "g");
state.output.append(value, this);
}
}
@@ -10476,6 +10549,14 @@ CSL.Util.Suffixator.prototype.format = function (N) {
CSL.Engine.prototype.processNumber = function (node, ItemObject, variable, type) {
var num, m, i, ilen, j, jlen;
var debug = false;
+ if (this.tmp.shadow_numbers[variable]) {
+ if (this.tmp.shadow_numbers[variable].numeric) {
+ for (var i = 0, ilen = this.tmp.shadow_numbers[variable].values.length; i < ilen; i += 2) {
+ this.tmp.shadow_numbers[variable].values[i][2] = node;
+ }
+ }
+ return;
+ }
this.tmp.shadow_numbers[variable] = {};
this.tmp.shadow_numbers[variable].values = [];
this.tmp.shadow_numbers[variable].plural = 0;
@@ -10978,7 +11059,6 @@ CSL.Util.FlipFlopper.prototype.getSplitStrings = function (str) {
len = strs.length;
for (pos = 0; pos < len; pos += 2) {
strs[pos] = strs[pos].replace("'", "\u2019", "g");
- strs[pos] = this.txt_esc(strs[pos]);
}
return strs;
};