commit d0a9108d92375ce7b56e1b7889930a86fd304ce3
parent 63c4096a6cd7601ecee169590d828d3288899ca0
Author: Simon Kornblith <simon@simonster.com>
Date: Sat, 10 Mar 2012 13:09:31 -0800
Merge pull request #76 from aurimasv/cleanAuthor
cleanAuthor
Diffstat:
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/chrome/content/zotero/xpcom/utilities.js b/chrome/content/zotero/xpcom/utilities.js
@@ -147,7 +147,7 @@ Zotero.Utilities = {
}
author = author.replace(/^[\s\.\,\/\[\]\:]+/, '');
- author = author.replace((useComma ? /[\s\,\/\[\]\:]+$/ : /[\s\,\/\[\]\:\.]+$/), '');
+ author = author.replace(/[\s\,\/\[\]\:\.]+$/, '');
author = author.replace(/ +/, ' ');
if(useComma) {
// Add spaces between periods
@@ -176,7 +176,23 @@ Zotero.Utilities = {
}
firstName = newFirstName.substr(1);
}
-
+
+ //add periods after all the initials
+ if(firstName) {
+ var names = firstName.replace(/^[\s\.]+/,'')
+ .replace(/[\s\,]+$/,'')
+ //remove spaces surronding any dashes
+ .replace(/\s*([\u002D\u00AD\u2010-\u2015\u2212\u2E3A\u2E3B])\s*/,'$1')
+ .split(/[\s\.]+/);
+ var newFirstName = '';
+ for(var i=0, n=names.length; i<n; i++) {
+ newFirstName += names[i];
+ if(names[i].length == 1) newFirstName += '.';
+ newFirstName += ' ';
+ }
+ firstName = newFirstName.trim();
+ }
+
return {firstName:firstName, lastName:lastName, creatorType:type};
},