Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 4 days 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 (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-10-02T11:31:49.000Z (4 months ago)
- Last Synced: 2025-01-11T15:06:58.000Z (11 days ago)
- Topics: bibliography, citation-style-language, citations, csl, xml
- Language: Rust
- Homepage:
- Size: 200 KB
- Stars: 38
- Watchers: 3
- Forks: 8
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# Citationberg
[![Crates.io](https://img.shields.io/crates/v/citationberg.svg)](https://crates.io/crates/citationberg)
[![Documentation](https://docs.rs/citationberg/badge.svg)](https://docs.rs/citationberg)
[![Build status](https://github.com/typst/citationberg/workflows/Continuous%20integration/badge.svg)](https://github.com/typst/citationberg/actions)
A library for parsing CSL styles.
```toml
[dependencies]
citationberg = "0.4"
```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.