Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Capitalize" capitalizes words after hyphens #9186

Merged
merged 2 commits into from
Sep 29, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- We fixed an issue about selecting the save order in the preferences. [#9175](https://github.com/JabRef/jabref/issues/9147)
- We fixed an issue where the CSS styles are missing in some dialogs. [#9150](https://github.com/JabRef/jabref/pull/9150)
- We fixed an issue where pdfs were re-indexed on each startup. [#9166](https://github.com/JabRef/jabref/pull/9166)
- We fixed an issue where Capitalize didn't capitalize words after hyphen characters. [#9157](https://github.com/JabRef/jabref/issues/9157)

### Removed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public String getKey() {
public String format(String input) {
Title title = new Title(input);

title.getWords().stream().forEach(Word::toUpperFirst);
title.getWords().stream().forEach(Word::toUpperFirstIgnoreHyphen);

return title.toString();
}
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/org/jabref/logic/formatter/casechanger/Word.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,16 @@ public void toUpperFirst() {
}
}

public void toUpperFirstIgnoreHyphen() {
for (int i = 0; i < chars.length; i++) {
if (!protectedChars[i]) {
chars[i] = (i == 0 || (DASHES.contains(chars[i - 1]))) ?
Character.toUpperCase(chars[i]) :
Character.toLowerCase(chars[i]);
}
}
}

public void toUpperFirstTitle() {
for (int i = 0; i < chars.length; i++) {
if (!protectedChars[i]) {
Expand Down