pandoc_ast

Crates.iopandoc_ast
lib.rspandoc_ast
version0.8.6
sourcesrc
created_at2015-08-14 15:42:06.082855
updated_at2024-01-03 12:36:51.697449
descriptiondeserializes and serializes the markdown ast for writing pandoc filters
homepage
repositoryhttps://github.com/oli-obk/pandoc-ast
max_upload_size
id2838
size44,983
Oli Scherer (oli-obk)

documentation

README

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();
}
Commit count: 70

cargo fmt