diff --git a/chrome/content/zotero/xpcom/citeproc.js b/chrome/content/zotero/xpcom/citeproc.js index 202b5ef53..ad318b1f6 100644 --- a/chrome/content/zotero/xpcom/citeproc.js +++ b/chrome/content/zotero/xpcom/citeproc.js @@ -80,7 +80,7 @@ if (!Array.indexOf) { }; } var CSL = { - PROCESSOR_VERSION: "1.0.539", + PROCESSOR_VERSION: "1.0.543", CONDITION_LEVEL_TOP: 1, CONDITION_LEVEL_BOTTOM: 2, PLAIN_HYPHEN_REGEX: /(?:[^\\]-|\u2013)/, @@ -237,7 +237,7 @@ var CSL = { MULTI_FIELDS: ["event", "publisher", "publisher-place", "event-place", "title", "container-title", "collection-title", "authority","edition","genre","title-short","medium","jurisdiction","archive","archive-place"], CITE_FIELDS: ["first-reference-note-number", "locator", "locator-revision"], MINIMAL_NAME_FIELDS: ["literal", "family"], - SWAPPING_PUNCTUATION: [".", "!", "?", ":",","], + SWAPPING_PUNCTUATION: [".", "!", "?", ":", ","], TERMINAL_PUNCTUATION: [":", ".", ";", "!", "?", " "], NONE: 0, NUMERIC: 1, @@ -2595,6 +2595,9 @@ CSL.Engine.prototype.setAbbreviations = function (arg) { this.sys.setAbbreviations(arg); } }; +CSL.Engine.prototype.setSuppressTrailingPunctuation = function (arg) { + this.citation.opt.suppressTrailingPunctuation = !!arg; +}; CSL.Output = {}; CSL.Output.Queue = function (state) { this.levelname = ["top"]; @@ -3209,19 +3212,30 @@ CSL.Output.Queue.adjust = function (punctInQuote) { return false; } function matchLastChar(blob, chr) { - if (blob.strings.suffix.slice(0, 1) === chr) { - return true; - } else if ("string" === typeof blob.blobs) { + if (!PUNCT[chr]) { + return false; + } + if ("string" === typeof blob.blobs) { if (blob.blobs.slice(-1) === chr) { return true; } else { return false; } + } else { + var child = blob.blobs[blob.blobs.length-1]; + if (child) { + var childChar = child.strings.suffix.slice(-1); + if (!childChar) { + return matchLastChar(child,chr); + } else if (child.strings.suffix.slice(-1) == chr) { + return true; + } else { + return false; + } + } else { + return false; + } } - for (var i=0,ilen=blob.blobs.length;i b[0]) { @@ -4329,9 +4358,14 @@ CSL.getCitationCluster = function (inputList, citationID) { this.tmp.last_years_used = []; this.tmp.backref_index = []; this.tmp.cite_locales = []; + var suppressTrailingPunctuation = false; + if (this.opt.xclass === "note" && this.citation.opt.suppressTrailingPunctuation) { + suppressTrailingPunctuation = true; + } if (citationID) { - this.registry.citationreg.citationById[citationID].properties.backref_index = false; - this.registry.citationreg.citationById[citationID].properties.backref_citation = false; + if (this.registry.citationreg.citationById[citationID].properties["suppress-trailing-punctuation"]) { + suppressTrailingPunctuation = true; + } } if (this.opt.xclass === "note") { var parasets = []; @@ -4460,7 +4494,9 @@ CSL.getCitationCluster = function (inputList, citationID) { && this.sys.wrapCitationEntry && !this.tmp.just_looking && this.tmp.area === "citation")) { - this.output.queue[this.output.queue.length - 1].strings.suffix = use_layout_suffix; + if (!suppressTrailingPunctuation) { + this.output.queue[this.output.queue.length - 1].strings.suffix = use_layout_suffix; + } this.output.queue[0].strings.prefix = this.citation.opt.layout_prefix; } } @@ -4933,7 +4969,7 @@ CSL.getBibliographyEntries = function (bibsection) { for (var j=0,jlen=this.output.queue.length;j]+>/g, "").replace(/["'\u201d\u2019]/g,"").replace(/\s+$/, "").replace(/^[.\s]+/, ""); + 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_prefix.slice(-1))) { + } 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_prefix.slice(-1)) > -1 - && test_prefix.slice(0, 1) != test_prefix.slice(0, 1).toLowerCase()) { + if (CSL.TERMINAL_PUNCTUATION.slice(0,-1).indexOf(test_char) > -1) { state.tmp.term_predecessor = false; ignorePredecessor = true; } @@ -7214,6 +7252,10 @@ CSL.NameOutput.prototype.setCommonTerm = function () { } freeters_offset += 1; } + if (this.persons[v].length !== this.persons[vv].length) { + this.common_term = false; + return; + } for (var j = 0, jlen = this.persons[v].length; j < jlen; j += 1) { if (this.etal_spec[v].persons[j] !== this.etal_spec[vv].persons[j] || !this._compareNamesets(this.persons[v][j], this.persons[vv][j])) { @@ -12654,7 +12696,7 @@ CSL.Util.FlipFlopper.prototype.init = function (str, blob) { }; CSL.Util.FlipFlopper.prototype._normalizeString = function (str) { var i, ilen; - str = str.replace(/\s+'\s+/," ’ ","g"); + str = str.replace(/\s+'\s+/g," ’ "); if (str.indexOf(this.quotechars[0]) > -1) { for (i = 0, ilen = 2; i < ilen; i += 1) { if (this.quotechars[i + 2]) {