This library is created to create Pandoc filters with Rust.
To use this library add the line:
pandoc = { git = "https://github.com/rloic/pandoc", branch = "pandoc/1.23" }
To your cargo file.
Let be a filter examble.rs
:
use std::io;
use pandoc::definition::Inline;
use pandoc::to_json_filter;
fn caps(inline: Inline) -> Inline {
match inline {
Inline::Str(text) => Inline::Str(text.to_uppercase()),
_ => inline
}
}
fn main() -> io::Result<()> {
to_json_filter(&mut caps)
}
We can compile this filter with:
cargo build --bin example
To use the filter with Pandoc use:
pandoc -f markdown -t markdown --filter ./target/debug/example example.md
will print:
# HELLO