nickng / bibtex

Basic parser for bibtex
Apache License 2.0
23 stars 8 forks source link

Parsing silently fails in case text between entries in bibfile #24

Open stmichaelis opened 6 months ago

stmichaelis commented 6 months ago

In case where there is text outside of entries, parsing silently fails and no entries are parsed. Example, which delivers 0 entries after parsing:

% Encoding: UTF-8
@article{CitekeyArticle,
  author   = "John Doe",
  title    = "The independence of the continuum hypothesis",
  journal  = "Proceedings of the National Academy of Sciences",
  year     = 1963,
  volume   = "50",
  number   = "6",
  pages    = "1143--1148",
}

While I do not see any reason for text outside of entries, it appears some bibliography tools are adding other forms of comments nevertheless. While this is considered garbage from a BibTeX/BibLaTeX point of view, they are still able to process the entries anyway.

Specifications seem to allow text between entries as well, e.g. see: https://tex.stackexchange.com/questions/21709/comments-in-bibtex and section 4.7: https://texdoc.org/serve/btxdoc/0

This parser should either throw an error on parsing or discard any text between entries.