Trait comrak::adapters::SyntaxHighlighterAdapter
source · pub trait SyntaxHighlighterAdapter: Send + Sync {
// Required methods
fn write_highlighted(
&self,
output: &mut dyn Write,
lang: Option<&str>,
code: &str
) -> Result<()>;
fn write_pre_tag(
&self,
output: &mut dyn Write,
attributes: HashMap<String, String>
) -> Result<()>;
fn write_code_tag(
&self,
output: &mut dyn Write,
attributes: HashMap<String, String>
) -> Result<()>;
}
Expand description
Implement this adapter for creating a plugin for custom syntax highlighting of codefence blocks.
Required Methods§
sourcefn write_highlighted(
&self,
output: &mut dyn Write,
lang: Option<&str>,
code: &str
) -> Result<()>
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.
sourcefn write_pre_tag(
&self,
output: &mut dyn Write,
attributes: HashMap<String, String>
) -> Result<()>
fn write_pre_tag( &self, output: &mut dyn Write, attributes: HashMap<String, String> ) -> 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.
sourcefn write_code_tag(
&self,
output: &mut dyn Write,
attributes: HashMap<String, String>
) -> Result<()>
fn write_code_tag( &self, output: &mut dyn Write, attributes: HashMap<String, String> ) -> 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.