pub fn parse_bibtex(input: &str) -> Result<Bibliography, BibParseError>Expand description
Parse input as a minimal BibTeX database.
Returns a Bibliography whose entries are keyed by citation key. A
duplicate citation key is rejected with BibParseErrorKind::DuplicateKey
at the duplicate key’s offset, so later resolver work can report it before
any source-location context is lost; a repeated field name inside one entry
keeps its last value. Parsing stops at the first malformed entry and returns
a BibParseError pinpointing the byte offset; well-formed input never
panics.
§Errors
Returns a BibParseError when the input is not a sequence of
well-formed @type{key, field = value, ...} entries separated by
whitespace: for example a missing @, entry type, {, citation key, or
=, or an unterminated brace/quote value.
§Examples
use mos_bib::parse_bibtex;
let bib = parse_bibtex("@article{rivest1978, author = {Ron Rivest}, year = 1978}")?;
assert_eq!(bib.entries["rivest1978"].fields["year"], "1978");