https://github.com/typst/citationberg
A library for parsing CSL styles.
https://github.com/typst/citationberg
bibliography citation-style-language citations csl xml
Last synced: about 1 month ago
JSON representation
A library for parsing CSL styles.
- Host: GitHub
- URL: https://github.com/typst/citationberg
- Owner: typst
- License: apache-2.0
- Created: 2023-06-02T10:17:16.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2025-03-07T21:44:10.000Z (3 months ago)
- Last Synced: 2025-04-03T21:12:08.079Z (3 months ago)
- Topics: bibliography, citation-style-language, citations, csl, xml
- Language: Rust
- Homepage:
- Size: 249 KB
- Stars: 41
- Watchers: 4
- Forks: 11
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# Citationberg
[](https://crates.io/crates/citationberg)
[](https://docs.rs/citationberg)
[](https://github.com/typst/citationberg/actions)
![]()
A library for parsing CSL styles.
```toml
[dependencies]
citationberg = "0.5"
```Citationberg deserializes CSL styles from XML into Rust structs. It supports
[CSL 1.0.2](https://docs.citationstyles.org/en/stable/specification.html).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](https://github.com/typst/hayagriva) which
uses this crate under the hood.Parse your style like this:
```rust
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](https://github.com/citation-style-language/styles) and
[locales](https://github.com/citation-style-language/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.