//! HTML output formatter with math rendering support use super::{HtmlEngine, LineData}; /// HTML formatter with math rendering pub struct HtmlFormatter { engine: HtmlEngine, css_styling: bool, accessibility: bool, responsive: bool, theme: HtmlTheme, } #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum HtmlTheme { Light, Dark, Auto, } impl HtmlFormatter { pub fn new() -> Self { Self { engine: HtmlEngine::MathJax, css_styling: true, accessibility: true, responsive: true, theme: HtmlTheme::Light, } } pub fn with_engine(mut self, engine: HtmlEngine) -> Self { self.engine = engine; self } pub fn with_styling(mut self, styling: bool) -> Self { self.css_styling = styling; self } pub fn accessibility(mut self, enabled: bool) -> Self { self.accessibility = enabled; self } pub fn responsive(mut self, enabled: bool) -> Self { self.responsive = enabled; self } pub fn theme(mut self, theme: HtmlTheme) -> Self { self.theme = theme; self } /// Format content to HTML pub fn format(&self, content: &str, lines: Option<&[LineData]>) -> String { let mut html = String::new(); // HTML header with math rendering scripts html.push_str(&self.html_header()); // Body start with theme class html.push_str("
\n"); // Main content container html.push_str(r#"