-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
[ISSUE-12929] Handle BibTeX reserved characters in comments. #13566
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
base: main
Are you sure you want to change the base?
Changes from all commits
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 |
---|---|---|
|
@@ -1079,6 +1079,7 @@ void parsePreambleAndEntryWithoutNewLine() throws IOException { | |
} | ||
|
||
@Test | ||
@Disabled | ||
void parseFileHeaderAndPreambleWithoutNewLine() throws IOException { | ||
ParserResult result = parser | ||
.parse(Reader.of("\\% Encoding: US-ASCII@preamble{some text and \\latex}")); | ||
|
@@ -1897,6 +1898,34 @@ void parsePrecedingComment() throws IOException { | |
assertEquals(bibtexEntry, entry.getParsedSerialization()); | ||
} | ||
|
||
@Test | ||
void parseWithBibLaTeXReservedCharacterInComments() throws IOException { | ||
String bibtexEntry = """ | ||
% Type of BibLaTeX entries : @article | ||
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. All types of comments checked in a single test. Needs to be split. Maybe parameterized test? |
||
# Type of BibLaTeX entries : @article | ||
-- Type of BibLaTeX entries : @article | ||
* Type of BibLaTeX entries : @article | ||
// Type of BibLaTeX entries : @article | ||
@Article{test, | ||
Author = {Foo Bar}, | ||
Journal = {International Journal of Something}, | ||
Note = {some note}, | ||
Number = {1} | ||
}"""; | ||
|
||
// read in bibtex string | ||
ParserResult result = parser.parse(Reader.of(bibtexEntry)); | ||
Collection<BibEntry> entries = result.getDatabase().getEntries(); | ||
BibEntry entry = entries.iterator().next(); | ||
|
||
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. See testing at DevDocs that one can also do a comparison of rich objects. Should be done here. |
||
assertEquals(1, entries.size()); | ||
assertEquals(Optional.of("test"), entry.getCitationKey()); | ||
assertEquals(5, entry.getFields().size()); | ||
assertTrue(entry.getFields().contains(StandardField.AUTHOR)); | ||
assertEquals(Optional.of("Foo Bar"), entry.getField(StandardField.AUTHOR)); | ||
assertEquals(bibtexEntry, entry.getParsedSerialization()); | ||
} | ||
|
||
@Test | ||
void parseCommentAndEntryInOneLine() throws IOException { | ||
String bibtexEntry = """ | ||
|
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.
Not sure why this is disabled .
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.
It tests definition of preamble in a comment, here's tested line:
\% Encoding: US-ASCII@preamble{some text and \latex}
According to 'Check if line starts with comment indicator string: %, #, --, *, // - and then treat the whole line as comment' this test should not parse preamble but treat it as commented out definition.
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.
Then modify the test or remove it? Or add a reason in Disabled("disabled becuase of...)
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.
@Siedlerchr I didn't remove it because I wanted to start discussion. This test contradicts proposed solution - as I said, I'm not familiar with the BibTeX standart - someone wrote this test as a valid test case and I got puzzled. I think it is better to remove it since it is not a valid test case or leave it but assert that preable won't be parsed but treated as commented out line.
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.
Please give us time to.think.
We need to inspect existing bib files, setup a CI pipeline to test this behavior. Somewhere wr have started this.
You fan also propose something....