#pandoc #ast #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

#1627 in Parser implementations

Download history 36/week @ 2024-03-11 19/week @ 2024-03-18 24/week @ 2024-03-25 129/week @ 2024-04-01 25/week @ 2024-04-08 30/week @ 2024-04-15 30/week @ 2024-04-22 23/week @ 2024-04-29 24/week @ 2024-05-06 46/week @ 2024-05-13 49/week @ 2024-05-20 33/week @ 2024-05-27 36/week @ 2024-06-03 36/week @ 2024-06-10 26/week @ 2024-06-17 42/week @ 2024-06-24

142 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.5MB
~34K SLoC