cmark syntax highlighting

Crates.io status Docs

This crate provides a preprocessor for pulldown_cmark events that implements syntax highlighting. It is based on the work of Maciej Hirsz for the Ramhorns templating engine.

Supported languages

Files defining language syntax are located in src/languages directory. The syntax is defined using regexes, which the Logos procedural macro turns into a parser on compile time. PRs implementing new languages are very welcome!

Use

This preprocessor can be used as a callback for the Ramhorns templating engine. ```rust use ramhorns::encoding::Encoder;

pub fn encode(source: &str, encoder: &mut E) -> Result<(), E::Error> { let parser = pulldowncmark::Parser::new(source); let processed = cmarksyntax::SyntaxPreprocessor::new(parser); encoder.write_html(processed) } ```