Humans-of-Julia / BibParser.jl

Parser for bibliographic formats, including BibTeX, in pure Julia
MIT License
13 stars 5 forks source link

Fixing issue #22 by restructuring tracking of curly brace nesting. #23

Closed LazyScholar closed 3 years ago

LazyScholar commented 3 years ago

Fixed the problem of the mutation of strings within the curly braces entries in issue #22.

Note that i did not change the stability of the parser! Unequal numbers of { and } after the sequence <entry> = will still lead to misbehaviour of the parser (which is not necessarily bad).

using Pkg
Pkg.activate(".")
using BibParser

test = parse_entry(raw"
@Article{2015Nguyen,
  author    = {Vinh Phu Nguyen and Cosmin Anitescu and St{\'{e}}phane P.A. Bordas and Timon Rabczuk},
  journal   = {Mathematics and Computers in Simulation},
  title     = {Isogeometric analysis: An overview and computer implementation aspects},
  year      = {2015},
  month     = {nov},
  pages     = {89--116},
  volume    = {117},
  doi       = {10.1016/j.matcom.2015.05.008},
  publisher = {Elsevier {BV}},
}
")
display(test["2015Nguyen"].authors)
4-element Vector{BibInternal.Name}:
 BibInternal.Name("", "Nguyen", "", "Vinh", " Phu")
 BibInternal.Name("", "Anitescu", "", "Cosmin", "")
 BibInternal.Name("", "Bordas", "", "St{\\'{e}}phane", " P.A.")
 BibInternal.Name("", "Rabczuk", "", "Timon", "")
Azzaare commented 3 years ago

@LazyScholar I have been super busy for a week, so I am currently popping GitHub stuff from the stack. I will go through this either today or tomorrow. Thanks in any case ;)

LazyScholar commented 3 years ago

Tiny change to make it more robust in case of error (resetting brace count in case of error).