#[derive(Debug, Clone)]
pub struct HtmlRendererOptions {
pub xhtml: bool,
pub soft_break: String,
pub hard_break: String,
pub highlight: bool,
pub sanitize: bool,
pub convert_md_links: bool,
pub base_url: String,
pub source_path: String,
pub code_annotations: bool,
pub code_annotation_meta_key: String,
pub code_annotation_syntax: CodeAnnotationSyntax,
pub code_annotation_default_line_numbers: bool,
pub toc_max_depth: u8,
pub autolink_urls: bool,
pub autolink_patterns: Vec<String>,
pub autolink_target_blank: bool,
}
impl HtmlRendererOptions {
#[must_use]
pub fn new() -> Self {
Self {
xhtml: false,
soft_break: "\n".to_string(),
hard_break: "<br>\n".to_string(),
highlight: false,
sanitize: false,
convert_md_links: false,
base_url: "/".to_string(),
source_path: String::new(),
code_annotations: false,
code_annotation_meta_key: "annotate".to_string(),
code_annotation_syntax: CodeAnnotationSyntax::Attribute,
code_annotation_default_line_numbers: false,
toc_max_depth: 3,
autolink_urls: false,
autolink_patterns: Vec::from([String::from("http://"), String::from("https://")]),
autolink_target_blank: true,
}
}
}
impl Default for HtmlRendererOptions {
fn default() -> Self {
Self::new()
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum CodeAnnotationSyntax {
Attribute,
VitePress,
Both,
}
impl CodeAnnotationSyntax {
pub(super) fn includes_attribute(self) -> bool {
matches!(self, Self::Attribute | Self::Both)
}
pub(super) fn includes_vitepress(self) -> bool {
matches!(self, Self::VitePress | Self::Both)
}
}