commit b35ba91c1521300158b25cf175a3a85963b5c90e
parent 37a6684546bb4911d442789d05b4bb0769477dcf
Author: Simon Kornblith <simon@simonster.com>
Date: Tue, 15 Aug 2006 01:26:14 +0000
closes #185, Citations shouldn't add a period to reference titles that already end with punctuation marks
Diffstat:
1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/chrome/chromeFiles/content/scholar/xpcom/cite.js b/chrome/chromeFiles/content/scholar/xpcom/cite.js
@@ -746,6 +746,7 @@ CSL.prototype._formatString = function(element, string, format, dontEscape) {
string = string.toString();
}
+ // handle text transformation
if(element["text-transform"]) {
if(element["text-transform"] == "lowercase") {
// all lowercase
@@ -759,6 +760,20 @@ CSL.prototype._formatString = function(element, string, format, dontEscape) {
}
}
+ // special rule: if a field ends in a punctuation mark, and the suffix
+ // begins with a period, chop the period off the suffix
+ var suffix;
+ if(element.suffix) {
+ suffix = element.suffix; // copy so as to leave original intact
+
+ if(suffix[0] == ".") {
+ var lastChar = string[string.length-1];
+ if(lastChar == "." || lastChar == "?" || lastChar == "!") {
+ suffix = suffix.substr(1);
+ }
+ }
+ }
+
if(!dontEscape) {
string = this._escapeString(string, format);
}
@@ -792,10 +807,8 @@ CSL.prototype._formatString = function(element, string, format, dontEscape) {
if(format != "compare" && element.prefix) {
string = this._escapeString(element.prefix, format)+string;
}
- if(format != "compare" && element.suffix &&
- (element.suffix.length != 1 || string[string.length-1] != element.suffix)) {
- // skip if suffix is the same as the last char
- string += this._escapeString(element.suffix, format);
+ if(format != "compare" && suffix) {
+ string += this._escapeString(suffix, format);
}
return string;