18 releases

0.10.0 Oct 2, 2024
0.9.3 Mar 7, 2024
0.9.1 Nov 29, 2023
0.8.0 Apr 4, 2023
0.3.0 Sep 13, 2020

#150 in Parser implementations

Download history 1260/week @ 2024-07-23 1138/week @ 2024-07-30 1295/week @ 2024-08-06 1259/week @ 2024-08-13 1383/week @ 2024-08-20 1438/week @ 2024-08-27 1607/week @ 2024-09-03 1291/week @ 2024-09-10 1425/week @ 2024-09-17 1777/week @ 2024-09-24 2081/week @ 2024-10-01 2052/week @ 2024-10-08 3147/week @ 2024-10-15 2323/week @ 2024-10-22 2369/week @ 2024-10-29 2255/week @ 2024-11-05

10,487 downloads per month
Used in 48 crates (7 directly)

MIT/Apache

205KB
5K SLoC

BibLaTeX

Build status Current crates.io release Documentation

A Rust crate for parsing and writing BibTeX and BibLaTeX files.

BibLaTeX can help you to parse .bib bibliography files. As opposed to other available crates, this crate attempts to parse the data within the fields into easily usable structs and enums like Person and Date for downstream consumption.

Usage

Add this to your Cargo.toml:

[dependencies]
biblatex = "0.10"

Parsing a bibliography and getting the author of an item is as simple as:

let src = "@book{tolkien1937, author = {J. R. R. Tolkien}}";
let bibliography = Bibliography::parse(src).unwrap();
let entry = bibliography.get("tolkien1937").unwrap();
let author = entry.author().unwrap();
assert_eq!(author[0].name, "Tolkien");

This library operates on a Bibliography struct, which is a collection of entries (the items in your .bib file that start with an @ and are wrapped in curly braces). The entries may hold multiple fields. Entries have getter methods for each of the possible fields in a Bib(La)TeX file which handle possible field aliases, composition and type conversion automatically.

Refer to the WikiBook section on LaTeX bibliography management and the BibLaTeX package manual to learn more about the intended meaning of each of the fields.

The generated documentation more specifically describes the selection and behavior of the getters but generally, they follow the convention of being the snake-case name of the corresponding field (such that the getter for booktitleaddon is named book_title_addon).

Limitations

This library attempts to provide fairly comprehensive coverage of the BibLaTeX spec with which most of the .bib files in circulation can be processed.

However, the crate currently has some limitations:

  • There is no explicit support for entry sets, although it is easy to account for them by manually getting the entryset field and calling parse::<Vec<String>>() on it

Dependencies

~1.2–1.8MB
~53K SLoC