6 releases (3 breaking)

0.4.0 Oct 2, 2024
0.3.1 May 16, 2024
0.3.0 Mar 6, 2024
0.2.0 Mar 6, 2024
0.1.0 Oct 31, 2023

#1168 in Parser implementations

Download history 1001/week @ 2024-07-29 1120/week @ 2024-08-05 1005/week @ 2024-08-12 1303/week @ 2024-08-19 1283/week @ 2024-08-26 1328/week @ 2024-09-02 1170/week @ 2024-09-09 1306/week @ 2024-09-16 1732/week @ 2024-09-23 1802/week @ 2024-09-30 1842/week @ 2024-10-07 2652/week @ 2024-10-14 2470/week @ 2024-10-21 2062/week @ 2024-10-28 2181/week @ 2024-11-04 2243/week @ 2024-11-11

9,241 downloads per month
Used in 41 crates (via hayagriva)

MIT/Apache

205KB
4.5K SLoC

Citationberg

Crates.io Documentation Build status

Dinkelberg meme: Dad from the TV show The Fairly Odd Parents exclaiming Citationberg

A library for parsing CSL styles.

[dependencies]
citationberg = "0.4"

Citationberg deserializes CSL styles from XML into Rust structs. It supports CSL 1.0.2.

This crate is not a CSL processor, so you are free to choose whatever data model and data types you need for your bibliographic needs. If you need to render citations, you can use Hayagriva which uses this crate under the hood.

Parse your style like this:

use std::fs;
use citationberg::Style;

let string = fs::read_to_string("tests/independent/ieee.csl")?;
let style = citationberg::Style::from_xml(&string)?;

let Style::Independent(independent) = style else {
    panic!("IEEE is an independent style");
};

assert_eq!(independent.info.title.value, "IEEE");

Be sure to check out the CSL styles and locales repositories into sibling folders of citationberg if you want to run the tests.

Safety

This crate forbids unsafe code.

License

This crate is dual-licensed under the MIT and Apache 2.0 licenses.

Dependencies

~1.5–2.3MB
~43K SLoC