diff -r -u chrome.orig/content/zotero/xpcom/csl.js chrome/content/zotero/xpcom/csl.js
|
old
|
new
|
|
| 20 | 20 | ***** END LICENSE BLOCK ***** |
| 21 | 21 | */ |
| 22 | 22 | |
| | 23 | /* |
| | 24 | * PATCHES: fbennett |
| | 25 | * |
| | 26 | * This version of cls.js reflects the following modification: |
| | 27 | * |
| | 28 | * (2) Make the is-numeric test available with note/extra and locator |
| | 29 | * fields: |
| | 30 | * The Extra field can be used to overcome limitations in a |
| | 31 | * style, for use cases the are not covered by the current schema |
| | 32 | * (such as the handling of an original and a modern publication |
| | 33 | * date for a resource). The locator field is likely to come |
| | 34 | * under pressure for special pinpoint forms of a citation in |
| | 35 | * footnote styles. |
| | 36 | * |
| | 37 | * The changes labeled fbennett (2) below improve the utility of |
| | 38 | * these fields by extending the is-numeric expression to cover |
| | 39 | * them. |
| | 40 | */ |
| | 41 | |
| | 42 | |
| 23 | 43 | /* |
| 24 | 44 | * CSL: a class for creating bibliographies from CSL files |
| 25 | 45 | * this is abstracted as a separate class for the benefit of anyone who doesn't |
| … |
… |
|
| 803 | 823 | for(var j=0; j<variables.length; j++) { |
| 804 | 824 | if(ignore[0][variables[j]]) continue; |
| 805 | 825 | |
| 806 | | var text = item.getNumericVariable(variables[j], form); |
| | 826 | /* |
| | 827 | * fbennett (2): pass citationItem through to provide locator field data to function |
| | 828 | */ |
| | 829 | var text = item.getNumericVariable(variables[j], citationItem, form); |
| | 830 | /* |
| | 831 | * fbennett: end |
| | 832 | */ |
| 807 | 833 | if(text) { |
| 808 | 834 | newString.append(text); |
| 809 | 835 | success = true; |
| … |
… |
|
| 1061 | 1087 | if (exists) exists = !!exists.length; |
| 1062 | 1088 | } |
| 1063 | 1089 | } else if (attribute == "is-numeric") { |
| 1064 | | exists = item.getNumericVariable(variables[j]); |
| | 1090 | /* |
| | 1091 | * fbennett (2): pass through citationItem to provide locator field data to function |
| | 1092 | */ |
| | 1093 | exists = item.getNumericVariable(variables[j], citationItem); |
| | 1094 | /* |
| | 1095 | * fbennett: end |
| | 1096 | */ |
| 1065 | 1097 | } else if (attribute == "is-date") { // XXX - this needs improving |
| 1066 | 1098 | if (Zotero.CSL._dateVariables[variables[j]]) { |
| 1067 | 1099 | exists = !!item.getDate(variables[j]); |
| … |
… |
|
| 1882 | 1914 | "issue":"issue", |
| 1883 | 1915 | "number-of-volumes":"numberOfVolumes", |
| 1884 | 1916 | "edition":"edition", |
| 1885 | | "number":"number" |
| | 1917 | /* |
| | 1918 | * fbennett (2): adding note and locator fields to number field map |
| | 1919 | */ |
| | 1920 | "number":"number", |
| | 1921 | "note":"extra", |
| | 1922 | "locator":"locator" |
| | 1923 | /* |
| | 1924 | * fbennett: end |
| | 1925 | */ |
| 1886 | 1926 | } |
| 1887 | 1927 | /* |
| 1888 | 1928 | * Gets a numeric object for a specific type. <number variable="edition" form="roman"/> |
| 1889 | 1929 | */ |
| 1890 | | Zotero.CSL.Item.prototype.getNumericVariable = function(variable, form) { |
| 1891 | | |
| | 1930 | /* |
| | 1931 | * fbennett (2): adding citationItem argument to function to gain access to locator field data |
| | 1932 | */ |
| | 1933 | Zotero.CSL.Item.prototype.getNumericVariable = function(variable, citationItem, form) { |
| | 1934 | /* |
| | 1935 | * fbennett: end |
| | 1936 | */ |
| 1892 | 1937 | if(!Zotero.CSL.Item._zoteroNumberFieldMap[variable]) return ""; |
| 1893 | 1938 | |
| 1894 | 1939 | var zoteroFields = []; |
| … |
… |
|
| 1903 | 1948 | |
| 1904 | 1949 | var matches; |
| 1905 | 1950 | for each(var zoteroField in zoteroFields) { |
| 1906 | | var value = this.zoteroItem.getField(zoteroField, false, true); |
| | 1951 | /* |
| | 1952 | * fbennett (2): adding special handling for locator field |
| | 1953 | */ |
| | 1954 | if(zoteroField == "locator") { |
| | 1955 | var value = citationItem.locator; |
| | 1956 | } else { |
| | 1957 | var value = this.zoteroItem.getField(zoteroField, false, true); |
| | 1958 | } |
| | 1959 | /* |
| | 1960 | * fbennett: end |
| | 1961 | */ |
| 1907 | 1962 | var matches; |
| 1908 | 1963 | if(value != "" && (matches = value.toString().match(Zotero.CSL._numberRegexp)) ) { |
| 1909 | 1964 | value = matches[0]; |