4 releases (2 breaking)

0.3.0 Mar 6, 2024
0.2.0 Mar 6, 2024
0.1.1 Nov 24, 2023
0.1.0 Oct 31, 2023

#425 in Parser implementations

Download history 496/week @ 2023-12-18 373/week @ 2023-12-25 732/week @ 2024-01-01 941/week @ 2024-01-08 1034/week @ 2024-01-15 783/week @ 2024-01-22 721/week @ 2024-01-29 843/week @ 2024-02-05 1127/week @ 2024-02-12 641/week @ 2024-02-19 815/week @ 2024-02-26 1747/week @ 2024-03-04 2159/week @ 2024-03-11 1448/week @ 2024-03-18 1066/week @ 2024-03-25 1060/week @ 2024-04-01

6,096 downloads per month
Used in 19 crates (via hayagriva)

MIT/Apache

200KB
4K 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.3"

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.6–2.3MB
~45K SLoC