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

#523 in Text processing

Download history 42/week @ 2024-06-24 47/week @ 2024-07-01 8/week @ 2024-07-08 31/week @ 2024-07-15 23/week @ 2024-07-22 27/week @ 2024-07-29 20/week @ 2024-08-05 28/week @ 2024-08-12 13/week @ 2024-08-19 34/week @ 2024-08-26 14/week @ 2024-09-02 22/week @ 2024-09-09 31/week @ 2024-09-16 106/week @ 2024-09-23 18/week @ 2024-09-30 10/week @ 2024-10-07

167 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
~34K SLoC