-
-
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
base: main
Are you sure you want to change the base?
Changes from 5 commits
55916ca
1319e8a
061577a
7f9df96
c7642fd
24696be
0fd9075
5e9e417
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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^_") | ||
Comment on lines
+309
to
+314
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. OK, but you did not test for 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. Thanks for pointing that out! I've added a new test case for InternalField.KEY_FIELD, but it's currently failing. 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. I assume, it is not failing now? |
||
); | ||
} | ||
|
||
@ParameterizedTest | ||
@MethodSource("provideCitationKeyInputs") | ||
void citationKeyField(String expectedMessage, Field field, String value) { | ||
entry.setField(field, value); | ||
// Ensure TTEM03 error is not raised for citation key field | ||
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. This comment has to move above 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. |
||
assertEquals(List.of(), checker.check(entry)); | ||
} | ||
|
||
koppor marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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") | ||
); | ||
} | ||
} |
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.
Why this comment? This is really what is in the next line - normally one adds the why on top - or summarizes the next line. Please just remove line 70
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.
Got it! Thanks for pointing that out! I’ll remove line 70.