diff --git a/chrome/content/zotero/xpcom/citeproc.js b/chrome/content/zotero/xpcom/citeproc.js index 9b10fb3e4f..a59d2df6bc 100644 --- a/chrome/content/zotero/xpcom/citeproc.js +++ b/chrome/content/zotero/xpcom/citeproc.js @@ -1506,7 +1506,7 @@ CSL.dateParser = function (txt) { }; CSL.Engine = function (sys, style, lang, xmlmode) { var attrs, langspec, localexml, locale; - this.processor_version = "1.0.53"; + this.processor_version = "1.0.57"; this.csl_version = "1.0"; this.sys = sys; this.sys.xml = new CSL.System.Xml.Parsing(); @@ -1674,8 +1674,34 @@ CSL.Engine.prototype.setOutputFormat = function (mode) { this.output[mode].tmp = {}; } }; -CSL.Engine.prototype.setLocale = function (locale) { -}; +CSL.Engine.prototype.setLangTagsForCslSort = function (tags) { + var i, ilen; + this.opt['locale-sort'] = []; + for (i = 0, ilen = tags.length; i < ilen; i += 1) { + this.opt['locale-sort'].push(tags[i]); + } +} +CSL.Engine.prototype.setLangTagsForCslNameTransliteration = function (tags) { + var i, ilen; + this.opt['locale-name'] = []; + for (i = 0, ilen = tags.length; i < ilen; i += 1) { + this.opt['locale-name'].push(tags[i]); + } +} +CSL.Engine.prototype.setLangTagsForCslTitleTransliteration = function (tags) { + var i, ilen; + this.opt['locale-pri'] = []; + for (i = 0, ilen = tags.length; i < ilen; i += 1) { + this.opt['locale-pri'].push(tags[i]); + } +} +CSL.Engine.prototype.setLangTagsForCslTranslation = function (tags) { + var i, ilen; + this.opt['locale-sec'] = []; + for (i = 0, ilen = tags.length; i < ilen; i += 1) { + this.opt['locale-sec'].push(tags[i]); + } +} CSL.Engine.prototype.getTerm = function (term, form, plural) { var ret = CSL.Engine.getField(CSL.LOOSE, this.locale[this.opt.lang].terms, term, form, plural); if (typeof ret === "undefined") { @@ -3235,7 +3261,7 @@ CSL.Node["date-part"] = { CSL.Node["else-if"] = { build: function (state, target) { var func, tryposition; - if (this.tokentype === CSL.START) { + if (this.tokentype === CSL.START || this.tokentype === CSL.SINGLETON) { if ("number" === typeof this.strings.position) { tryposition = this.strings.position; func = function (state, Item, item) { @@ -3268,7 +3294,7 @@ CSL.Node["else-if"] = { this.evaluator = state.fun.match.any; } } - if (this.tokentype === CSL.END) { + if (this.tokentype === CSL.END || this.tokentype === CSL.SINGLETON) { func = function (state, Item) { var next = this[state.tmp.jump.value()]; return next; @@ -3372,7 +3398,7 @@ CSL.Node.group = { CSL.Node["if"] = { build: function (state, target) { var tryposition, func; - if (this.tokentype === CSL.START) { + if (this.tokentype === CSL.START || this.tokentype === CSL.SINGLETON) { if ("number" === typeof this.strings.position) { tryposition = this.strings.position; func = function (state, Item, item) { @@ -3405,7 +3431,7 @@ CSL.Node["if"] = { this.evaluator = state.fun.match.any; } } - if (this.tokentype === CSL.END) { + if (this.tokentype === CSL.END || this.tokentype === CSL.SINGLETON) { func = function (state, Item) { var next = this[state.tmp.jump.value()]; return next; @@ -4116,12 +4142,33 @@ CSL.Node.names = { state.output.addToken("non-dropping-particle", false, state.output.getToken("family")); state.output.addToken("suffix", false, state.output.getToken("family")); state.output.openLevel("term-join"); - if (label && state.output.getToken("label").strings.label_position === CSL.BEFORE) { - state.output.append(label, "label"); - } len = namesets.length; for (namesetIndex = 0; namesetIndex < len; namesetIndex += 1) { nameset = namesets[namesetIndex]; + label = false; + if (state.output.getToken("label").strings.label_position) { + if (common_term) { + termname = common_term; + } else { + termname = nameset.variable; + } + if (!state.output.getToken("label").strings.form) { + form = "long"; + } else { + form = state.output.getToken("label").strings.form; + } + if ("number" === typeof state.output.getToken("label").strings.plural) { + plural = state.output.getToken("label").strings.plural; + } else if (nameset.names.length > 1) { + plural = 1; + } else { + plural = 0; + } + label = state.getTerm(termname, form, plural); + } + if (label && state.output.getToken("label").strings.label_position === CSL.BEFORE) { + state.output.append(label, "label"); + } if (!state.tmp.suppress_decorations && (state[state.tmp.area].opt.collapse === "year" || state[state.tmp.area].opt.collapse === "year-suffix" || state[state.tmp.area].opt.collapse === "year-suffix-ranged")) { if (state.tmp.last_names_used.length === state.tmp.names_used.length) { lastones = state.tmp.last_names_used[state.tmp.nameset_counter]; @@ -4262,27 +4309,6 @@ CSL.Node.names = { state.tmp.disambig_settings.givens[state.tmp.nameset_counter][ppos] = param; } } - label = false; - if (state.output.getToken("label").strings.label_position) { - if (common_term) { - termname = common_term; - } else { - termname = nameset.variable; - } - if (!state.output.getToken("label").strings.form) { - form = "long"; - } else { - form = state.output.getToken("label").strings.form; - } - if ("number" === typeof state.output.getToken("label").strings.plural) { - plural = state.output.getToken("label").strings.plural; - } else if (nameset.names.length > 1) { - plural = 1; - } else { - plural = 0; - } - label = state.getTerm(termname, form, plural); - } if (namesetIndex > 0 && nameset.variable !== last_variable) { state.output.closeLevel("term-join"); } @@ -4337,7 +4363,7 @@ CSL.Node.names = { state.output.closeLevel("trailing-names"); } if (namesets.length === namesetIndex + 1 || namesets[namesetIndex + 1].variable !== namesets[namesetIndex].variable) { - if (label && state.tmp.name_label_position !== CSL.BEFORE) { + if (label && state.output.getToken("label").strings.label_position !== CSL.BEFORE) { state.output.append(label, "label"); } } @@ -6844,15 +6870,15 @@ CSL.Util.FlipFlopper = function (state) { this.state = state; this.blob = false; tagdefs = [ - ["", "", "italics", "@font-style", ["italic", "normal"], true], - ["", "", "bold", "@font-weight", ["bold", "normal"], true], - ["", "", "superscript", "@vertical-align", ["sup", "sup"], true], - ["", "", "subscript", "@vertical-align", ["sub", "sub"], true], - ["", "", "smallcaps", "@font-variant", ["small-caps", "small-caps"], true], - ["", "", "passthrough", "@passthrough", ["true", "true"], true], - ["", "", "passthrough", "@passthrough", ["true", "true"], true], - ['"', '"', "quotes", "@quotes", ["true", "inner"], "'"], - [" '", "'", "quotes", "@quotes", ["inner", "true"], '"'] + ["", "", "italics", "@font-style", ["italic", "normal","normal"], true], + ["", "", "bold", "@font-weight", ["bold", "normal","normal"], true], + ["", "", "superscript", "@vertical-align", ["sup", "sup","baseline"], true], + ["", "", "subscript", "@vertical-align", ["sub", "sub","baseline"], true], + ["", "", "smallcaps", "@font-variant", ["small-caps", "small-caps","normal"], true], + ["", "", "passthrough", "@passthrough", ["true", "true","true"], true], + ["", "", "passthrough", "@passthrough", ["true", "true","true"], true], + ['"', '"', "quotes", "@quotes", ["true", "inner","true"], "'"], + [" '", "'", "quotes", "@quotes", ["inner", "true","true"], '"'] ]; for (pos = 0; pos < 2; pos += 1) { p = ["-", "-inner-"][pos]; @@ -6913,7 +6939,7 @@ CSL.Util.FlipFlopper = function (state) { flipTags[tagdefs[pos][1]] = tagdefs[pos][5]; openToClose[tagdefs[pos][0]] = tagdefs[pos][1]; openToDecorations[tagdefs[pos][0]] = [tagdefs[pos][3], tagdefs[pos][4]]; - okReverse[tagdefs[pos][3]] = [tagdefs[pos][3], [tagdefs[pos][4][1], tagdefs[pos][1]]]; + okReverse[tagdefs[pos][3]] = [tagdefs[pos][3], [tagdefs[pos][4][2], tagdefs[pos][1]]]; } return [closeTags, flipTags, openToClose, openToDecorations, okReverse]; }; @@ -7281,7 +7307,7 @@ CSL.Output.Formats.prototype.html = { "@font-style/normal": "%%STRING%%", "@font-variant/small-caps": "%%STRING%%", "@passthrough/true": CSL.Output.Formatters.passthrough, - "@font-variant/normal": false, + "@font-variant/normal": "%%STRING%%", "@font-weight/bold": "%%STRING%%", "@font-weight/normal": "%%STRING%%", "@font-weight/light": false, @@ -7575,7 +7601,7 @@ CSL.Registry.prototype.dorefreshes = function () { regtoken.ambig = undefined; Item = this.state.retrieveItem(key); if ("undefined" === typeof akey) { - CSL.getAmbiguousCite.call(this.state, Item); + akey = CSL.getAmbiguousCite.call(this.state, Item); this.state.tmp.taintedItemIDs[key] = true; } this.registry[key] = regtoken; @@ -8240,4 +8266,4 @@ CSL.Disambiguation.prototype.decrementNames = function () { CSL.Registry.CitationReg = function (state) { this.citationById = {}; this.citationByIndex = []; -}; +}; \ No newline at end of file