#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

#1316 in Parser implementations

Download history 4/week @ 2023-12-18 2/week @ 2023-12-25 20/week @ 2024-01-01 4/week @ 2024-02-05 15/week @ 2024-02-12 134/week @ 2024-02-19 90/week @ 2024-02-26 48/week @ 2024-03-04 36/week @ 2024-03-11 19/week @ 2024-03-18 24/week @ 2024-03-25 129/week @ 2024-04-01

219 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.4MB
~33K SLoC