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: bibkey generated does not handle diacritics #4713

Merged
merged 8 commits into from
Mar 10, 2019
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
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public String generateKey(BibEntry entry) {
List<String> parts = parseFieldMarker(typeListEntry);
Character delimiter = bibtexKeyPatternPreferences.getKeywordDelimiter();
String pattern = "[" + parts.get(0) + "]";
String label = expandBrackets(pattern, delimiter, entry, database);
String label = expandBrackets(pattern, delimiter, entry, database, bibtexKeyPatternPreferences.isEnforceLegalKey());
// apply modifier if present
if (parts.size() > 1) {
label = applyModifiers(label, parts, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ public String expand(BibEntry bibentry, Character keywordDelimiter, BibDatabase
return expandBrackets(this.pattern, keywordDelimiter, bibentry, database);
}

public static String expandBrackets(String pattern, Character keywordDelimiter, BibEntry entry, BibDatabase database) {
return expandBrackets(pattern, keywordDelimiter, entry, database, false);
}

/**
* Expands a pattern
*
Expand All @@ -101,7 +105,7 @@ public String expand(BibEntry bibentry, Character keywordDelimiter, BibDatabase
* @param database The database for field resolving. May be null.
* @return The expanded pattern. Not null.
*/
public static String expandBrackets(String pattern, Character keywordDelimiter, BibEntry entry, BibDatabase database) {
public static String expandBrackets(String pattern, Character keywordDelimiter, BibEntry entry, BibDatabase database, boolean isEnforceLegalKey) {
Objects.requireNonNull(pattern);
Objects.requireNonNull(entry);
StringBuilder sb = new StringBuilder();
Expand All @@ -122,10 +126,10 @@ public static String expandBrackets(String pattern, Character keywordDelimiter,
// check whether there is a modifier on the end such as
// ":lower":
if (fieldParts.size() <= 1) {
sb.append(getFieldValue(entry, token, keywordDelimiter, database));
sb.append(getFieldValue(entry, token, keywordDelimiter, database, isEnforceLegalKey));
} else {
// apply modifiers:
String fieldValue = getFieldValue(entry, fieldParts.get(0), keywordDelimiter, database);
String fieldValue = getFieldValue(entry, fieldParts.get(0), keywordDelimiter, database, isEnforceLegalKey);
sb.append(applyModifiers(fieldValue, fieldParts, 1));
}
// Fetch and discard the closing ']'
Expand Down Expand Up @@ -156,7 +160,7 @@ public static String expandBrackets(String pattern, Character keywordDelimiter,
*
* @return String containing the evaluation result. Empty string if the pattern cannot be resolved.
*/
public static String getFieldValue(BibEntry entry, String value, Character keywordDelimiter, BibDatabase database) {
public static String getFieldValue(BibEntry entry, String value, Character keywordDelimiter, BibDatabase database, boolean isEnforceLegalKey) {

String val = value;
try {
Expand Down Expand Up @@ -187,7 +191,7 @@ public static String getFieldValue(BibEntry entry, String value, Character keywo
}
}
}

authString = BibtexKeyGenerator.cleanKey(authString, isEnforceLegalKey);
// Gather all author-related checks, so we don't
// have to check all the time.
if ("auth".equals(val)) {
Expand Down