pub struct BibEntry {
pub entry_type: String,
pub key: String,
pub key_span: Range<usize>,
pub fields: BTreeMap<String, String>,
}Expand description
A single parsed BibTeX entry: one @type{...} record.
The entry type and field names are normalized to lowercase, because
BibTeX treats them case-insensitively; the citation key is
preserved verbatim, because keys are case-sensitive. Fields live in a
BTreeMap, so fields iterates in sorted, stable
order. Values are stored as raw text exactly as written, outer {} or
"" delimiters included; bare values have none. A field name repeated
within one entry keeps its last value. No TeX decoding or name parsing.
§Examples
use mos_bib::parse_bibtex;
let bib = parse_bibtex("@article{knuth1984, title = {Literate Programming}}")?;
let entry = &bib.entries["knuth1984"];
assert_eq!(entry.entry_type, "article");
assert_eq!(entry.key, "knuth1984");
assert_eq!(entry.fields["title"], "{Literate Programming}");Fields§
§entry_type: StringThe entry type without the leading @, lowercased (e.g. article).
key: StringThe citation key, preserved verbatim (e.g. knuth1984).
key_span: Range<usize>Byte range of key inside the parsed BibTeX source.
fields: BTreeMap<String, String>Field name (lowercased) to raw value text including its outer delimiters, in sorted name order.
Implementations§
Source§impl BibEntry
impl BibEntry
Sourcepub fn field_text(&self, name: &str) -> Option<&str>
pub fn field_text(&self, name: &str) -> Option<&str>
A field’s value with its outer {} / "" delimiters removed; see
unwrap_value. Inner text is still raw (no TeX decoding).
§Examples
use mos_bib::parse_bibtex;
let bib = parse_bibtex(r#"@book{k, title = {The {TeX}book}, year = "1984"}"#)?;
let entry = &bib.entries["k"];
assert_eq!(entry.field_text("title"), Some("The {TeX}book"));
assert_eq!(entry.field_text("year"), Some("1984"));
assert_eq!(entry.field_text("pages"), None);