Skip to main content

apply_theme

Function apply_theme 

Source
pub fn apply_theme(html: &str, theme: &Theme, inline: bool) -> Result<String>
Expand description

Apply theme to HTML body content.

  • html - The HTML content (body only, no DOCTYPE)
  • theme - The theme to apply
  • inline - If true, inline all CSS into style attributes (for WeChat/copy-paste)

Returns themed HTML with CSS either inlined or as <style> block.

Note: No wrapper div is added. Theme CSS uses direct element selectors (e.g., h1, p) rather than .content h1 to ensure styles are inlined directly onto elements. This is required for platforms like WeChat that filter out <div> tags.