use ecow::EcoString;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct HtmlWriterOptions {
pub code_block_language_class_prefix: Option<EcoString>,
#[cfg(feature = "gfm")]
pub enable_gfm: bool,
#[cfg(feature = "gfm")]
pub gfm_disallowed_html_tags: Vec<EcoString>,
pub strict: bool,
}
impl Default for HtmlWriterOptions {
fn default() -> Self {
Self {
code_block_language_class_prefix: Some("language-".into()),
#[cfg(feature = "gfm")]
enable_gfm: false, #[cfg(feature = "gfm")]
gfm_disallowed_html_tags: Vec::new(), strict: true, }
}
}
impl HtmlWriterOptions {
pub fn with_code_block_prefix<S: Into<EcoString>>(mut self, prefix: Option<S>) -> Self {
self.code_block_language_class_prefix = prefix.map(|p| p.into());
self
}
pub fn with_strict(mut self, strict: bool) -> Self {
self.strict = strict;
self
}
pub fn set_code_block_prefix<S: Into<EcoString>>(&mut self, prefix: Option<S>) {
self.code_block_language_class_prefix = prefix.map(|p| p.into());
}
pub fn set_strict(&mut self, strict: bool) {
self.strict = strict;
}
#[cfg(feature = "gfm")]
pub fn with_gfm_enabled(mut self, enable: bool) -> Self {
self.enable_gfm = enable;
self
}
#[cfg(feature = "gfm")]
pub fn set_gfm_enabled(&mut self, enable: bool) {
self.enable_gfm = enable;
}
#[cfg(feature = "gfm")]
pub fn with_gfm_disallowed_tags(mut self, tags: Vec<EcoString>) -> Self {
self.gfm_disallowed_html_tags = tags;
self
}
#[cfg(feature = "gfm")]
pub fn set_gfm_disallowed_tags(&mut self, tags: Vec<EcoString>) {
self.gfm_disallowed_html_tags = tags;
}
}