update to citeproc-js 1.0.52
closes #1709: [patch] citeproc-js 1.0.51 compatibility patch: makeBibliography() return value closes #1712: [patch] citeproc-js 1.0.52 compatibility patch From Frank's notes for 1.0.52: In this release, the following change may require accomodation within the calling application: The processor quashes double spaces in the output. RTF control words can be terminated with a space, but this causes an immediately following space to be lost from the output. To avoid this, the RTF output mode of the processor has been adjusted to terminate RTF control words with {} rather than space. Applications that convert processor output between other formats (such as HTML) may need to be adjusted to accomodate this new behavior. Also in this release: Reverse the RTF-related conservatism in the quashing of duplicate spaces that was introduced in 1.0.51. Add missing parens to suspect test condition (not related to any known bug). From Frank's notes for 1.0.51: The API return value changes slightly with this version: For styles that have no bibliography element, the command makeBibliography() now returns false, rather than a stub bibliography object. Code adjustments in the calling application may be required to accommodate this change in behavior. In other bibliography and citation returns, the processor now provides new arrays, bibliography_errors and citation_errors respectively, with information on bibliography entries or cites that produce no meaningful rendered output. Details are in the processor manual: http://gsl-nagoya-u.net/http/pub/citeproc-doc.html#handling-items-with-no-rendered-form Also in this release: Fix string breakage affecting text-case="title". Fix over-aggressive quashing of spaces, which affected spacing following RTF entities.
This commit is contained in:
parent
be5f7baca3
commit
ecd6309fbc
3 changed files with 143 additions and 69 deletions
|
@ -52,49 +52,52 @@
|
||||||
this._rtfMap = {
|
this._rtfMap = {
|
||||||
"\\":"\\\\",
|
"\\":"\\\\",
|
||||||
"<em>":"\\i ",
|
"<em>":"\\i ",
|
||||||
"</em>":"\\i0 ",
|
"</em>":"\\i0{}",
|
||||||
"<i>":"\\i ",
|
"<i>":"\\i ",
|
||||||
"</i>":"\\i0 ",
|
"</i>":"\\i0{}",
|
||||||
"<strong>":"\\b ",
|
"<strong>":"\\b ",
|
||||||
"</strong>":"\\b0 ",
|
"</strong>":"\\b0{}",
|
||||||
"<b>":"\\b ",
|
"<b>":"\\b ",
|
||||||
"</b>":"\\b0 ",
|
"</b>":"\\b0{}",
|
||||||
"<br />":"\x0B",
|
"<br />":"\x0B",
|
||||||
// there's no way to mimic a tab stop in CSS without
|
// there's no way to mimic a tab stop in CSS without
|
||||||
// tables, which wouldn't work here.
|
// tables, which wouldn't work here.
|
||||||
'<span class="tab"> </span>':"\\tab "
|
'<span class="tab"> </span>':"\\tab{}"
|
||||||
};
|
};
|
||||||
|
|
||||||
this._rtfToHtmlMap = [
|
this._rtfToHtmlMap = [
|
||||||
[/\\uc0\{?\\u([0-9]+)\}? ?/g, function(wholeStr, aCode) { return String.fromCharCode(aCode) }],
|
[/\\uc0\{?\\u([0-9]+)\}?(?:{}| )?/g, function(wholeStr, aCode) { return String.fromCharCode(aCode) }],
|
||||||
["\\t ", '<span class="tab"> </span>'],
|
[/\\tab(?:\{\}| )/g, '<span class="tab"> </span>'],
|
||||||
[/(?:\\par |\\\r?\n)/g, "</p><p>"],
|
[/(?:\\par{}|\\\r?\n)/g, "</p><p>"],
|
||||||
[/\\super (.*?)\\nosupersub /g, "<sup>$1</sup>"],
|
[/\\super (.*?)\\nosupersub{}/g, "<sup>$1</sup>"],
|
||||||
[/\\sub (.*?)\\nosupersub /g, "<sub>$1</sub>"]
|
[/\\sub (.*?)\\nosupersub{}/g, "<sub>$1</sub>"],
|
||||||
|
// for backwards compatibility with Zotero < 2.1
|
||||||
|
["\\i0 ", "</em>"],
|
||||||
|
["\\b0 ", "</strong>"]
|
||||||
];
|
];
|
||||||
|
|
||||||
this._htmlToRtfMap = [
|
this._htmlToRtfMap = [
|
||||||
[/"(\w)/, "“$1"],
|
[/"(\w)/, "“$1"],
|
||||||
[/([\w,.?!])"/, "$1”"],
|
[/([\w,.?!])"/, "$1”"],
|
||||||
["<p>", ""],
|
["<p>", ""],
|
||||||
["</p>", "\\par "],
|
//[/<\/p>(?!\s*$)/g, "\\par{}"],
|
||||||
[/<\/?div[^>]*>/g, ""],
|
[/<\/?div[^>]*>/g, ""],
|
||||||
["<sup>", "\\super "],
|
["<sup>", "\\super "],
|
||||||
["</sup>", "\\nosupersub "],
|
["</sup>", "\\nosupersub{}"],
|
||||||
["<sub>", "\\sub "],
|
["<sub>", "\\sub "],
|
||||||
["</sub>", "\\nosupersub "]
|
["</sub>", "\\nosupersub{}"]
|
||||||
];
|
];
|
||||||
|
|
||||||
this._rtfRexMap = [
|
this._rtfRexMap = [
|
||||||
["<span style=\"font-variant:small-caps;\">",
|
["<span style=\"font-variant:small-caps;\">",
|
||||||
/small-caps/,
|
/small-caps/,
|
||||||
"\\scaps ",
|
"\\scaps ",
|
||||||
"\\scaps0 "
|
"\\scaps0{}"
|
||||||
],
|
],
|
||||||
["<span style=\"text-decoration:underline;\">",
|
["<span style=\"text-decoration:underline;\">",
|
||||||
/underline/,
|
/underline/,
|
||||||
"\\ul ",
|
"\\ul ",
|
||||||
"\\ul0 "
|
"\\ul0{}"
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -182,6 +185,11 @@
|
||||||
var output = this._editor.getContent();
|
var output = this._editor.getContent();
|
||||||
|
|
||||||
if(this._format == "RTF") {
|
if(this._format == "RTF") {
|
||||||
|
// strip divs
|
||||||
|
if(output.substr(0, 5) == "<div>" && output.substr(-6) == "</div>") {
|
||||||
|
output = output.substr(5, output.length-6);
|
||||||
|
}
|
||||||
|
|
||||||
// do appropriate replacement operations
|
// do appropriate replacement operations
|
||||||
for(var needle in this._rtfMap) {
|
for(var needle in this._rtfMap) {
|
||||||
output = output.replace(needle, this._rtfMap[needle], "g");
|
output = output.replace(needle, this._rtfMap[needle], "g");
|
||||||
|
@ -209,17 +217,17 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
output = l.join("");
|
output = l.join("");
|
||||||
};
|
}
|
||||||
|
|
||||||
for each(var entry in this._htmlToRtfMap) {
|
for each(var entry in this._htmlToRtfMap) {
|
||||||
output = output.replace(entry[0], entry[1], "g");
|
output = output.replace(entry[0], entry[1], "g");
|
||||||
}
|
}
|
||||||
output = Zotero.Utilities.prototype.trim(output)
|
|
||||||
output = Zotero.Utilities.prototype.unescapeHTML(
|
output = Zotero.Utilities.prototype.unescapeHTML(
|
||||||
output.replace(" ", " ", "g"))
|
output.replace(" ", " ", "g"))
|
||||||
.replace(highcharRe,
|
.replace(highcharRe,
|
||||||
function(aChar) { return "\\uc0\\u"+aChar.charCodeAt(0).toString()+" " });
|
function(aChar) { return "\\uc0\\u"+aChar.charCodeAt(0).toString()+"{}" });
|
||||||
|
output = Zotero.Utilities.prototype.trim(output);
|
||||||
if(output.substr(-4) == "\\par") output = output.substr(0, output.length-4);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
|
|
|
@ -61,6 +61,7 @@ var CSL = {
|
||||||
error: function (str) {
|
error: function (str) {
|
||||||
print(str);
|
print(str);
|
||||||
},
|
},
|
||||||
|
ERROR_NO_RENDERED_FORM: 1,
|
||||||
PREVIEW: "Just for laughs.",
|
PREVIEW: "Just for laughs.",
|
||||||
ASSUME_ALL_ITEMS_REGISTERED: 2,
|
ASSUME_ALL_ITEMS_REGISTERED: 2,
|
||||||
START: 0,
|
START: 0,
|
||||||
|
@ -614,7 +615,8 @@ CSL.Output.Queue.prototype.append = function (str, tokname) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
CSL.Output.Queue.prototype.string = function (state, myblobs, blob) {
|
CSL.Output.Queue.prototype.string = function (state, myblobs, blob) {
|
||||||
var blobs, ret, blob_delimiter, i, params, blobjr, last_str, last_char, b, use_suffix, qres, addtoret, span_split, j, res, blobs_start, blobs_end, key, pos, len, ppos, llen, ttype, ltype, terminal, leading, delimiters, use_prefix;
|
var blobs, ret, blob_delimiter, i, params, blobjr, last_str, last_char, b, use_suffix, qres, addtoret, span_split, j, res, blobs_start, blobs_end, key, pos, len, ppos, llen, ttype, ltype, terminal, leading, delimiters, use_prefix, txt_esc;
|
||||||
|
txt_esc = CSL.Output.Formats[this.state.opt.mode].text_escape;
|
||||||
blobs = myblobs.slice();
|
blobs = myblobs.slice();
|
||||||
ret = [];
|
ret = [];
|
||||||
if (blobs.length === 0) {
|
if (blobs.length === 0) {
|
||||||
|
@ -659,7 +661,7 @@ CSL.Output.Queue.prototype.string = function (state, myblobs, blob) {
|
||||||
b = qres[0];
|
b = qres[0];
|
||||||
use_suffix = qres[1];
|
use_suffix = qres[1];
|
||||||
if (b && b.length) {
|
if (b && b.length) {
|
||||||
b = blobjr.strings.prefix + b + use_suffix;
|
b = txt_esc(blobjr.strings.prefix) + b + txt_esc(use_suffix);
|
||||||
ret.push(b);
|
ret.push(b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -671,7 +673,7 @@ CSL.Output.Queue.prototype.string = function (state, myblobs, blob) {
|
||||||
if ("string" === ttype && "string" === ltype) {
|
if ("string" === ttype && "string" === ltype) {
|
||||||
terminal = ret.slice(-1)[0].slice(-1);
|
terminal = ret.slice(-1)[0].slice(-1);
|
||||||
leading = addtoret.slice(-1)[0].slice(0, 1);
|
leading = addtoret.slice(-1)[0].slice(0, 1);
|
||||||
if ((CSL.TERMINAL_PUNCTUATION.slice(0, -1).indexOf(terminal) > -1 && terminal === leading) || CSL.TERMINAL_PUNCTUATION.slice(0, -1).indexOf(terminal) > -1 && CSL.TERMINAL_PUNCTUATION.slice(0, -1).indexOf(leading) > -1) {
|
if ((CSL.TERMINAL_PUNCTUATION.slice(0, -1).indexOf(terminal) > -1 && terminal === leading) || (CSL.TERMINAL_PUNCTUATION.slice(0, -1).indexOf(terminal) > -1 && CSL.TERMINAL_PUNCTUATION.slice(0, -1).indexOf(leading) > -1)) {
|
||||||
ret[(ret.length - 1)] = ret[(ret.length - 1)].slice(0, -1);
|
ret[(ret.length - 1)] = ret[(ret.length - 1)].slice(0, -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -713,7 +715,7 @@ CSL.Output.Queue.prototype.string = function (state, myblobs, blob) {
|
||||||
if (CSL.TERMINAL_PUNCTUATION.indexOf(use_prefix.slice(-1)) > -1 && use_prefix.slice(-1) === b.slice(0, 1)) {
|
if (CSL.TERMINAL_PUNCTUATION.indexOf(use_prefix.slice(-1)) > -1 && use_prefix.slice(-1) === b.slice(0, 1)) {
|
||||||
use_prefix = use_prefix.slice(0, -1);
|
use_prefix = use_prefix.slice(0, -1);
|
||||||
}
|
}
|
||||||
b = use_prefix + b + use_suffix;
|
b = txt_esc(use_prefix) + b + txt_esc(use_suffix);
|
||||||
}
|
}
|
||||||
blobs_start = b;
|
blobs_start = b;
|
||||||
if (!state.tmp.suppress_decorations) {
|
if (!state.tmp.suppress_decorations) {
|
||||||
|
@ -760,7 +762,8 @@ CSL.Output.Queue.prototype.clearlevel = function () {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
CSL.Output.Queue.prototype.renderBlobs = function (blobs, delim) {
|
CSL.Output.Queue.prototype.renderBlobs = function (blobs, delim) {
|
||||||
var state, ret, ret_last_char, use_delim, i, blob, pos, len, ppos, llen, pppos, lllen, res, str, params;
|
var state, ret, ret_last_char, use_delim, i, blob, pos, len, ppos, llen, pppos, lllen, res, str, params, txt_esc;
|
||||||
|
txt_esc = CSL.Output.Formats[this.state.opt.mode].text_escape;
|
||||||
if (!delim) {
|
if (!delim) {
|
||||||
delim = "";
|
delim = "";
|
||||||
}
|
}
|
||||||
|
@ -799,7 +802,7 @@ CSL.Output.Queue.prototype.renderBlobs = function (blobs, delim) {
|
||||||
blob = blob.slice(1);
|
blob = blob.slice(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ret += use_delim;
|
ret += txt_esc(use_delim);
|
||||||
ret += blob;
|
ret += blob;
|
||||||
} else if (blob.status !== CSL.SUPPRESS) {
|
} else if (blob.status !== CSL.SUPPRESS) {
|
||||||
str = blob.formatter.format(blob.num);
|
str = blob.formatter.format(blob.num);
|
||||||
|
@ -1500,7 +1503,7 @@ CSL.dateParser = function (txt) {
|
||||||
};
|
};
|
||||||
CSL.Engine = function (sys, style, lang, xmlmode) {
|
CSL.Engine = function (sys, style, lang, xmlmode) {
|
||||||
var attrs, langspec, localexml, locale;
|
var attrs, langspec, localexml, locale;
|
||||||
this.processor_version = "1.0.49";
|
this.processor_version = "1.0.52";
|
||||||
this.csl_version = "1.0";
|
this.csl_version = "1.0";
|
||||||
this.sys = sys;
|
this.sys = sys;
|
||||||
this.sys.xml = new CSL.System.Xml.Parsing();
|
this.sys.xml = new CSL.System.Xml.Parsing();
|
||||||
|
@ -1675,6 +1678,9 @@ CSL.Engine.prototype.getTerm = function (term, form, plural) {
|
||||||
if (typeof ret === "undefined") {
|
if (typeof ret === "undefined") {
|
||||||
ret = CSL.Engine.getField(CSL.STRICT, CSL.locale[this.opt.lang].terms, term, form, plural);
|
ret = CSL.Engine.getField(CSL.STRICT, CSL.locale[this.opt.lang].terms, term, form, plural);
|
||||||
}
|
}
|
||||||
|
if (ret) {
|
||||||
|
this.tmp.cite_renders_content = true;
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
};
|
};
|
||||||
CSL.Engine.prototype.getDate = function (form) {
|
CSL.Engine.prototype.getDate = function (form) {
|
||||||
|
@ -2147,8 +2153,11 @@ CSL.Engine.prototype.updateUncitedItems = function (idList, nosort) {
|
||||||
return this.registry.getSortedIds();
|
return this.registry.getSortedIds();
|
||||||
};
|
};
|
||||||
CSL.Engine.prototype.makeBibliography = function (bibsection) {
|
CSL.Engine.prototype.makeBibliography = function (bibsection) {
|
||||||
var debug, ret, params, maxoffset, item, len, pos, tok, tokk, tokkk, entry_ids, entry_strings;
|
var debug, ret, params, maxoffset, item, len, pos, tok, tokk, tokkk, entry_ids, entry_strings, bibliography_errors;
|
||||||
debug = false;
|
debug = false;
|
||||||
|
if (!this.bibliography.tokens.length) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if ("string" === typeof bibsection ) {
|
if ("string" === typeof bibsection ) {
|
||||||
this.opt.citation_number_slug = bibsection;
|
this.opt.citation_number_slug = bibsection;
|
||||||
bibsection = false;
|
bibsection = false;
|
||||||
|
@ -2161,7 +2170,8 @@ CSL.Engine.prototype.makeBibliography = function (bibsection) {
|
||||||
"entryspacing": this.bibliography.opt["entry-spacing"],
|
"entryspacing": this.bibliography.opt["entry-spacing"],
|
||||||
"linespacing": this.bibliography.opt["line-spacing"],
|
"linespacing": this.bibliography.opt["line-spacing"],
|
||||||
"second-field-align": false,
|
"second-field-align": false,
|
||||||
"entry_ids": entry_ids
|
"entry_ids": entry_ids,
|
||||||
|
"bibliography_errors": this.tmp.bibliography_errors.slice()
|
||||||
};
|
};
|
||||||
if (this.bibliography.opt["second-field-align"]) {
|
if (this.bibliography.opt["second-field-align"]) {
|
||||||
params["second-field-align"] = this.bibliography.opt["second-field-align"];
|
params["second-field-align"] = this.bibliography.opt["second-field-align"];
|
||||||
|
@ -2183,10 +2193,13 @@ CSL.Engine.prototype.makeBibliography = function (bibsection) {
|
||||||
return [params, entry_strings];
|
return [params, entry_strings];
|
||||||
};
|
};
|
||||||
CSL.getBibliographyEntries = function (bibsection) {
|
CSL.getBibliographyEntries = function (bibsection) {
|
||||||
var ret, input, include, anymatch, allmatch, bib_entry, res, len, pos, item, llen, ppos, spec, lllen, pppos, bib_layout, topblobs, all_item_ids, entry_item_ids, debug, collapse_parallel, i, siblings, skips, sortedItems, eyetem, chr;
|
var ret, input, include, anymatch, allmatch, bib_entry, res, len, pos, item, llen, ppos, spec, lllen, pppos, bib_layout, topblobs, all_item_ids, entry_item_ids, debug, collapse_parallel, i, siblings, skips, sortedItems, eyetem, chr, entry_item_data;
|
||||||
ret = [];
|
ret = [];
|
||||||
|
entry_item_data = [];
|
||||||
this.tmp.area = "bibliography";
|
this.tmp.area = "bibliography";
|
||||||
this.tmp.last_rendered_name = false;
|
this.tmp.last_rendered_name = false;
|
||||||
|
this.tmp.bibliography_errors = [];
|
||||||
|
this.tmp.bibliography_pos = 0;
|
||||||
input = this.retrieveItems(this.registry.getSortedIds());
|
input = this.retrieveItems(this.registry.getSortedIds());
|
||||||
this.tmp.disambig_override = true;
|
this.tmp.disambig_override = true;
|
||||||
function eval_string(a, b) {
|
function eval_string(a, b) {
|
||||||
|
@ -2303,6 +2316,8 @@ CSL.getBibliographyEntries = function (bibsection) {
|
||||||
} else if (!this.registry.registry[item.id].siblings) {
|
} else if (!this.registry.registry[item.id].siblings) {
|
||||||
entry_item_ids.push(CSL.getCite.call(this, item));
|
entry_item_ids.push(CSL.getCite.call(this, item));
|
||||||
}
|
}
|
||||||
|
entry_item_data.push("");
|
||||||
|
this.tmp.bibliography_pos += 1;
|
||||||
all_item_ids.push(entry_item_ids);
|
all_item_ids.push(entry_item_ids);
|
||||||
this.output.endTag("bib_entry");
|
this.output.endTag("bib_entry");
|
||||||
if (this.output.queue[0].blobs.length && this.output.queue[0].blobs[0].blobs.length) {
|
if (this.output.queue[0].blobs.length && this.output.queue[0].blobs[0].blobs.length) {
|
||||||
|
@ -2355,6 +2370,7 @@ CSL.Engine.prototype.appendCitationCluster = function (citation) {
|
||||||
CSL.Engine.prototype.processCitationCluster = function (citation, citationsPre, citationsPost, flag) {
|
CSL.Engine.prototype.processCitationCluster = function (citation, citationsPre, citationsPost, flag) {
|
||||||
var sortedItems, new_citation, pos, len, item, citationByIndex, c, Item, newitem, k, textCitations, noteCitations, update_items, citations, first_ref, last_ref, ipos, ilen, cpos, onecitation, oldvalue, ibidme, suprame, useme, items, i, key, prev_locator, curr_locator, param, ret, obj, ppos, llen, lllen, pppos, ppppos, llllen, cids, note_distance, return_data, lostItemId, lostItemList, lostItemData, otherLostPkeys, disambig, oldItemIds;
|
var sortedItems, new_citation, pos, len, item, citationByIndex, c, Item, newitem, k, textCitations, noteCitations, update_items, citations, first_ref, last_ref, ipos, ilen, cpos, onecitation, oldvalue, ibidme, suprame, useme, items, i, key, prev_locator, curr_locator, param, ret, obj, ppos, llen, lllen, pppos, ppppos, llllen, cids, note_distance, return_data, lostItemId, lostItemList, lostItemData, otherLostPkeys, disambig, oldItemIds;
|
||||||
this.debug = false;
|
this.debug = false;
|
||||||
|
this.tmp.citation_errors = [];
|
||||||
return_data = {"bibchange": false};
|
return_data = {"bibchange": false};
|
||||||
this.registry.return_data = return_data;
|
this.registry.return_data = return_data;
|
||||||
this.setCitationId(citation);
|
this.setCitationId(citation);
|
||||||
|
@ -2604,15 +2620,22 @@ CSL.Engine.prototype.processCitationCluster = function (citation, citationsPre,
|
||||||
if (key === citation.citationID) {
|
if (key === citation.citationID) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
obj = [];
|
|
||||||
var mycitation = this.registry.citationreg.citationById[key];
|
var mycitation = this.registry.citationreg.citationById[key];
|
||||||
obj.push(mycitation.properties.index);
|
this.tmp.citation_pos = mycitation.properties.index;
|
||||||
obj.push(this.process_CitationCluster.call(this, mycitation.sortedItems));
|
this.tmp.citation_note_index = mycitation.properties.noteIndex;
|
||||||
ret.push(obj);
|
this.tmp.citation_id = mycitation.citationID;
|
||||||
|
obj = [];
|
||||||
|
obj.push(mycitation.properties.index);
|
||||||
|
obj.push(this.process_CitationCluster.call(this, mycitation.sortedItems));
|
||||||
|
ret.push(obj);
|
||||||
|
this.tmp.citation_pos += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.tmp.taintedItemIDs = false;
|
this.tmp.taintedItemIDs = false;
|
||||||
this.tmp.taintedCitationIDs = false;
|
this.tmp.taintedCitationIDs = false;
|
||||||
|
this.tmp.citation_pos = citation.properties.index;
|
||||||
|
this.tmp.citation_note_index = citation.properties.noteIndex;
|
||||||
|
this.tmp.citation_id = citation.citationID;
|
||||||
obj = [];
|
obj = [];
|
||||||
obj.push(citationsPre.length);
|
obj.push(citationsPre.length);
|
||||||
obj.push(this.process_CitationCluster.call(this, sortedItems));
|
obj.push(this.process_CitationCluster.call(this, sortedItems));
|
||||||
|
@ -2627,6 +2650,7 @@ CSL.Engine.prototype.processCitationCluster = function (citation, citationsPre,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
return_data.citation_errors = this.tmp.citation_errors.slice();
|
||||||
return [return_data, ret];
|
return [return_data, ret];
|
||||||
};
|
};
|
||||||
CSL.Engine.prototype.process_CitationCluster = function (sortedItems) {
|
CSL.Engine.prototype.process_CitationCluster = function (sortedItems) {
|
||||||
|
@ -2652,6 +2676,7 @@ CSL.Engine.prototype.makeCitationCluster = function (rawList) {
|
||||||
}
|
}
|
||||||
inputList.sort(this.citation.srt.compareCompositeKeys);
|
inputList.sort(this.citation.srt.compareCompositeKeys);
|
||||||
}
|
}
|
||||||
|
this.tmp.citation_errors = [];
|
||||||
this.parallel.StartCitation(inputList);
|
this.parallel.StartCitation(inputList);
|
||||||
str = CSL.getCitationCluster.call(this, inputList);
|
str = CSL.getCitationCluster.call(this, inputList);
|
||||||
return str;
|
return str;
|
||||||
|
@ -2682,7 +2707,8 @@ CSL.getSpliceDelimiter = function (last_collapsed) {
|
||||||
return this.tmp.splice_delimiter;
|
return this.tmp.splice_delimiter;
|
||||||
};
|
};
|
||||||
CSL.getCitationCluster = function (inputList, citationID) {
|
CSL.getCitationCluster = function (inputList, citationID) {
|
||||||
var delimiter, result, objects, myparams, len, pos, item, last_collapsed, params, empties, composite, compie, myblobs, Item, llen, ppos, obj, preceding_item;
|
var delimiter, result, objects, myparams, len, pos, item, last_collapsed, params, empties, composite, compie, myblobs, Item, llen, ppos, obj, preceding_item, txt_esc, error_object;
|
||||||
|
txt_esc = CSL.Output.Formats[this.opt.mode].text_escape;
|
||||||
this.tmp.area = "citation";
|
this.tmp.area = "citation";
|
||||||
delimiter = "";
|
delimiter = "";
|
||||||
result = "";
|
result = "";
|
||||||
|
@ -2708,6 +2734,17 @@ CSL.getCitationCluster = function (inputList, citationID) {
|
||||||
this.tmp.term_predecessor = false;
|
this.tmp.term_predecessor = false;
|
||||||
CSL.getCite.call(this, Item, item);
|
CSL.getCite.call(this, Item, item);
|
||||||
}
|
}
|
||||||
|
if (!this.tmp.cite_renders_content) {
|
||||||
|
error_object = {
|
||||||
|
citationID: this.tmp.citation_id,
|
||||||
|
index: this.tmp.citation_pos,
|
||||||
|
noteIndex: this.tmp.citation_note_index,
|
||||||
|
itemID: Item.id,
|
||||||
|
citationItems_pos: pos,
|
||||||
|
error_code: CSL.ERROR_NO_RENDERED_FORM
|
||||||
|
};
|
||||||
|
this.tmp.citation_errors.push(error_object);
|
||||||
|
}
|
||||||
if (pos === (inputList.length - 1)) {
|
if (pos === (inputList.length - 1)) {
|
||||||
this.parallel.ComposeSet();
|
this.parallel.ComposeSet();
|
||||||
}
|
}
|
||||||
|
@ -2754,7 +2791,7 @@ CSL.getCitationCluster = function (inputList, citationID) {
|
||||||
}
|
}
|
||||||
if (objects.length && "string" === typeof composite[0]) {
|
if (objects.length && "string" === typeof composite[0]) {
|
||||||
composite.reverse();
|
composite.reverse();
|
||||||
objects.push(this.tmp.splice_delimiter + composite.pop());
|
objects.push(txt_esc(this.tmp.splice_delimiter) + composite.pop());
|
||||||
} else {
|
} else {
|
||||||
composite.reverse();
|
composite.reverse();
|
||||||
compie = composite.pop();
|
compie = composite.pop();
|
||||||
|
@ -2767,7 +2804,7 @@ CSL.getCitationCluster = function (inputList, citationID) {
|
||||||
for (ppos = 0; ppos < llen; ppos += 1) {
|
for (ppos = 0; ppos < llen; ppos += 1) {
|
||||||
obj = composite[ppos];
|
obj = composite[ppos];
|
||||||
if ("string" === typeof obj) {
|
if ("string" === typeof obj) {
|
||||||
objects.push(this.tmp.splice_delimiter + obj);
|
objects.push(txt_esc(this.tmp.splice_delimiter) + obj);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
compie = composite.pop();
|
compie = composite.pop();
|
||||||
|
@ -2784,7 +2821,7 @@ CSL.getCitationCluster = function (inputList, citationID) {
|
||||||
if (result.slice(-1) === this.citation.opt.layout_suffix.slice(0)) {
|
if (result.slice(-1) === this.citation.opt.layout_suffix.slice(0)) {
|
||||||
result = result.slice(0, -1);
|
result = result.slice(0, -1);
|
||||||
}
|
}
|
||||||
result = this.citation.opt.layout_prefix + result + this.citation.opt.layout_suffix;
|
result = txt_esc(this.citation.opt.layout_prefix) + result + txt_esc(this.citation.opt.layout_suffix);
|
||||||
if (!this.tmp.suppress_decorations) {
|
if (!this.tmp.suppress_decorations) {
|
||||||
len = this.citation.opt.layout_decorations.length;
|
len = this.citation.opt.layout_decorations.length;
|
||||||
for (pos = 0; pos < len; pos += 1) {
|
for (pos = 0; pos < len; pos += 1) {
|
||||||
|
@ -2796,7 +2833,8 @@ CSL.getCitationCluster = function (inputList, citationID) {
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
CSL.getCite = function (Item, item, prevItemID) {
|
CSL.getCite = function (Item, item, prevItemID) {
|
||||||
var next;
|
var next, error_object;
|
||||||
|
this.tmp.cite_renders_content = false;
|
||||||
this.parallel.StartCite(Item, item, prevItemID);
|
this.parallel.StartCite(Item, item, prevItemID);
|
||||||
CSL.citeStart.call(this, Item);
|
CSL.citeStart.call(this, Item);
|
||||||
next = 0;
|
next = 0;
|
||||||
|
@ -2805,6 +2843,16 @@ CSL.getCite = function (Item, item, prevItemID) {
|
||||||
}
|
}
|
||||||
CSL.citeEnd.call(this, Item);
|
CSL.citeEnd.call(this, Item);
|
||||||
this.parallel.CloseCite(this);
|
this.parallel.CloseCite(this);
|
||||||
|
if (!this.tmp.cite_renders_content && !this.tmp.just_looking) {
|
||||||
|
if (this.tmp.area === "bibliography") {
|
||||||
|
error_object = {
|
||||||
|
index: this.tmp.bibliography_pos,
|
||||||
|
itemID: Item.id,
|
||||||
|
error_code: CSL.ERROR_NO_RENDERED_FORM
|
||||||
|
};
|
||||||
|
this.tmp.bibliography_errors.push(error_object);
|
||||||
|
}
|
||||||
|
}
|
||||||
return Item.id;
|
return Item.id;
|
||||||
};
|
};
|
||||||
CSL.citeStart = function (Item) {
|
CSL.citeStart = function (Item) {
|
||||||
|
@ -4803,6 +4851,9 @@ CSL.Attributes["@variable"] = function (state, arg) {
|
||||||
}
|
}
|
||||||
flag = state.tmp.term_sibling.value();
|
flag = state.tmp.term_sibling.value();
|
||||||
if (output) {
|
if (output) {
|
||||||
|
if (variable !== "citation-number" || !state.tmp.area === "bibliography") {
|
||||||
|
state.tmp.cite_renders_content = true;
|
||||||
|
}
|
||||||
flag[2] = true;
|
flag[2] = true;
|
||||||
state.tmp.term_sibling.replace(flag);
|
state.tmp.term_sibling.replace(flag);
|
||||||
state.tmp.can_substitute.replace(false, CSL.LITERAL);
|
state.tmp.can_substitute.replace(false, CSL.LITERAL);
|
||||||
|
@ -7163,8 +7214,11 @@ CSL.Output.Formatters.title = function (state, string) {
|
||||||
}
|
}
|
||||||
notfirst = pos !== 0;
|
notfirst = pos !== 0;
|
||||||
notlast = pos !== lastWordIndex;
|
notlast = pos !== lastWordIndex;
|
||||||
firstword = previousWordIndex === -1;
|
if (words[previousWordIndex]) {
|
||||||
aftercolon = words[previousWordIndex][(words[previousWordIndex].length - 1)] !== ":";
|
aftercolon = words[previousWordIndex].slice(-1) !== ":";
|
||||||
|
} else {
|
||||||
|
aftercolon = false;
|
||||||
|
}
|
||||||
if (skip && notfirst && notlast && (firstword || aftercolon)) {
|
if (skip && notfirst && notlast && (firstword || aftercolon)) {
|
||||||
words[pos] = lowerCaseVariant;
|
words[pos] = lowerCaseVariant;
|
||||||
} else {
|
} else {
|
||||||
|
@ -7202,6 +7256,12 @@ CSL.Output.Formatters.undoppelString = function (str) {
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
};
|
};
|
||||||
|
CSL.Output.Formatters.serializeItemAsRdf = function (Item) {
|
||||||
|
return "";
|
||||||
|
};
|
||||||
|
CSL.Output.Formatters.serializeItemAsRdfA = function (Item) {
|
||||||
|
return "";
|
||||||
|
};
|
||||||
CSL.Output.Formats = function () {};
|
CSL.Output.Formats = function () {};
|
||||||
CSL.Output.Formats.prototype.html = {
|
CSL.Output.Formats.prototype.html = {
|
||||||
"text_escape": function (text) {
|
"text_escape": function (text) {
|
||||||
|
@ -7312,24 +7372,24 @@ CSL.Output.Formats.prototype.text = {
|
||||||
CSL.Output.Formats.prototype.rtf = {
|
CSL.Output.Formats.prototype.rtf = {
|
||||||
"text_escape": function (text) {
|
"text_escape": function (text) {
|
||||||
return text.replace("\\", "\\\\", "g").replace(/[\x7F-\uFFFF]/g,
|
return text.replace("\\", "\\\\", "g").replace(/[\x7F-\uFFFF]/g,
|
||||||
function(aChar) { return "\\uc0\\u"+aChar.charCodeAt(0).toString()+" " })
|
function(aChar) { return "\\uc0\\u"+aChar.charCodeAt(0).toString()+"{}" })
|
||||||
.replace("\t", "\\tab ", "g");
|
.replace("\t", "\\tab{}", "g");
|
||||||
},
|
},
|
||||||
"@passthrough/true": CSL.Output.Formatters.passthrough,
|
"@passthrough/true": CSL.Output.Formatters.passthrough,
|
||||||
"@strip-periods/true": CSL.Output.Formatters.strip_periods,
|
"@strip-periods/true": CSL.Output.Formatters.strip_periods,
|
||||||
"@font-style/italic":"\\i %%STRING%%\\i0 ",
|
"@font-style/italic":"\\i %%STRING%%\\i0{}",
|
||||||
"@font-style/normal":false,
|
"@font-style/normal":false,
|
||||||
"@font-style/oblique":"\\i %%STRING%%\\i0 ",
|
"@font-style/oblique":"\\i %%STRING%%\\i0{}",
|
||||||
"@font-variant/small-caps":"\\scaps %%STRING%%\\scaps0 ",
|
"@font-variant/small-caps":"\\scaps %%STRING%%\\scaps0{}",
|
||||||
"@font-variant/normal":false,
|
"@font-variant/normal":false,
|
||||||
"@font-weight/bold":"\\b %%STRING%%\\b0 ",
|
"@font-weight/bold":"\\b %%STRING%%\\b0{}",
|
||||||
"@font-weight/normal":false,
|
"@font-weight/normal":false,
|
||||||
"@font-weight/light":false,
|
"@font-weight/light":false,
|
||||||
"@text-decoration/none":false,
|
"@text-decoration/none":false,
|
||||||
"@text-decoration/underline":"\\ul %%STRING%%\\ul0 ",
|
"@text-decoration/underline":"\\ul %%STRING%%\\ul0{}",
|
||||||
"@vertical-align/baseline":false,
|
"@vertical-align/baseline":false,
|
||||||
"@vertical-align/sup":"\\super %%STRING%%\\nosupersub ",
|
"@vertical-align/sup":"\\super %%STRING%%\\nosupersub{}",
|
||||||
"@vertical-align/sub":"\\sub %%STRING%%\\nosupersub ",
|
"@vertical-align/sub":"\\sub %%STRING%%\\nosupersub{}",
|
||||||
"@strip-periods/true": CSL.Output.Formatters.strip_periods,
|
"@strip-periods/true": CSL.Output.Formatters.strip_periods,
|
||||||
"@strip-periods/false": function (state, string) {
|
"@strip-periods/false": function (state, string) {
|
||||||
return string;
|
return string;
|
||||||
|
@ -8173,4 +8233,4 @@ CSL.Disambiguation.prototype.decrementNames = function () {
|
||||||
CSL.Registry.CitationReg = function (state) {
|
CSL.Registry.CitationReg = function (state) {
|
||||||
this.citationById = {};
|
this.citationById = {};
|
||||||
this.citationByIndex = [];
|
this.citationByIndex = [];
|
||||||
};
|
};
|
|
@ -698,19 +698,23 @@ Zotero.Integration.Document.prototype._updateDocument = function(forceCitations,
|
||||||
|
|
||||||
// get bibliography and format as RTF
|
// get bibliography and format as RTF
|
||||||
var bib = this._session.getBibliography();
|
var bib = this._session.getBibliography();
|
||||||
var bibliographyText = bib[0].bibstart+bib[1].join("\\\r\n")+"\\\r\n"+bib[0].bibend;
|
|
||||||
|
|
||||||
// if bibliography style not set, set it
|
var bibliographyText = "";
|
||||||
if(!this._session.data.bibliographyStyleHasBeenSet) {
|
if(bib) {
|
||||||
var bibStyle = Zotero.Cite.getBibliographyFormatParameters(bib);
|
bibliographyText = bib[0].bibstart+bib[1].join("\\\r\n")+"\\\r\n"+bib[0].bibend;
|
||||||
|
|
||||||
// set bibliography style
|
// if bibliography style not set, set it
|
||||||
this._doc.setBibliographyStyle(bibStyle.firstLineIndent, bibStyle.indent,
|
if(!this._session.data.bibliographyStyleHasBeenSet) {
|
||||||
bibStyle.lineSpacing, bibStyle.entrySpacing, bibStyle.tabStops, bibStyle.tabStops.length);
|
var bibStyle = Zotero.Cite.getBibliographyFormatParameters(bib);
|
||||||
|
|
||||||
// set bibliographyStyleHasBeenSet parameter to prevent further changes
|
// set bibliography style
|
||||||
this._session.data.bibliographyStyleHasBeenSet = true;
|
this._doc.setBibliographyStyle(bibStyle.firstLineIndent, bibStyle.indent,
|
||||||
this._doc.setDocumentData(this._session.data.serializeXML());
|
bibStyle.lineSpacing, bibStyle.entrySpacing, bibStyle.tabStops, bibStyle.tabStops.length);
|
||||||
|
|
||||||
|
// set bibliographyStyleHasBeenSet parameter to prevent further changes
|
||||||
|
this._session.data.bibliographyStyleHasBeenSet = true;
|
||||||
|
this._doc.setDocumentData(this._session.data.serializeXML());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// set bibliography text
|
// set bibliography text
|
||||||
|
@ -1333,13 +1337,15 @@ Zotero.Integration.Session.prototype.getBibliography = function() {
|
||||||
// generate bibliography
|
// generate bibliography
|
||||||
var bib = this.style.makeBibliography();
|
var bib = this.style.makeBibliography();
|
||||||
|
|
||||||
// omit items
|
if(bib) {
|
||||||
Zotero.Cite.removeFromBibliography(bib, this.omittedItems);
|
// omit items
|
||||||
|
Zotero.Cite.removeFromBibliography(bib, this.omittedItems);
|
||||||
// replace items with their custom counterpars
|
|
||||||
for(var i in bib[0].entry_ids) {
|
// replace items with their custom counterpars
|
||||||
if(this.customBibliographyText[bib[0].entry_ids[i]]) {
|
for(var i in bib[0].entry_ids) {
|
||||||
bib[1][i] = this.customBibliographyText[bib[0].entry_ids[i]];
|
if(this.customBibliographyText[bib[0].entry_ids[i]]) {
|
||||||
|
bib[1][i] = this.customBibliographyText[bib[0].entry_ids[i]];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue