Skip to main content

highlight_code

Function highlight_code 

Source
pub fn highlight_code(code: &str, language: Option<&str>) -> String
Expand description

Apply syntax highlighting to code.

Returns HTML string with CSS classes for syntax highlighting. Token spans use classes like sy-keyword, sy-string, etc. that are styled via CSS custom properties (see syntax_highlight_css()). Falls back to plain escaped code if highlighting fails.