Crates.io | citationberg |
lib.rs | citationberg |
version | 0.4.0 |
source | src |
created_at | 2023-10-31 00:07:04.295418 |
updated_at | 2024-10-02 11:35:33.87568 |
description | A parser for CSL files |
homepage | |
repository | https://github.com/typst/citationberg |
max_upload_size | |
id | 1019214 |
size | 351,235 |
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.
This crate forbids unsafe code.
This crate is dual-licensed under the MIT and Apache 2.0 licenses.