Skip to main content

highlight_code_blocks

Function highlight_code_blocks 

Source
pub fn highlight_code_blocks(html: &str, theme: SyntaxTheme) -> String
Expand description

Highlight all <pre><code class="language-..."> blocks in rendered HTML.

Each recognized block is replaced with <div class="code-block-wrapper"><pre class="syntax-highlight" data-language="..." data-theme="...">…</pre> plus a copy-to-clipboard button, matching the docs-site rendering pipeline. The theme is stamped on the output as data-theme so downstream CSS can restyle per theme. Blocks with unknown or unsupported languages are left untouched.