citeproc-rs
An early-stage work-in-progress implementation of CSL and CSL-M in Rust. It is geared at:
- replacing
citeproc-jsby providing WebAssembly bindings such that it could be embedded in Zotero or fulfil any other JavaScript-based use; - replacing much of
pandoc-citeproc, by running as a Pandoc Filter; - providing a compiled static library to replace other divergent or incomplete implementations and make it easy to integrate citeproc into document processing pipelines and web services; and
- correctness and high performance.
Nearly every programming language in existence can link against a static C library; this effort is therefore also aimed at reducing the number of implementations to 1, thereby reducing the burden on implementers and making CSL evolution more nimble.
Currently, the codebase is evolving rapidly and if you submit a PR, chances are I've either already done it or made a change that breaks the subsystem you were working on. Or force-pushed on master. If you really want to contribute, let me know and we can sort something out.
Technology overview
Compiling requires Rust 2018 Edition with Cargo, i.e. stable version 1.31 or
later, or a nightly compiler. You should install it with
rustup.
- XML parsing with
roxmltree - Error reporting with
codespan - Little utility parsers written with
nom - Parallel processing using
rayon's work-stealing queues - JSON IO using
serde_json - Pandoc-JSON interop using
pandoc_types.
Try it out!
Currently it can:
- parse a CSL style (ignoring
<info>,<style-options>, and<bibliography>) with built-in validation, type-checking, error reporting, and semantic versioning, - parse a CSL-M style (ignoring
<info>,<style-options>, and<bibliography>, missing many undocumentedciteproc-jsextensions to the spec), - parse a CSL-JSON file
- pluck out the first reference, and execute the style against only that one
- output valid Pandoc JSON that can be converted to HTML
git clone https://github.com/cormacrelf/citeproc-rs
cd citeproc-rs/citeproc
cargo run -- --csl ../example.csl # runs on a predefined single ref
cargo run -- --csl ../example.csl --library path/to/csl-json/file.jsonTo test it across the entire styles repo:
cd citeproc-rs/citeproc
cargo install --path . --force
cd ../..
git clone https://github.com/citation-style-language/styles
for style in styles/*.csl; do citeproc-rs --csl $style | pandoc -f json -t html; done- Some styles in the repo are possibly invalid (mostly for using terms that aren't actually listed in the terms in the spec, namely number variables).
- Some will successfully output HTML!
- Many styles will panic when accessing locales, as most locale lookups are
just
.get("en-GB").unwrap()on the inline locales instead of using a merged locale.