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

Fix #5551 - Don't remove unwanted characters before first author is s… #5558

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -57,6 +57,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
- We fixed an exception which occurred when an invalid jstyle was loaded. [#5452](https://github.com/JabRef/jabref/issues/5452)
- We fixed an error where the preview theme did not adapt to the "Dark" mode [#5463](https://github.com/JabRef/jabref/issues/5463)
- We fixed an issue where the merge dialog showed the wrong text colour in "Dark" mode [#5516](https://github.com/JabRef/jabref/issues/5516)
- We fixed an issue where the author field was not correctly parsed during bibtex key-generation. [#5551](https://github.com/JabRef/jabref/issues/5551)

### Removed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -843,8 +843,8 @@ public static String authNofMth(String authorField, int n, int m) {
* First N chars of the first author's last name.
*/
public static String authN(String authString, int num, boolean isEnforceLegalKey) {
authString = BibtexKeyGenerator.removeUnwantedCharacters(authString, isEnforceLegalKey);
String fa = firstAuthor(authString);
fa = BibtexKeyGenerator.removeUnwantedCharacters(fa, isEnforceLegalKey);
if (num > fa.length()) {
num = fa.length();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1087,4 +1087,13 @@ public void generateKeyWithMinusInCitationStyleOutsideAField() throws Exception

assertEquals("Newton-2019", BibtexKeyGenerator.generateKey(entry, "[auth]-[year]"));
}

@Test
public void generateKeyWithWithFirstNCharacters() throws Exception {
BibEntry entry = new BibEntry();
entry.setField(StandardField.AUTHOR, "Newton, Isaac");
entry.setField(StandardField.YEAR, "2019");

assertEquals("newt-2019", BibtexKeyGenerator.generateKey(entry, "[auth4:lower]-[year]"));
}
}