-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Fix Copy cite command should respect preferences #10707
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
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
f85c393
Fix Copy cite command should respect preferences
Siedlerchr a4ef04f
add changelog
Siedlerchr 10f748b
Fix CHANGELOG.md
koppor ed5e3a2
Add missing "citation" to "key"
koppor bac658b
Add debug message at error in logic in CopyMoreAction
koppor f3ee184
Add fallback if preference could not be parsed
koppor bc64e5f
Fix key binding setting
koppor ff3d6c3
More relaxed parsing
koppor 0b1fc6b
Streamline code in AbstractPushToApplication
koppor b501709
Add more test cases for configured citation command
koppor 2a4fe1b
Streamline code for copy action
koppor f965146
Merge branch 'main' into copycitecommand
koppor 28d003d
Update src/main/java/org/jabref/gui/preferences/external/ExternalTabV…
Siedlerchr d6b1de1
Fix test
koppor 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
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
34 changes: 34 additions & 0 deletions
34
src/main/java/org/jabref/logic/push/CitationCommandString.java
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package org.jabref.logic.push; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public record CitationCommandString(String prefix, String delimiter, String suffix) { | ||
private static final Logger LOGGER = LoggerFactory.getLogger(CitationCommandString.class); | ||
private static final String CITE_KEY1 = "key1"; | ||
private static final String CITE_KEY2 = "key2"; | ||
|
||
@Override | ||
public String toString() { | ||
return prefix + CITE_KEY1 + delimiter + CITE_KEY2 + suffix; | ||
} | ||
|
||
public static CitationCommandString from(String completeCiteCommand) { | ||
Siedlerchr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
int indexKey1 = completeCiteCommand.indexOf(CITE_KEY1); | ||
int indexKey2 = completeCiteCommand.indexOf(CITE_KEY2); | ||
if (indexKey1 < 0 || indexKey2 < 0 || indexKey2 < (indexKey1 + CITE_KEY1.length())) { | ||
LOGGER.info("Wrong indexes {} {} for completeCiteCommand {}. Using default delimiter and suffix.", indexKey1, indexKey2, completeCiteCommand); | ||
if (completeCiteCommand.isEmpty()) { | ||
completeCiteCommand = "\\cite{"; | ||
} else if (!completeCiteCommand.endsWith("{")) { | ||
completeCiteCommand += "{"; | ||
} | ||
return new CitationCommandString(completeCiteCommand, ",", "}"); | ||
} | ||
|
||
String prefix = completeCiteCommand.substring(0, indexKey1); | ||
String delim = completeCiteCommand.substring(completeCiteCommand.lastIndexOf(CITE_KEY1) + CITE_KEY1.length(), indexKey2); | ||
String suffix = completeCiteCommand.substring(completeCiteCommand.lastIndexOf(CITE_KEY2) + CITE_KEY2.length()); | ||
return new CitationCommandString(prefix, delim, suffix); | ||
} | ||
} |
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.
Uh oh!
There was an error while loading. Please reload this page.