From 6393c3bfe2aba1f49e1b6dec91344800e781e8cb Mon Sep 17 00:00:00 2001 From: Aurimas Vinckevicius Date: Tue, 17 Sep 2013 21:41:34 -0500 Subject: [PATCH 1/5] Look for abbreviations for longest possible match first --- chrome/content/zotero/xpcom/cite.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chrome/content/zotero/xpcom/cite.js b/chrome/content/zotero/xpcom/cite.js index caed89fdd..f23f1e37c 100644 --- a/chrome/content/zotero/xpcom/cite.js +++ b/chrome/content/zotero/xpcom/cite.js @@ -419,7 +419,7 @@ Zotero.Cite.getAbbreviation = new function() { newWord = cat[lcWord]; } else { // Partial match - for(var k=1; k<=word.length && newWord === undefined; k++) { + for(var k=word.length; k>0 && newWord === undefined; k--) { newWord = cat[lcWord.substr(0, k)+"-"]; if(newWord && word.length - newWord.length < 1) { newWord = undefined; From a55f9b624e2ffa4dccac1f222df53bdd59217c71 Mon Sep 17 00:00:00 2001 From: Aurimas Vinckevicius Date: Tue, 17 Sep 2013 21:52:10 -0500 Subject: [PATCH 2/5] Don't drop last word when abbreviating journal names --- chrome/content/zotero/xpcom/cite.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/chrome/content/zotero/xpcom/cite.js b/chrome/content/zotero/xpcom/cite.js index f23f1e37c..24adae2a7 100644 --- a/chrome/content/zotero/xpcom/cite.js +++ b/chrome/content/zotero/xpcom/cite.js @@ -430,7 +430,10 @@ Zotero.Cite.getAbbreviation = new function() { // Fall back to full word if(newWord === undefined) newWord = word; - + + // Don't discard last word (e.g. Climate of the Past => Clim. Past) + if(!newWord && words.length<=j+2) newWord = word; + words[j] = newWord.substr(0, 1).toUpperCase() + newWord.substr(1); } abbreviation = words.join("").replace(/\s+/g, " ").trim(); From 7f7d78603a3419a32eca8d6423dad96c22d3802a Mon Sep 17 00:00:00 2001 From: Aurimas Vinckevicius Date: Tue, 17 Sep 2013 22:53:04 -0500 Subject: [PATCH 3/5] Use the longest abbreviation possible. E.g. Fictional journal "Journal of Annunc Materials" (obviously annunc is not a real word) Use "annunc-":"annunc." substitution instead of "annu-":"annu." resulting in "J. Annunc Mater." instead of "J. Annu. Mater." --- chrome/content/zotero/xpcom/cite.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/chrome/content/zotero/xpcom/cite.js b/chrome/content/zotero/xpcom/cite.js index 24adae2a7..74d1a05b2 100644 --- a/chrome/content/zotero/xpcom/cite.js +++ b/chrome/content/zotero/xpcom/cite.js @@ -421,13 +421,15 @@ Zotero.Cite.getAbbreviation = new function() { // Partial match for(var k=word.length; k>0 && newWord === undefined; k--) { newWord = cat[lcWord.substr(0, k)+"-"]; - if(newWord && word.length - newWord.length < 1) { - newWord = undefined; - } } } } - + + // Don't substitute with a longer word + if(newWord && word.length - newWord.length < 1) { + newWord = word; + } + // Fall back to full word if(newWord === undefined) newWord = word; From b680bcf375a2afd73ca42b677ad458126aec0b45 Mon Sep 17 00:00:00 2001 From: Aurimas Vinckevicius Date: Tue, 17 Sep 2013 23:55:21 -0500 Subject: [PATCH 4/5] Abbreviate plural forms of words same as singular --- chrome/content/zotero/xpcom/cite.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/chrome/content/zotero/xpcom/cite.js b/chrome/content/zotero/xpcom/cite.js index 74d1a05b2..d912fcb5e 100644 --- a/chrome/content/zotero/xpcom/cite.js +++ b/chrome/content/zotero/xpcom/cite.js @@ -408,8 +408,9 @@ Zotero.Cite.getAbbreviation = new function() { for(var j=0; j0 && newWord === undefined; k--) { @@ -426,7 +432,7 @@ Zotero.Cite.getAbbreviation = new function() { } // Don't substitute with a longer word - if(newWord && word.length - newWord.length < 1) { + if(newWord && !exactMatch && word.length - newWord.length < 1) { newWord = word; } From 84b6d8c5eee01e01743bf070a0facf449df97028 Mon Sep 17 00:00:00 2001 From: Aurimas Vinckevicius Date: Thu, 19 Sep 2013 14:05:38 -0500 Subject: [PATCH 5/5] If abbreviation is same as key, it's still valid See http://forums.zotero.org/discussion/32000/overriding-automatic-abbreviations/ --- chrome/content/zotero/xpcom/cite.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/chrome/content/zotero/xpcom/cite.js b/chrome/content/zotero/xpcom/cite.js index d912fcb5e..3a6712873 100644 --- a/chrome/content/zotero/xpcom/cite.js +++ b/chrome/content/zotero/xpcom/cite.js @@ -450,10 +450,8 @@ Zotero.Cite.getAbbreviation = new function() { } } - if(!abbreviation || abbreviation === key) { - Zotero.debug("No abbreviation found for "+key); - return; - } + if(!abbreviation) abbreviation = key; //this should never happen, but just in case + Zotero.debug("Abbreviated "+key+" as "+abbreviation); // Add to jurisdiction object