typst / biblatex

A Rust crate for parsing and writing BibTeX and BibLaTeX files.
Apache License 2.0
120 stars 15 forks source link

Multiline author fields not parsed correctly #28

Closed justhsu closed 11 months ago

justhsu commented 1 year ago

Thank you for making this package. For bibtex entries where the author field has linebreaks, the authors aren't parsed correctly in some cases. Here is an example:

fn main() -> Result<(), Error> {
  let src = r#"
@article{Monroe,
  author = {
    Monroe, Brian Albert and
    Doe, John
  },
  title = {Estimating Beliefs by Event Space Bisection},
  year = {2022},
  }
"#;

    let biblio = Bibliography::parse(src).unwrap();
    let entry = biblio.get("Monroe").unwrap();
    let author = &entry.author().unwrap()[0];
    println!("name: ({}) given: ({}) prefix: ({}) suffix: ({})",
             author.name,
             author.given_name,
             author.prefix,
             author.suffix);

    Ok(())
}

This prints:

name: (Monroe) given: (John
  ) prefix: () suffix: (Brian Albert and
    Doe)

The problem seems to go away if in the bibtex file, we put a space after "and".