#ast #pandoc #serialize-deserialize #filter #markdown #latex

pandoc_ast

deserializes and serializes the markdown ast for writing pandoc filters

23 releases

0.8.6 Jan 3, 2024
0.8.5 Aug 28, 2023
0.8.4 Feb 21, 2023
0.8.2 Jun 1, 2022
0.1.0 Aug 14, 2015

#2105 in Parser implementations

Download history 22/week @ 2024-07-20 29/week @ 2024-07-27 20/week @ 2024-08-03 25/week @ 2024-08-10 17/week @ 2024-08-17 20/week @ 2024-08-24 28/week @ 2024-08-31 20/week @ 2024-09-07 30/week @ 2024-09-14 89/week @ 2024-09-21 39/week @ 2024-09-28 11/week @ 2024-10-05 12/week @ 2024-10-12 17/week @ 2024-10-19 23/week @ 2024-10-26 17/week @ 2024-11-02

71 downloads per month
Used in 5 crates

MIT license

18KB
386 lines

This crate allows you to implement filters for pandoc. The easiest way is to them in conjunction with the pandoc crate. You can also create a binary that reads from stdin and writes to stdout and pass that to a normal pandoc call with --filter

Instructions

fn main() {
    let mut pandoc = pandoc::new();

    ...

    pandoc.add_filter(|json| pandoc_ast::filter(json, |mut pandoc| {
        for block in &mut pandoc.1 {
            use pandoc_ast::Block::*;
            *block = match *block {
                CodeBlock((_, ref kinds, _), _) if kinds.iter().next() == Some("graphviz") => {
                    // do something to change a graphviz block into an image
                }
            }
        }
        pandoc
    }));
    pandoc.execute().unwrap();
}

Dependencies

~0.7–1.6MB
~35K SLoC