Skip to main content

highlight_code

Function highlight_code 

Source
pub fn highlight_code(code: &str, extension: &str) -> Result<String, CoreError>
Expand description

Syntax highlight code using syntect, returning an HTML string.

Falls back to plain text if the extension is not recognized. The returned HTML is wrapped in <pre><code> if not already wrapped.