Right clicking in the Jabref edit title field brings up "change case" and then one can "upper each first". The capitalization algorithm is crude, and uppercases "The" "And" "Of" etc., which then need to be hand-edited. Please replace the algorithm with this more sophisticated one, in JS, taken from StackOverflow:
// from http://stackoverflow.com/questions/196972/convert-string-to-title-case-with-javascript String.prototype.toTitleCase = function() { var i, str, lowers, uppers; str = this.replace(/([^\W_]+[^\s-]*) */g, function(txt) { return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(); }); // Certain minor words should be left lowercase unless // they are the first or last words in the string lowers = ['A', 'An', 'The', 'And', 'But', 'Or', 'For', 'Nor', 'As', 'At', 'By', 'For', 'From', 'In', 'Into', 'Near', 'Of', 'On', 'Onto', 'To', 'With']; for (i = 0; i < lowers.length; i++) str = str.replace(new RegExp('\\s' + lowers[i] + '\\s', 'g'), function(txt) { return txt.toLowerCase(); }); // Certain words such as initialisms or acronyms should be left uppercase uppers = ['Id', 'Tv']; for (i = 0; i < uppers.length; i++) str = str.replace(new RegExp('\\b' + uppers[i] + '\\b', 'g'), uppers[i].toUpperCase()); return str; }
And then something like this, but I don't know the internal syntax you use in JabRef:
cursor.replaceSelectedText(cursor.selectedText().toTitleCase())
All implemented by adding the TitleCaseChanger, except for the words that are left in UPPER. These are not considered in this algorithm, as they are very domain specific.
Targeted for 2.11.
Great; thanks!
Thank you for this very useful functionality! Especially with multi-lingual bibtex-files I often find myself in the need to normalize only English titles.
I noticed two potential improvements while using this function in Jabref 2.11b3. I don't know if we should collect these here or if I should open a new ticket?
1) I think it would be logical to leave capitalization within curly braces {} intact, as it often has special meaning and is used for abbriviatons or capitalizations within a word. Currently, the content is changed to lowercase.
2) In many cases, subtitles are seperated with a colon and often start with a minor word from the list ("a", "the"). Because of this, I would propose to change those minor words which appear after a colon to uppercase.
Just a few thoughts. Thank you for integrating this...!
I am afraid, at the moment we are concerned with a lot of other stuff. But we would appreciate pull requests on github - just look at the TitleCaseChanger class.
https://github.com/JabRef/jabref/pull/215 implements your suggestions Ben.