-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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: Ignore "Math superscript (^) and subscript (_) characters are not allowed in text mode" error for citation key (#11948) #12391
Open
Satyamkumarnavneet
wants to merge
4
commits into
JabRef:main
Choose a base branch
from
Satyamkumarnavneet:ignore-citation-key-validation
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.
+30
−3
Open
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
55916ca
Fix: Ignore superscript (^) and subscript (_) validation for citation…
1319e8a
Changelog: Update with fix for superscript and subscript validation i…
061577a
Fix: Address feedback for TTEM03 citation key validation
7f9df96
Apply OpenRewrite fixes
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 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 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 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 |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
|
||
import org.jabref.model.entry.BibEntry; | ||
import org.jabref.model.entry.field.Field; | ||
import org.jabref.model.entry.field.InternalField; | ||
import org.jabref.model.entry.field.StandardField; | ||
import org.jabref.model.entry.field.UserSpecificCommentField; | ||
|
||
|
@@ -300,10 +301,33 @@ private static Stream<Arguments> provideUnacceptedInputs() { | |
Arguments.of(LatexIntegrityChecker.errorMessageFormatHelper(CoreErrorCode.TFEM03), StandardField.TITLE, "$\\right)$"), | ||
|
||
// TFEM04: \left had no following \right | ||
Arguments.of(LatexIntegrityChecker.errorMessageFormatHelper(CoreErrorCode.TFEM04), StandardField.TITLE, "$\\left($") | ||
Arguments.of(LatexIntegrityChecker.errorMessageFormatHelper(CoreErrorCode.TFEM04), StandardField.TITLE, "$\\left($"), | ||
|
||
// TFETB0: \hline must be the only token in table row | ||
// Skipped | ||
|
||
Arguments.of(LatexIntegrityChecker.errorMessageFormatHelper(CoreErrorCode.TTEM03), StandardField.TITLE, "Title with ^ and _ characters"), | ||
// Ensure invalid LaTeX syntax with special characters in other fields is detected | ||
Arguments.of(LatexIntegrityChecker.errorMessageFormatHelper(CoreErrorCode.TTEM03), StandardField.AUTHOR, "Author_Name"), | ||
Arguments.of(LatexIntegrityChecker.errorMessageFormatHelper(CoreErrorCode.TTEM03), StandardField.JOURNAL, "Journal_Name"), | ||
Arguments.of(LatexIntegrityChecker.errorMessageFormatHelper(CoreErrorCode.TTEM03), StandardField.BOOKTITLE, "Book^Title"), | ||
Arguments.of(LatexIntegrityChecker.errorMessageFormatHelper(CoreErrorCode.TTEM03), StandardField.NOTE, "Note_with_subscript_and_superscript^_") | ||
); | ||
} | ||
|
||
@ParameterizedTest | ||
@MethodSource("provideCitationKeyInputs") | ||
void testCitationKeyField(String expectedMessage, Field field, String value) { | ||
entry.setField(field, value); | ||
// Ensure TTEM03 error is not raised for citation key field | ||
assertEquals(List.of(), checker.check(entry)); | ||
} | ||
|
||
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. No empty line at the end. 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. Thank you for the feedback! I’ll make sure to take care of this next time. |
||
private static Stream<Arguments> provideCitationKeyInputs() { | ||
return Stream.of( | ||
Arguments.of("", InternalField.KEY_FIELD, "Corti_2009"), | ||
Arguments.of("", InternalField.KEY_FIELD, "Key_With^Superscript"), | ||
Arguments.of("", InternalField.KEY_FIELD, "Key_With_Subscript") | ||
); | ||
} | ||
} |
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.
OK, but you did not test for
org.jabref.model.entry.field.InternalField#KEY_FIELD
, where you changed the behavior.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.
Thanks for pointing that out! I've added a new test case for InternalField.KEY_FIELD, but it's currently failing.