diff --git a/chrome/content/zotero/xpcom/citeproc.js b/chrome/content/zotero/xpcom/citeproc.js index 3e817f4cbe..c21957b6f5 100644 --- a/chrome/content/zotero/xpcom/citeproc.js +++ b/chrome/content/zotero/xpcom/citeproc.js @@ -57,7 +57,7 @@ if (!Array.indexOf) { }; } var CSL = { - PROCESSOR_VERSION: "1.0.351", + PROCESSOR_VERSION: "1.0.353", 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: { @@ -9590,7 +9590,7 @@ CSL.Transform = function (state) { secondary_tok.strings.prefix = " "; } for (var i = secondary_tok.decorations.length - 1; i > -1; i += -1) { - if (secondary_tok.decorations[i][0] === '@quotes') { + if (['@quotes/true','@font-style/italic','@font-style/oblique','@font-weight/bold'].indexOf(secondary_tok.decorations[i].join('/')) > -1) { secondary_tok.decorations = secondary_tok.decorations.slice(0, i).concat(secondary_tok.decorations.slice(i + 1)) } } @@ -9604,7 +9604,7 @@ CSL.Transform = function (state) { tertiary_tok.strings.prefix = " "; } for (var i = tertiary_tok.decorations.length - 1; i > -1; i += -1) { - if (tertiary_tok.decorations[i][0] === '@quotes') { + if (['@quotes/true','@font-style/italic','@font-style/oblique','@font-weight/bold'].indexOf(tertiary_tok.decorations[i].join('/')) > -1) { tertiary_tok.decorations = tertiary_tok.decorations.slice(0, i).concat(tertiary_tok.decorations.slice(i + 1)) } } @@ -10531,66 +10531,83 @@ CSL.Util.Dates.year.numeric = function (state, num) { } return (pre + num); }; -CSL.Util.Dates.month = {}; -CSL.Util.Dates.month.numeric = function (state, num) { - if (num) { - num = parseInt(num, 10); - if (num > 12) { - num = ""; - } - } - var ret = "" + num; - return ret; -}; -CSL.Util.Dates.month["numeric-leading-zeros"] = function (state, num) { +CSL.Util.Dates.normalizeMonth = function (num, useSeason) { + var ret; if (!num) { num = 0; } - num = parseInt(num, 10); - if (num > 12) { + num = "" + num; + if (!num.match(/^[0-9]+$/)) { num = 0; } - num = "" + num; - while (num.length < 2) { - num = "0" + num; + num = parseInt(num, 10); + if (useSeason) { + var res = {stub: "month-", num: num}; + if (res.num < 1 || res.num > 20) { + res.num = 0; + } else if (res.num > 16) { + res.stub = "season-"; + res.num = res.num - 16; + } else if (res.num > 12) { + res.stub = "season-"; + res.num = res.num - 12; + } + ret = res; + } else { + if (num < 1 || num > 12) { + num = 0; + } + ret = num; } - return num.toString(); + return ret; +} +CSL.Util.Dates.month = {}; +CSL.Util.Dates.month.numeric = function (state, num) { + var num = CSL.Util.Dates.normalizeMonth(num); + if (!num) { + num = ""; + } + return num; +}; +CSL.Util.Dates.month["numeric-leading-zeros"] = function (state, num) { + var num = CSL.Util.Dates.normalizeMonth(num); + if (!num) { + num = ""; + } else { + num = "" + num; + while (num.length < 2) { + num = "0" + num; + } + } + return num; }; CSL.Util.Dates.month["long"] = function (state, num) { - var stub = "month-"; - num = parseInt(num, 10); - if (num > 12) { - stub = "season-"; - if (num > 16) { - num = num - 16; - } else { - num = num - 12; + var res = CSL.Util.Dates.normalizeMonth(num, true); + var num = res.num; + if (!num) { + num = ""; + } else { + num = "" + num; + while (num.length < 2) { + num = "0" + num; } + num = state.getTerm(res.stub + num, "long", 0); } - num = "" + num; - while (num.length < 2) { - num = "0" + num; - } - num = stub + num; - return state.getTerm(num, "long", 0); + return num; }; CSL.Util.Dates.month["short"] = function (state, num) { - var stub = "month-"; - num = parseInt(num, 10); - if (num > 12) { - stub = "season-"; - if (num > 16) { - num = num - 16; - } else { - num = num - 12; + var res = CSL.Util.Dates.normalizeMonth(num, true); + var num = res.num; + if (!num) { + num = ""; + } else { + num = "" + num; + while (num.length < 2) { + num = "0" + num; } + num = state.getTerm(res.stub + num, "short", 0); } - num = "" + num; - while (num.length < 2) { - num = "0" + num; - } - num = "month-" + num; - return state.getTerm(num, "short", 0); + return num; }; CSL.Util.Dates.day = {}; CSL.Util.Dates.day.numeric = function (state, num) {