diff --git a/chrome/content/zotero/xpcom/cite.js b/chrome/content/zotero/xpcom/cite.js index 3a67128739..00ce12b72b 100644 --- a/chrome/content/zotero/xpcom/cite.js +++ b/chrome/content/zotero/xpcom/cite.js @@ -405,9 +405,13 @@ Zotero.Cite.getAbbreviation = new function() { var words = normalizedKey.split(/([ \-])/); if(words.length > 1) { + var lcWords = []; + for(var j=0; j0 && newWord === undefined; k--) { - newWord = cat[lcWord.substr(0, k)+"-"]; + if(j < words.length-2) { + // Two-word match + newWord = cat[lcWord+words[j+1]+lcWords[j+2]]; + if(newWord !== undefined) { + words.splice(j+1, 2); + lcWords.splice(j+1, 2); + exactMatch = true; + } + } + + if(newWord === undefined) { + // Partial match + for(var k=lcWord.length; k>0 && newWord === undefined; k--) { + newWord = cat[lcWord.substr(0, k)+"-"]; + } } } } @@ -440,7 +456,7 @@ Zotero.Cite.getAbbreviation = new function() { 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; + if(!newWord && j == words.length-1) newWord = word; words[j] = newWord.substr(0, 1).toUpperCase() + newWord.substr(1); }