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 patch incorporates the following modification: |
| | 27 | * |
| | 28 | * (3) New is-quoted test: |
| | 29 | * This test returns true if the target field is enclosed in |
| | 30 | * double-quote marks. This opens a path for the exceptional |
| | 31 | * handling of fields which normally contain a single word or |
| | 32 | * number, and take (the edition field is the obvious example). |
| | 33 | * Some such facility will be needed for hands-free processing |
| | 34 | * of the Bluebook style. |
| | 35 | * |
| | 36 | * The changes labled fbennett (3) below provide this test. |
| | 37 | */ |
| | 38 | |
| 23 | 39 | /* |
| 24 | 40 | * CSL: a class for creating bibliographies from CSL files |
| 25 | 41 | * this is abstracted as a separate class for the benefit of anyone who doesn't |
| … |
… |
|
| 99 | 115 | Zotero.CSL._firstNameRegexp = /^[^\s]*/; |
| 100 | 116 | Zotero.CSL._textCharRegexp = /[a-zA-Z0-9]/; |
| 101 | 117 | Zotero.CSL._numberRegexp = /\d+/; |
| | 118 | /* |
| | 119 | * fbennett (3): adding regexp for detecting enclosing quotes |
| | 120 | */ |
| | 121 | Zotero.CSL._quotedRegexp = /^(".*")$/; |
| | 122 | /* |
| | 123 | * fbennett: end |
| | 124 | */ |
| 102 | 125 | Zotero.CSL.prototype.formatCitation = function(citation, format) { |
| 103 | 126 | default xml namespace = "http://purl.org/net/xbiblio/csl"; with({}); |
| 104 | 127 | |
| … |
… |
|
| 757 | 780 | |
| 758 | 781 | if(variables[j] == "locator") { |
| 759 | 782 | // special case for locator |
| 760 | | var text = citationItem && citationItem.locator ? citationItem.locator : ""; |
| | 783 | /* |
| | 784 | * fbennett (3): strip quotes from locator: |
| | 785 | */ |
| | 786 | var text = citationItem && citationItem.locator ? item.stripQuotes(citationItem.locator) : ""; |
| | 787 | /* |
| | 788 | * fbennett: end |
| | 789 | */ |
| 761 | 790 | } else if(citationItem && citationItem._csl && citationItem._csl[variables[j]]) { |
| 762 | 791 | // override if requested |
| 763 | 792 | var text = citationItem._csl[variables[j]]; |
| … |
… |
|
| 1036 | 1065 | |
| 1037 | 1066 | // inspect variables |
| 1038 | 1067 | var done = false; |
| 1039 | | var attributes = ["variable", "is-date", "is-numeric", "is-plural", "type", "disambiguate", "locator", "position"]; |
| | 1068 | /* |
| | 1069 | * fbennett (3): add "is-quoted" to attributes list |
| | 1070 | */ |
| | 1071 | var attributes = ["variable","is-date", "is-numeric", "is-plural", "type", "disambiguate","locator","position","is-quoted"]; |
| | 1072 | /* |
| | 1073 | * fbennett: end |
| | 1074 | */ |
| 1040 | 1075 | for(var k=0; !done && k<attributes.length; k++) { |
| 1041 | 1076 | var attribute = attributes[k]; |
| 1042 | 1077 | |
| … |
… |
|
| 1087 | 1122 | exists = citationItem && citationItem.locator && |
| 1088 | 1123 | (citationItem.locatorType == variables[j] |
| 1089 | 1124 | || (!citationItem.locatorType && variables[j] == "page")); |
| | 1125 | /* |
| | 1126 | * fbennett (3): adding is-quoted condition |
| | 1127 | */ |
| | 1128 | } else if (attribute == "is-quoted") { |
| | 1129 | //special handling for locator |
| | 1130 | if(variables[j] == "locator") { |
| | 1131 | exists = citationItem && citationItem.locator ? citationItem.locator.match(Zotero.CSL._quotedRegexp) : "" |
| | 1132 | } else { |
| | 1133 | exists = item.getVariable(variables[j],"nostrip").match(Zotero.CSL._quotedRegexp); |
| | 1134 | } |
| | 1135 | /* |
| | 1136 | * fbennett: end |
| | 1137 | */ |
| 1090 | 1138 | } else { // attribute == "position" |
| 1091 | 1139 | if(variables[j] == "first") { |
| 1092 | 1140 | exists = !citationItem |
| … |
… |
|
| 1824 | 1872 | |
| 1825 | 1873 | for each(var zoteroField in zoteroFields) { |
| 1826 | 1874 | var value = this.zoteroItem.getField(zoteroField, false, true); |
| 1827 | | if(value != "") return value + ''; |
| | 1875 | /* |
| | 1876 | * fbennett (3): strip quotes from field if form != "nostrip" |
| | 1877 | */ |
| | 1878 | if(value != "") return this.stripQuotes(value, form) + ''; |
| | 1879 | /* |
| | 1880 | * fbennett: end |
| | 1881 | */ |
| 1828 | 1882 | } |
| 1829 | 1883 | |
| 1830 | 1884 | return ""; |
| … |
… |
|
| 2062 | 2116 | } |
| 2063 | 2117 | |
| 2064 | 2118 | /* |
| | 2119 | * fbennett: (3): add function to strip double-quotation marks from a string |
| | 2120 | */ |
| | 2121 | Zotero.CSL.Item.prototype.stripQuotes = function(value,form) { |
| | 2122 | if(typeof(value) == "string" && value.substr(0,1) == '"' && value.substr(value.length-1,1) == '"' && form != "nostrip") { |
| | 2123 | return value.slice(1,value.length-1); |
| | 2124 | } else { |
| | 2125 | return value; |
| | 2126 | } |
| | 2127 | } |
| | 2128 | /* |
| | 2129 | * fbennett: end |
| | 2130 | */ |
| | 2131 | |
| | 2132 | /* |
| 2065 | 2133 | * Date class |
| 2066 | 2134 | */ |
| 2067 | 2135 | Zotero.CSL.Item.Date = function(date, sort) { |