Skip to content

Commit

Permalink
Fold title into citation-label if no author
Browse files Browse the repository at this point in the history
  • Loading branch information
fbennett committed May 28, 2016
1 parent c7e5338 commit 0ef6c98
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/util_citationlabel.js
Expand Up @@ -52,6 +52,26 @@ CSL.Engine.prototype.getCitationLabel = function (Item) {
break;
}
}
if (!label) {
// Try for something using title
if (Item.title) {
var skipWords = this.locale[this.opt.lang].opts["skip-words"];
var lst = Item.title.split(/\s+/);
for (var i = lst.length - 1; i > -1; i--) {
if (skipWords.indexOf(lst[i]) > -1) {
lst = lst.slice(0, i).concat(lst.slice(i + 1));
}
}
var str = lst.join('');
str = str.slice(0, params[0].authors[0]);
if (str.length > 1) {
str = str.slice(0, 1).toUpperCase() + str.slice(1).toLowerCase();
} else if (str.length === 1) {
str = str.toUpperCase();
}
label = str;
}
}
var year = "0000";
if (Item.issued) {
if (Item.issued.year) {
Expand Down

0 comments on commit 0ef6c98

Please sign in to comment.