inukshuk / bibtex-ruby

A BibTeX library, parser, and converter for Ruby.
http://inukshuk.github.com/bibtex-ruby
GNU General Public License v3.0
156 stars 31 forks source link

Braces in citekey #150

Open mapreal19 opened 3 years ago

mapreal19 commented 3 years ago

When a citekey has braces the parser can't handle it. Maybe we should strip them when processing?

The example bibtex I've got:

@book{book:{421090},
  title = {Fuzzy Reasoning in Information...)},
  author = {S.G. Tzafestas, Anastasios N. Venetsanopoulos},
}

Error

 BibTeX::ParseError:
       Failed to parse BibTeX on value "{" (LBRACE) ["@", #<BibTeX::Entry >, "book:"]
     # bibtex.y:138:in `on_error'
     # (eval):3:in `_racc_do_parse_c'
     # (eval):3:in `do_parse'
     # bibtex.y:111:in `parse'

Using the latex filter produces the same result.

inukshuk commented 3 years ago

I don't remember if BibTeX itself allows such keys, but I vaguely remember that we already made changes in the past to be less strict with the key syntax, so we can probably do the same here. If I'm not mistaken you'd just have to change the lexer pattern for keys here. You can probably test this at runtime even by adjusting BibTeX::Lexer.defaults or passing the options to Bibliography.parse which, I think, passes them through all the way to the lexer instantiation.

mapreal19 commented 3 years ago

ok! I'll try to make the change.