pub struct HtmlConfig {Show 15 fields
pub enable_syntax_highlighting: bool,
pub syntax_theme: Option<String>,
pub minify_output: bool,
pub add_aria_attributes: bool,
pub generate_structured_data: bool,
pub max_input_size: usize,
pub language: String,
pub generate_toc: bool,
pub allow_unsafe_html: bool,
pub sanitize_html: bool,
pub generate_full_document: bool,
pub max_buffer_size: usize,
pub encoding: String,
pub enable_math: bool,
pub enable_diagrams: bool,
}Expand description
Configuration options for HTML generation.
Controls various aspects of the HTML generation process including syntax highlighting, accessibility features, and output formatting.
§Examples
use html_generator::HtmlConfig;
let cfg = HtmlConfig::default();
assert!(cfg.add_aria_attributes);
assert_eq!(cfg.language, "en-GB");Fields§
§enable_syntax_highlighting: boolEnable syntax highlighting for code blocks
syntax_theme: Option<String>Theme to use for syntax highlighting
minify_output: boolMinify the generated HTML output
add_aria_attributes: boolAutomatically add ARIA attributes for accessibility
generate_structured_data: boolGenerate structured data (JSON-LD) based on content
max_input_size: usizeMaximum size (in bytes) for input content
language: StringLanguage for generated content
generate_toc: boolEnable table of contents generation
allow_unsafe_html: boolAllow raw HTML passthrough in Markdown conversion.
When false (the default), raw HTML tags in Markdown input are
stripped from the output, preventing XSS when processing
untrusted content. Set to true only when the Markdown source
is fully trusted.
sanitize_html: boolSanitize raw HTML using ammonia instead of stripping it.
When true and allow_unsafe_html is also true, the library
runs ammonia over the final output to strip dangerous elements
(<script>, onclick, etc.) while preserving safe tags like
<div>, <span>, and <img>. This provides a secure
middle-ground for user-authored HTML.
Has no effect when allow_unsafe_html is false (HTML is
already stripped by the Markdown renderer).
generate_full_document: boolWrap output in a full HTML5 document.
When true, the pipeline wraps the generated body in:
<!DOCTYPE html>
<html lang="{language}">
<head><meta charset="utf-8"><title>…</title>{meta}{json-ld}</head>
<body>{content}</body>
</html>SEO meta tags and JSON-LD are placed in <head>, and the
language field is injected as the lang attribute. When
false (the default), only an HTML fragment is returned.
max_buffer_size: usizeMaximum buffer size for file I/O operations (default: 16MB).
Controls the upper bound on buffer allocation when reading input files. Adjust this if you need to process unusually large documents or want to constrain memory usage.
encoding: StringThe encoding for file I/O (defaults to “utf-8”).
This field is used by markdown_file_to_html when reading
or writing files. In-memory functions ignore it.
enable_math: boolRender $..$ and $$..$$ LaTeX math spans to inline MathML.
Pure server-side: no client-side JavaScript bundle required,
browsers render MathML natively. Powered by pulldown-latex
behind the math feature (on by default). When false, math
spans are passed through as-is.
enable_diagrams: boolRewrite \u{60}\u{60}\u{60}mermaid fenced code blocks for client-side
mermaid.js.
The CommonMark engine emits these as
<pre><code class="language-mermaid">…</code></pre>. With this
flag on, the post-processing step rewrites them to
<pre class="mermaid">…</pre> so the standard mermaid.js
loader picks them up. The page must still include
<script type="module">…mermaid.initialize…</script> for the
diagrams to actually render.
Implementations§
Source§impl HtmlConfig
impl HtmlConfig
Sourcepub fn builder() -> HtmlConfigBuilder
pub fn builder() -> HtmlConfigBuilder
Creates a new HtmlConfig using the builder pattern.
§Examples
use html_generator::HtmlConfig;
let config = HtmlConfig::builder()
.with_syntax_highlighting(true, Some("monokai".to_string()))
.with_language("en-GB")
.build()
.unwrap();Sourcepub fn validate(&self) -> Result<()>
pub fn validate(&self) -> Result<()>
Validates the configuration settings.
Checks that all configuration values are within acceptable ranges and conform to required formats.
§Returns
Returns Ok(()) if the configuration is valid, or an appropriate
error if validation fails.
§Examples
use html_generator::HtmlConfig;
let cfg = HtmlConfig::default();
cfg.validate().unwrap();§Errors
Returns crate::error::HtmlError::InvalidInput if language
is not a valid BCP 47 code or max_input_size is below
constants::MIN_INPUT_SIZE.
Trait Implementations§
Source§impl Clone for HtmlConfig
impl Clone for HtmlConfig
Source§fn clone(&self) -> HtmlConfig
fn clone(&self) -> HtmlConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for HtmlConfig
impl Debug for HtmlConfig
Source§impl Default for HtmlConfig
impl Default for HtmlConfig
Source§impl From<MarkdownConfig> for HtmlConfig
impl From<MarkdownConfig> for HtmlConfig
Source§fn from(mc: MarkdownConfig) -> Self
fn from(mc: MarkdownConfig) -> Self
Source§impl PartialEq for HtmlConfig
impl PartialEq for HtmlConfig
impl Eq for HtmlConfig
impl StructuralPartialEq for HtmlConfig
Auto Trait Implementations§
impl Freeze for HtmlConfig
impl RefUnwindSafe for HtmlConfig
impl Send for HtmlConfig
impl Sync for HtmlConfig
impl Unpin for HtmlConfig
impl UnsafeUnpin for HtmlConfig
impl UnwindSafe for HtmlConfig
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg or
a color-specific method, such as OwoColorize::green, Read moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg or
a color-specific method, such as OwoColorize::on_yellow, Read more