pub trait SyntaxHighlighterAdapter: Send + Sync {
// Required methods
fn write_highlighted(
&self,
output: &mut dyn Write,
lang: Option<&str>,
code: &str,
) -> Result<(), Error>;
fn write_pre_tag(
&self,
output: &mut dyn Write,
attributes: HashMap<String, String>,
) -> Result<(), Error>;
fn write_code_tag(
&self,
output: &mut dyn Write,
attributes: HashMap<String, String>,
) -> Result<(), Error>;
}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<(), Error>
fn write_highlighted( &self, output: &mut dyn Write, lang: Option<&str>, code: &str, ) -> Result<(), Error>
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<(), Error>
fn write_pre_tag( &self, output: &mut dyn Write, attributes: HashMap<String, String>, ) -> Result<(), Error>
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<(), Error>
fn write_code_tag( &self, output: &mut dyn Write, attributes: HashMap<String, String>, ) -> Result<(), Error>
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.