7 releases (breaking)

0.6.0 Feb 11, 2023
0.5.0 Feb 7, 2022
0.4.0 Jul 7, 2021
0.3.3 May 26, 2020
0.1.0 Feb 26, 2017

#504 in Text processing

Download history 72/week @ 2023-12-10 61/week @ 2023-12-17 136/week @ 2023-12-24 21/week @ 2023-12-31 12/week @ 2024-01-07 1/week @ 2024-01-14 6/week @ 2024-01-28 17/week @ 2024-02-04 64/week @ 2024-02-11 160/week @ 2024-02-18 130/week @ 2024-02-25 99/week @ 2024-03-03 50/week @ 2024-03-10 48/week @ 2024-03-17 70/week @ 2024-03-24

277 downloads per month

Apache-2.0

33KB
701 lines

Rust port of pandoc-types Build status

This library provides a Rust port of the pandoc-types Haskell package.

To install, add the following to your Cargo.toml:

[dependencies]
pandoc_types = "0.6"

What this library is for

The purpose of pandoc-types is to allow Rust programs to natively manipulate Pandoc documents. Using this library, Rust programs should be able to create and modify Pandoc documents in a principled way (i.e. via ASTs, not text). This library can also be used along with serde_json to serialize and deserialize Pandoc documents to and from Pandoc's JSON format.

What this library is NOT for

This library does not provide a way of calling the Pandoc executable itself. If that's what you're looking for, consider the rust-pandoc library.

Compatibility

The current version is compatible with Haskell pandoc-types 1.23. This is the most recent version at the time of writing.

If you require support for a previous version of pandoc-types, please refer to the following support table to determine which version to use:

Rust Version pandoc-types Version pandoc Versions
0.6 1.23 3.0–
0.5 1.22 2.11–2.19
0.4 1.22 2.11–2.19
0.3 1.20 2.8–2.9
0.2 1.17 1.18–2.7
0.1 1.17 1.18–2.7

Supported modules

The following modules from pandoc-types are supported:

  • Haskell Text.Pandoc.Definition (as pandoc_types::definition in Rust)

Note that Text.Pandoc.JSON is unnecessary in Rust because all types implement Serialize and Deserialize from serde and can be used directly with serde_json.

Example usage

let para = Block::Para(vec![Inline::Str("b".to_owned())]);

let s = serde_json::to_string(&para)?;
println!("serialized = {}", s);

let d: Block = serde_json::from_str(&s)?;
println!("deserialized = {:?}", d);

For a full example, see examples/definition.rs.

License

This library is licensed under the Apache License, Version 2.0 (see LICENSE.txt).

Dependencies

~1.2–1.6MB
~39K SLoC