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

Remove dash from illegal characters. #6300

Merged
merged 32 commits into from
May 6, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
2b7fad5
Remove dash from illegal characters. Fix #6295 #6257 #6252
dextep Apr 16, 2020
f332e42
Update bibtexkey incompatible characters.
dextep Apr 17, 2020
38687aa
Add missing abbreviated journal names (#6292)
mayrmt Apr 16, 2020
feb6709
Change in CHANGELOG.md described.
dextep Apr 17, 2020
23d9720
Revert "Add missing abbreviated journal names (#6292)"
dextep Apr 17, 2020
a90ac60
Update CHANGELOG.md
dextep Apr 17, 2020
ed42ac1
Update CHANGELOG.md
dextep Apr 17, 2020
6fc9645
Renamed 'KEY_UNWANTED_CHARACTERS' to 'KEY_CHARACTERS_CAUSING_PARSING_…
dextep Apr 17, 2020
00f8c92
Merged illegal `KEY_ILLEGAL_CHARACTERS` and disallowed `KEY_CHARACTER…
dextep Apr 22, 2020
e39cca3
Adapted the tests according to code updates.
dextep Apr 23, 2020
471ec0e
Removed 'enforceLegalKey'.
dextep Apr 28, 2020
19e0879
Removed "Enforce legal characters in BibTeX keys" option in the prefe…
dextep May 1, 2020
2161cd1
Changes related to the review.
dextep May 2, 2020
ae8b183
Remove dash from illegal characters. Fix #6295 #6257 #6252
dextep Apr 16, 2020
08257ff
Update bibtexkey incompatible characters.
dextep Apr 17, 2020
d0e5241
Change in CHANGELOG.md described.
dextep Apr 17, 2020
8a510e3
Revert "Add missing abbreviated journal names (#6292)"
dextep Apr 17, 2020
d7d5ac7
Update CHANGELOG.md
dextep Apr 17, 2020
dda3259
Update CHANGELOG.md
dextep Apr 17, 2020
7362457
Renamed 'KEY_UNWANTED_CHARACTERS' to 'KEY_CHARACTERS_CAUSING_PARSING_…
dextep Apr 17, 2020
fe43020
Merged illegal `KEY_ILLEGAL_CHARACTERS` and disallowed `KEY_CHARACTER…
dextep Apr 22, 2020
aae2b0e
Adapted the tests according to code updates.
dextep Apr 23, 2020
4807493
Removed 'enforceLegalKey'.
dextep Apr 28, 2020
0b1ca1a
Removed "Enforce legal characters in BibTeX keys" option in the prefe…
dextep May 1, 2020
d64b911
Changes related to the review.
dextep May 2, 2020
6032766
Changes related to the review.
dextep May 3, 2020
995ff60
Merge branch 'remove-dash-from-illegal-chars' of https://github.com/d…
dextep May 3, 2020
4d37195
Merge remote-tracking branch 'upstream/master' into remove-dash-from-…
dextep May 4, 2020
3f5b2e5
Fix checkstyle.
dextep May 5, 2020
6db1344
Changes related to the review.
dextep May 5, 2020
c1ec4ad
Changes related to the review.
dextep May 6, 2020
cfeea59
Changes related to the review.
dextep May 6, 2020
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 @@ -11,6 +11,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve

### Added

- We added a new field in the preferences in 'BibTeX key generator' for unwanted characters that can be user-specified. [#6295](https://github.com/JabRef/jabref/issues/6295)
- We added support for searching ShortScience for an entry through the user's browser. [#6018](https://github.com/JabRef/jabref/pull/6018)
- We updated EditionChecker to permit edition to start with a number. [#6144](https://github.com/JabRef/jabref/issues/6144)
- We added tooltips for most fields in the entry editor containing a short description. [#5847](https://github.com/JabRef/jabref/issues/5847)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,15 @@ public static String removeUnwantedCharacters(String key, String unwantedCharact
for (char ch : unwantedCharacters.toCharArray()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need the unwantedChars variable, do we? Can you please delete that for loop and the variable? --> the code on line 86 directly accesses the method parameter unwantedChararacters!

Side note: This is an example why similar variable names can be mixed up.

Copy link
Contributor Author

@dextep dextep May 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course, we don't need it, I'm sorry. Every time I get the impression that I didn't notice something. 🐞

unwantedChars.add(ch);
}

StringBuilder newKey = new StringBuilder();
for (int i = 0; i < key.length(); i++) {
char c = key.charAt(i);
if (!DISALLOWED_CHARACTERS.contains(c) && !unwantedChars.contains(c)) {
newKey.append(c);
}
}
String newKey = key.chars()
.filter(c -> unwantedCharacters.indexOf(c) == -1)
.filter(c -> !DISALLOWED_CHARACTERS.contains((char) c))
.collect(StringBuilder::new,
StringBuilder::appendCodePoint, StringBuilder::append)
.toString();
// Replace non-English characters like umlauts etc. with a sensible
// letter or letter combination that bibtex can accept.
return StringUtil.replaceSpecialCharacters(newKey.toString());
return StringUtil.replaceSpecialCharacters(newKey);
}

public static String cleanKey(String key, String unwantedCharacters) {
Expand Down