diff --git a/CHANGES.txt b/CHANGES.txt index 08c0f4592..decdf3d1a 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,6 +1,13 @@ Summary of changes to citeproc-js since version 1.0.0 release. +========================== +Changes in version 1.1.192 +========================== + +- Handle Chicago-style page-n-note pinpoint ranges a little + better. + ========================== Changes in version 1.1.191 ========================== diff --git a/citeproc.js b/citeproc.js index fe87da486..741504f17 100644 --- a/citeproc.js +++ b/citeproc.js @@ -24,7 +24,7 @@ */ var CSL = { - PROCESSOR_VERSION: "1.1.191", + PROCESSOR_VERSION: "1.1.192", CONDITION_LEVEL_TOP: 1, CONDITION_LEVEL_BOTTOM: 2, PLAIN_HYPHEN_REGEX: /(?:[^\\]-|\u2013)/, @@ -13911,9 +13911,9 @@ CSL.Engine.prototype.processNumber = function (node, ItemObject, variable, type) info.plural = 0; info.labelVisibility = false; } - var m = val.match(/^([a-zA-Z0]*)([0-9]+(?:[a-zA-Z]*|[-,a-zA-Z]+))$/); + var m = val.match(/^([0-9]*[a-zA-Z]+0*)?([0-9]+(?:[a-zA-Z]*|[-,a-zA-Z]+))$/); if (m) { - info.particle = m[1]; + info.particle = m[1] ? m[1] : ""; info.value = m[2]; } else { info.particle = ""; @@ -14210,7 +14210,7 @@ CSL.Engine.prototype.processNumber = function (node, ItemObject, variable, type) } else { str = values[i-1].value + stripHyphenBackslash(values[i-1].joiningSuffix) + values[i].value; } - var m = str.match(/^([a-zA-Z]?0*)([0-9]+)(\s*[^0-9]+\s*)([-,a-zA-Z]?0*)([0-9]+)$/); + var m = str.match(/^((?:[0-9]*[a-zA-Z]+0*))?([0-9]+)(\s*[^0-9]+\s*)([-,a-zA-Z]?0*)([0-9]+)$/); if (m) { var rangeDelimiter = m[3]; rangeDelimiter = fixupRangeDelimiter(variable, val, rangeDelimiter, values[i].numeric); @@ -14384,7 +14384,7 @@ CSL.Util.outputNumericField = function(state, varname, itemID) { } } if (num.collapsible) { - if (num.value.match(/^[0-9]+$/)) { + if (num.value.match(/^[1-9][0-9]*$/)) { var blob = new CSL.NumericBlob(num.particle, parseInt(num.value, 10), numStyling, itemID); } else { var blob = new CSL.NumericBlob(num.particle, num.value, numStyling, itemID); @@ -14415,7 +14415,7 @@ CSL.Util.PageRangeMangler = {}; CSL.Util.PageRangeMangler.getFunction = function (state, rangeType) { var rangerex, pos, len, stringify, listify, expand, minimize, minimize_internal, chicago, lst, m, b, e, ret, begin, end, ret_func, ppos, llen; var range_delimiter = state.getTerm(rangeType + "-range-delimiter"); - rangerex = /([a-zA-Z]*)([0-9]+)\s*(?:\u2013|-)\s*([a-zA-Z]*)([0-9]+)/; + rangerex = /([0-9]*[a-zA-Z]+0*)?([0-9]+)\s*(?:\u2013|-)\s*([0-9]*[a-zA-Z]+0*)?([0-9]+)/; stringify = function (lst) { len = lst.length; for (pos = 1; pos < len; pos += 2) { @@ -14433,8 +14433,8 @@ CSL.Util.PageRangeMangler.getFunction = function (state, rangeType) { var this_range_delimiter = range_delimiter === "-" ? "" : range_delimiter; var delimRex = new RegExp("([^\\\\])[-" + this_range_delimiter + "\\u2013]", "g"); str = str.replace(delimRex, "$1 - ").replace(/\s+-\s+/g, " - "); - var rexm = new RegExp("([a-zA-Z]*[0-9]+" + hyphens + "[a-zA-Z]*[0-9]+)", "g"); - var rexlst = new RegExp("[a-zA-Z]*[0-9]+" + hyphens + "[a-zA-Z]*[0-9]+"); + var rexm = new RegExp("((?:[0-9]*[a-zA-Z]+0*)?[0-9]+" + hyphens + "(?:[0-9]*[a-zA-Z]+0*)?[0-9]+)", "g"); + var rexlst = new RegExp("(?:[0-9]*[a-zA-Z]+0*)?[0-9]+" + hyphens + "(?:[0-9]*[a-zA-Z]+0*)?[0-9]+"); m = str.match(rexm); lst = str.split(rexlst); if (lst.length === 0) { @@ -14460,7 +14460,7 @@ CSL.Util.PageRangeMangler.getFunction = function (state, rangeType) { m[4] = m[2].slice(0, (m[2].length - m[4].length)) + m[4]; } if (parseInt(m[2], 10) < parseInt(m[4], 10)) { - m[3] = range_delimiter + m[1]; + m[3] = range_delimiter + (m[1] ? m[1] : ""); lst[pos] = m.slice(1); } } diff --git a/citeproc_commonjs.js b/citeproc_commonjs.js index 6b81b6878..931211072 100644 --- a/citeproc_commonjs.js +++ b/citeproc_commonjs.js @@ -24,7 +24,7 @@ */ var CSL = { - PROCESSOR_VERSION: "1.1.191", + PROCESSOR_VERSION: "1.1.192", CONDITION_LEVEL_TOP: 1, CONDITION_LEVEL_BOTTOM: 2, PLAIN_HYPHEN_REGEX: /(?:[^\\]-|\u2013)/, @@ -13990,9 +13990,9 @@ CSL.Engine.prototype.processNumber = function (node, ItemObject, variable, type) info.plural = 0; info.labelVisibility = false; } - var m = val.match(/^([a-zA-Z0]*)([0-9]+(?:[a-zA-Z]*|[-,a-zA-Z]+))$/); + var m = val.match(/^([0-9]*[a-zA-Z]+0*)?([0-9]+(?:[a-zA-Z]*|[-,a-zA-Z]+))$/); if (m) { - info.particle = m[1]; + info.particle = m[1] ? m[1] : ""; info.value = m[2]; } else { info.particle = ""; @@ -14289,7 +14289,7 @@ CSL.Engine.prototype.processNumber = function (node, ItemObject, variable, type) } else { str = values[i-1].value + stripHyphenBackslash(values[i-1].joiningSuffix) + values[i].value; } - var m = str.match(/^([a-zA-Z]?0*)([0-9]+)(\s*[^0-9]+\s*)([-,a-zA-Z]?0*)([0-9]+)$/); + var m = str.match(/^((?:[0-9]*[a-zA-Z]+0*))?([0-9]+)(\s*[^0-9]+\s*)([-,a-zA-Z]?0*)([0-9]+)$/); if (m) { var rangeDelimiter = m[3]; rangeDelimiter = fixupRangeDelimiter(variable, val, rangeDelimiter, values[i].numeric); @@ -14463,7 +14463,7 @@ CSL.Util.outputNumericField = function(state, varname, itemID) { } } if (num.collapsible) { - if (num.value.match(/^[0-9]+$/)) { + if (num.value.match(/^[1-9][0-9]*$/)) { var blob = new CSL.NumericBlob(num.particle, parseInt(num.value, 10), numStyling, itemID); } else { var blob = new CSL.NumericBlob(num.particle, num.value, numStyling, itemID); @@ -14495,7 +14495,7 @@ CSL.Util.PageRangeMangler = {}; CSL.Util.PageRangeMangler.getFunction = function (state, rangeType) { var rangerex, pos, len, stringify, listify, expand, minimize, minimize_internal, chicago, lst, m, b, e, ret, begin, end, ret_func, ppos, llen; var range_delimiter = state.getTerm(rangeType + "-range-delimiter"); - rangerex = /([a-zA-Z]*)([0-9]+)\s*(?:\u2013|-)\s*([a-zA-Z]*)([0-9]+)/; + rangerex = /([0-9]*[a-zA-Z]+0*)?([0-9]+)\s*(?:\u2013|-)\s*([0-9]*[a-zA-Z]+0*)?([0-9]+)/; stringify = function (lst) { len = lst.length; for (pos = 1; pos < len; pos += 2) { @@ -14513,8 +14513,8 @@ CSL.Util.PageRangeMangler.getFunction = function (state, rangeType) { var this_range_delimiter = range_delimiter === "-" ? "" : range_delimiter; var delimRex = new RegExp("([^\\\\])[-" + this_range_delimiter + "\\u2013]", "g"); str = str.replace(delimRex, "$1 - ").replace(/\s+-\s+/g, " - "); - var rexm = new RegExp("([a-zA-Z]*[0-9]+" + hyphens + "[a-zA-Z]*[0-9]+)", "g"); - var rexlst = new RegExp("[a-zA-Z]*[0-9]+" + hyphens + "[a-zA-Z]*[0-9]+"); + var rexm = new RegExp("((?:[0-9]*[a-zA-Z]+0*)?[0-9]+" + hyphens + "(?:[0-9]*[a-zA-Z]+0*)?[0-9]+)", "g"); + var rexlst = new RegExp("(?:[0-9]*[a-zA-Z]+0*)?[0-9]+" + hyphens + "(?:[0-9]*[a-zA-Z]+0*)?[0-9]+"); m = str.match(rexm); lst = str.split(rexlst); if (lst.length === 0) { @@ -14540,7 +14540,7 @@ CSL.Util.PageRangeMangler.getFunction = function (state, rangeType) { m[4] = m[2].slice(0, (m[2].length - m[4].length)) + m[4]; } if (parseInt(m[2], 10) < parseInt(m[4], 10)) { - m[3] = range_delimiter + m[1]; + m[3] = range_delimiter + (m[1] ? m[1] : ""); lst[pos] = m.slice(1); } } diff --git a/citeproc_with_e4x.js b/citeproc_with_e4x.js index 5e22513b1..acd145fcb 100644 --- a/citeproc_with_e4x.js +++ b/citeproc_with_e4x.js @@ -24,7 +24,7 @@ */ var CSL = { - PROCESSOR_VERSION: "1.1.191", + PROCESSOR_VERSION: "1.1.192", CONDITION_LEVEL_TOP: 1, CONDITION_LEVEL_BOTTOM: 2, PLAIN_HYPHEN_REGEX: /(?:[^\\]-|\u2013)/, @@ -13912,9 +13912,9 @@ CSL.Engine.prototype.processNumber = function (node, ItemObject, variable, type) info.plural = 0; info.labelVisibility = false; } - var m = val.match(/^([a-zA-Z0]*)([0-9]+(?:[a-zA-Z]*|[-,a-zA-Z]+))$/); + var m = val.match(/^([0-9]*[a-zA-Z]+0*)?([0-9]+(?:[a-zA-Z]*|[-,a-zA-Z]+))$/); if (m) { - info.particle = m[1]; + info.particle = m[1] ? m[1] : ""; info.value = m[2]; } else { info.particle = ""; @@ -14211,7 +14211,7 @@ CSL.Engine.prototype.processNumber = function (node, ItemObject, variable, type) } else { str = values[i-1].value + stripHyphenBackslash(values[i-1].joiningSuffix) + values[i].value; } - var m = str.match(/^([a-zA-Z]?0*)([0-9]+)(\s*[^0-9]+\s*)([-,a-zA-Z]?0*)([0-9]+)$/); + var m = str.match(/^((?:[0-9]*[a-zA-Z]+0*))?([0-9]+)(\s*[^0-9]+\s*)([-,a-zA-Z]?0*)([0-9]+)$/); if (m) { var rangeDelimiter = m[3]; rangeDelimiter = fixupRangeDelimiter(variable, val, rangeDelimiter, values[i].numeric); @@ -14385,7 +14385,7 @@ CSL.Util.outputNumericField = function(state, varname, itemID) { } } if (num.collapsible) { - if (num.value.match(/^[0-9]+$/)) { + if (num.value.match(/^[1-9][0-9]*$/)) { var blob = new CSL.NumericBlob(num.particle, parseInt(num.value, 10), numStyling, itemID); } else { var blob = new CSL.NumericBlob(num.particle, num.value, numStyling, itemID); @@ -14416,7 +14416,7 @@ CSL.Util.PageRangeMangler = {}; CSL.Util.PageRangeMangler.getFunction = function (state, rangeType) { var rangerex, pos, len, stringify, listify, expand, minimize, minimize_internal, chicago, lst, m, b, e, ret, begin, end, ret_func, ppos, llen; var range_delimiter = state.getTerm(rangeType + "-range-delimiter"); - rangerex = /([a-zA-Z]*)([0-9]+)\s*(?:\u2013|-)\s*([a-zA-Z]*)([0-9]+)/; + rangerex = /([0-9]*[a-zA-Z]+0*)?([0-9]+)\s*(?:\u2013|-)\s*([0-9]*[a-zA-Z]+0*)?([0-9]+)/; stringify = function (lst) { len = lst.length; for (pos = 1; pos < len; pos += 2) { @@ -14434,8 +14434,8 @@ CSL.Util.PageRangeMangler.getFunction = function (state, rangeType) { var this_range_delimiter = range_delimiter === "-" ? "" : range_delimiter; var delimRex = new RegExp("([^\\\\])[-" + this_range_delimiter + "\\u2013]", "g"); str = str.replace(delimRex, "$1 - ").replace(/\s+-\s+/g, " - "); - var rexm = new RegExp("([a-zA-Z]*[0-9]+" + hyphens + "[a-zA-Z]*[0-9]+)", "g"); - var rexlst = new RegExp("[a-zA-Z]*[0-9]+" + hyphens + "[a-zA-Z]*[0-9]+"); + var rexm = new RegExp("((?:[0-9]*[a-zA-Z]+0*)?[0-9]+" + hyphens + "(?:[0-9]*[a-zA-Z]+0*)?[0-9]+)", "g"); + var rexlst = new RegExp("(?:[0-9]*[a-zA-Z]+0*)?[0-9]+" + hyphens + "(?:[0-9]*[a-zA-Z]+0*)?[0-9]+"); m = str.match(rexm); lst = str.split(rexlst); if (lst.length === 0) { @@ -14461,7 +14461,7 @@ CSL.Util.PageRangeMangler.getFunction = function (state, rangeType) { m[4] = m[2].slice(0, (m[2].length - m[4].length)) + m[4]; } if (parseInt(m[2], 10) < parseInt(m[4], 10)) { - m[3] = range_delimiter + m[1]; + m[3] = range_delimiter + (m[1] ? m[1] : ""); lst[pos] = m.slice(1); } } diff --git a/package.json b/package.json index a0834f2f2..21575b764 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "citeproc", - "version": "2.1.191", - "description": "The citeproc-js citation formatting module, in CommonJS format. This version is based on citeproc-js 1.1.191.", + "version": "2.1.192", + "description": "The citeproc-js citation formatting module, in CommonJS format. This version is based on citeproc-js 1.1.192.", "main": "citeproc_commonjs.js", "repository": { "type" : "git", diff --git a/src/load.js b/src/load.js index 3ad0ac610..d01e132af 100644 --- a/src/load.js +++ b/src/load.js @@ -35,7 +35,7 @@ var CSL = { - PROCESSOR_VERSION: "1.1.191", + PROCESSOR_VERSION: "1.1.192", CONDITION_LEVEL_TOP: 1,