nom_bibtex/lib.rs
1//! A feature complete *BibTeX* parser using [nom](https://github.com/Geal/nom).
2//!
3//! **nom-bibtex** can parse the four differents types of entries listed in the
4//! [BibTeX format description](http://www.bibtex.org/Format/):
5//!
6//! - Preambles which allows to call *LaTeX* command inside your *BibTeX*.
7//! - Strings which defines abbreviations in a key-value format.
8//! - Comments.
9//! - Bibliography entries.
10//!
11//! ## Example
12//!
13//! ```
14//! extern crate nom_bibtex;
15//! use nom_bibtex::*;
16//!
17//! const BIBFILE_DATA: &str = r#"@preamble{
18//! "A bibtex preamble" # " another test"
19//! }
20//!
21//! @Comment{
22//! Here is a comment.
23//! }
24//!
25//! Another comment!
26//!
27//! @string ( name= "Charles Vandevoorde")
28//! @string (github = "https://github.com/charlesvdv")
29//!
30//! @misc {my_citation_key,
31//! author= name,
32//! title = "nom-bibtex",
33//! note = "Github: " # github
34//! }
35//! "#;
36//!
37//! fn main() {
38//! let bibtex = Bibtex::parse(BIBFILE_DATA).unwrap();
39//!
40//! let preambles = bibtex.preambles();
41//! assert_eq!(preambles[0], "A bibtex preamble another test");
42//!
43//! let comments = bibtex.comments();
44//! assert_eq!(comments[0], "Here is a comment.");
45//! assert_eq!(comments[1], "Another comment!");
46//!
47//! let variables = bibtex.variables();
48//! assert_eq!(variables["name"], "Charles Vandevoorde");
49//! assert_eq!(variables["github"], "https://github.com/charlesvdv");
50//!
51//! let biblio = &bibtex.bibliographies()[0];
52//! assert_eq!(biblio.entry_type(), "misc");
53//! assert_eq!(biblio.citation_key(), "my_citation_key");
54//!
55//! let bib_tags = biblio.tags();
56//! assert_eq!(bib_tags["author"], "Charles Vandevoorde");
57//! assert_eq!(bib_tags["title"], "nom-bibtex");
58//! assert_eq!(bib_tags["note"], "Github: https://github.com/charlesvdv");
59//! }
60//! ```
61//!
62extern crate quick_error;
63
64pub mod error;
65pub mod model;
66mod parser;
67
68pub use model::{Bibliography, Bibtex};
69pub use parser::Entry;