Skip to content

Unittest: assure preamble parses with arbitrary brackets#7768

Closed
gwy15 wants to merge 1 commit into
JabRef:mainfrom
gwy15:preamble-bracket-pair-test
Closed

Unittest: assure preamble parses with arbitrary brackets#7768
gwy15 wants to merge 1 commit into
JabRef:mainfrom
gwy15:preamble-bracket-pair-test

Conversation

@gwy15

@gwy15 gwy15 commented May 25, 2021

Copy link
Copy Markdown

The preamble part of the bibtext parser (logic/importer/fileformat/BibtextParser) has a parseBracketedText method that accepts any pairing of curly bracket and round bracket, for example

@preamble{ some (  { text ) } )

is acceptable.

I'm writing a new test case for that to indicate that this 'feature' is tested so that developers should know this is a feature not a bug.

I assume that this is designed as is, so that it won't break on opening current acceptable bibtex files. But if this is indeed a bug, please let me know so that I can get a PR for this.

  • Change in CHANGELOG.md described in a way that is understandable for the average user (if applicable)
  • Tests created for changes (if applicable)
  • Manually tested changed features in running JabRef (always required)
  • Screenshots added in PR description (for UI changes)
  • Checked documentation: Is the information available and up to date? If not created an issue at https://github.com/JabRef/user-documentation/issues or, even better, submitted a pull request to the documentation repository.

@Siedlerchr

Copy link
Copy Markdown
Member

Regarding the preamble I found this Tex StackExchange answer which provides some more info of the preamble and the allowed format and how it's used in bibtex
https://tex.stackexchange.com/a/468369

void parseRecognizesPreambleWithArbitraryBracketPairAndSpace() throws IOException {
ParserResult result = parser
.parse(new StringReader("@preamble{some ( {text )}) and \\latex}"));
// |> the rest got cut-off

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not understand "got cut-off". Can you elaborate? Maybe, it is just not required, beucause the preamble itself is tested.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so in current implementation, as long as jabref get enough of pairing brackets, in this case { ( { ) } ), it returns immediately and ignores the rest of the input.

@koppor

koppor commented Jun 3, 2021

Copy link
Copy Markdown
Member

Regarding the preamble I found this Tex StackExchange answer which provides some more info of the preamble and the allowed format and how it's used in bibtex
tex.stackexchange.com/a/468369

Thank you for the link. The link should also be added to JabRef's preamble-parsing source.

JabRef should be able to parse even invalid files, because users want to edit their library using JabRef - and not fall back to other tools not having parsing issues.

@gwy15 Thank you for your contribution. Since we take each contribution serious, please also be reminded that this contribution causes us energy to think about it. Thus, these comments. Since you are also in the context of pre-amble-parsing, you can think of more on it. Can you, for instance, check whether the user documentation also has correct content for preamble handling?

Other than that, I would not spend much more energy here. I do not know any user using the premable feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants