Trait SyntaxHighlighterAdapter

pub trait SyntaxHighlighterAdapter: Send + Sync

Implement this adapter for creating a plugin for custom syntax highlighting of codefence blocks.

Required Methods

fn write_highlighted(&self, output: &mut dyn Write, lang: Option<&str>, code: &str) -> Result

Generates a syntax highlighted HTML output.

lang: Name of the programming language (the info string of the codefence block after the initial "```" part). code: The source code to be syntax highlighted.

fn write_pre_tag(&self, output: &mut dyn Write, attributes: HashMap<&'static str, Cow<'_, str>>) -> Result

Generates the opening <pre> tag. Some syntax highlighter libraries might include their own <pre> tag possibly with some HTML attribute pre-filled.

attributes: A map of HTML attributes provided by Comrak.

fn write_code_tag(&self, output: &mut dyn Write, attributes: HashMap<&'static str, Cow<'_, str>>) -> Result

Generates the opening <code> tag. Some syntax highlighter libraries might include their own <code> tag possibly with some HTML attribute pre-filled.

attributes: A map of HTML attributes provided by Comrak.