-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
feat:Allowed multiple delimiter in keyword separator field. #13706
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
Draft
tushar-2320
wants to merge
4
commits into
JabRef:main
Choose a base branch
from
tushar-2320:fix-for-issue-12974
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+40
−12
Draft
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
27f97b5
initial commit
tushar-2320 88fe7f7
refactor:converted arguments to string for multiple delimeter.
tushar-2320 729e2dc
Revert "refactor:converted arguments to string for multiple delimeter."
tushar-2320 37bd7e2
fix:created new method for parsing with multiple delimeter.
tushar-2320 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -165,7 +165,7 @@ public String expand(BibEntry bibentry) { | |
*/ | ||
public String expand(BibEntry bibentry, BibDatabase database) { | ||
Objects.requireNonNull(bibentry); | ||
Character keywordDelimiter = ';'; | ||
String keywordDelimiter = ";"; | ||
return expand(bibentry, keywordDelimiter, database); | ||
} | ||
|
||
|
@@ -177,7 +177,7 @@ public String expand(BibEntry bibentry, BibDatabase database) { | |
* @param database The database to use for string-lookups and cross-refs. May be null. | ||
* @return The expanded pattern. The empty string is returned, if it could not be expanded. | ||
*/ | ||
public String expand(BibEntry bibentry, Character keywordDelimiter, BibDatabase database) { | ||
public String expand(BibEntry bibentry, String keywordDelimiter, BibDatabase database) { | ||
Objects.requireNonNull(bibentry); | ||
return expandBrackets(this.pattern, keywordDelimiter, bibentry, database); | ||
} | ||
|
@@ -191,7 +191,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, String keywordDelimiter, BibEntry entry, BibDatabase database) { | ||
Objects.requireNonNull(pattern); | ||
Objects.requireNonNull(entry); | ||
return expandBrackets(pattern, expandBracketContent(keywordDelimiter, entry, database)); | ||
|
@@ -206,7 +206,7 @@ public static String expandBrackets(String pattern, Character keywordDelimiter, | |
* @param database The {@link BibDatabase} for field resolving. May be null. | ||
* @return a function accepting a bracketed expression and returning the result of expanding it | ||
*/ | ||
public static Function<String, String> expandBracketContent(Character keywordDelimiter, BibEntry entry, BibDatabase database) { | ||
public static Function<String, String> expandBracketContent(String keywordDelimiter, BibEntry entry, BibDatabase database) { | ||
return (String bracket) -> { | ||
List<String> fieldParts = parseFieldAndModifiers(bracket); | ||
// check whether there is a modifier on the end such as | ||
|
@@ -259,7 +259,7 @@ public static String expandBrackets(String pattern, Function<String, String> bra | |
/** | ||
* Returns the content enclosed between brackets, including enclosed quotes, and excluding the paired enclosing brackets. | ||
* There may be brackets in it. | ||
* Intended to be used by {@link BracketedPattern#expandBrackets(String, Character, BibEntry, BibDatabase)} when a [ | ||
* Intended to be used by {@link BracketedPattern#expandBrackets(String, String, BibEntry, BibDatabase)} when a [ | ||
* is encountered, and has been consumed, by the {@code StringTokenizer}. | ||
* | ||
* @param pattern pattern used by {@code expandBrackets}, used for logging | ||
|
@@ -302,7 +302,7 @@ private static String contentBetweenBrackets(StringTokenizer tokenizer, final St | |
|
||
/** | ||
* Appends the content between, and including, two \" to the provided <code>StringBuilder</code>. Intended to be | ||
* used by {@link BracketedPattern#expandBrackets(String, Character, BibEntry, BibDatabase)} when a \" is | ||
* used by {@link BracketedPattern#expandBrackets(String, String, BibEntry, BibDatabase)} when a \" is | ||
* encountered by the StringTokenizer. | ||
* | ||
* @param stringBuilder the <code>StringBuilder</code> to which tokens will be appended | ||
|
@@ -326,7 +326,7 @@ private static void appendQuote(StringBuilder stringBuilder, StringTokenizer tok | |
* @param database The database to use for field resolving. May be null. | ||
* @return String containing the evaluation result. Empty string if the pattern cannot be resolved. | ||
*/ | ||
public static String getFieldValue(BibEntry entry, String pattern, Character keywordDelimiter, BibDatabase database) { | ||
public static String getFieldValue(BibEntry entry, String pattern, String keywordDelimiter, BibDatabase database) { | ||
try { | ||
if (pattern.startsWith("auth") || pattern.startsWith("pureauth")) { | ||
// result the author | ||
|
@@ -481,7 +481,15 @@ public static String getFieldValue(BibEntry entry, String pattern, Character key | |
} else if (pattern.matches("keyword\\d+")) { | ||
// according to LabelPattern.php, it returns keyword number n | ||
int num = Integer.parseInt(pattern.substring(7)); | ||
KeywordList separatedKeywords = entry.getResolvedKeywords(keywordDelimiter, database); | ||
// KeywordList separatedKeywords = entry.getResolvedKeywords(keywordDelimiter, database); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another instance of commented code that should be removed. Version control systems like Git are designed to maintain code history, making commented-out code unnecessary. |
||
|
||
Optional<String> keywordsContent = entry.getResolvedFieldOrAlias(StandardField.KEYWORDS, database); | ||
|
||
for (char d : keywordDelimiter.toCharArray()) { | ||
keywordsContent = keywordsContent.map(content -> content.replace(d, ',')); | ||
} | ||
KeywordList separatedKeywords = keywordsContent.map(content -> KeywordList.parse(content, ',')).orElse(new KeywordList()); | ||
|
||
if (separatedKeywords.size() < num) { | ||
// not enough keywords | ||
return ""; | ||
|
@@ -497,7 +505,14 @@ public static String getFieldValue(BibEntry entry, String pattern, Character key | |
} else { | ||
num = Integer.MAX_VALUE; | ||
} | ||
KeywordList separatedKeywords = entry.getResolvedKeywords(keywordDelimiter, database); | ||
// KeywordList separatedKeywords = entry.getResolvedKeywords(keywordDelimiter, database); | ||
Optional<String> keywordsContent = entry.getResolvedFieldOrAlias(StandardField.KEYWORDS, database); | ||
|
||
for (char d : keywordDelimiter.toCharArray()) { | ||
keywordsContent = keywordsContent.map(content -> content.replace(d, ',')); | ||
} | ||
KeywordList separatedKeywords = keywordsContent.map(content -> KeywordList.parse(content, ',')).orElse(new KeywordList()); | ||
|
||
StringBuilder sb = new StringBuilder(); | ||
int i = 0; | ||
for (Keyword keyword : separatedKeywords) { | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commented code should be removed as it serves no purpose in understanding the current implementation and clutters the codebase. Git history should be used to track changes.