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, highlight: &SyntaxHighlightMeta<'_>) -> Result

Generates a syntax highlighted HTML output.

fn write_pre_tag(&self, output: &mut dyn Write, highlight: &SyntaxHighlightMeta<'_>, attributes: BTreeMap<&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, highlight: &SyntaxHighlightMeta<'_>, attributes: BTreeMap<&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.