pub struct HtmlWriterOptions {
pub code_block_language_class_prefix: Option<EcoString>,
pub strict: bool,
}Expand description
Options for configuring the HTML rendering process.
HtmlWriterOptions allows customizing how HTML is generated when rendering
CommonMark content. These options can be used directly with an HtmlWriter or
can be derived from a CommonMarkWriter’s options when rendering HTML elements
within CommonMark content.
§Example
use cmark_writer::{HtmlWriter, HtmlWriterOptions};
// Create custom HTML rendering options
let options = HtmlWriterOptions {
strict: true,
code_block_language_class_prefix: Some("language-".into()),
#[cfg(feature = "gfm")]
enable_gfm: true,
#[cfg(feature = "gfm")]
gfm_disallowed_html_tags: vec!["script".into()],
};
// Use the options with an HtmlWriter
let mut writer = HtmlWriter::with_options(options);Fields§
§code_block_language_class_prefix: Option<EcoString>A prefix for the class name applied to fenced code blocks. For example, if set to “lang-”, a Rust code block might get class “lang-rust”. If None, no language class is added.
strict: boolDetermines if HTML parsing/rendering errors should be strict (panic/Err) or lenient (warn and attempt to recover/textualize).
Implementations§
Source§impl HtmlWriterOptions
impl HtmlWriterOptions
Sourcepub fn with_code_block_prefix<S: Into<EcoString>>(
self,
prefix: Option<S>,
) -> Self
pub fn with_code_block_prefix<S: Into<EcoString>>( self, prefix: Option<S>, ) -> Self
Sets the code block language class prefix.
Sourcepub fn with_strict(self, strict: bool) -> Self
pub fn with_strict(self, strict: bool) -> Self
Sets strict mode.
Sourcepub fn set_code_block_prefix<S: Into<EcoString>>(&mut self, prefix: Option<S>)
pub fn set_code_block_prefix<S: Into<EcoString>>(&mut self, prefix: Option<S>)
Sets the code block language class prefix.
Sourcepub fn set_strict(&mut self, strict: bool)
pub fn set_strict(&mut self, strict: bool)
Sets strict mode.
Trait Implementations§
Source§impl Clone for HtmlWriterOptions
impl Clone for HtmlWriterOptions
Source§fn clone(&self) -> HtmlWriterOptions
fn clone(&self) -> HtmlWriterOptions
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for HtmlWriterOptions
impl Debug for HtmlWriterOptions
Source§impl Default for HtmlWriterOptions
impl Default for HtmlWriterOptions
Source§impl PartialEq for HtmlWriterOptions
impl PartialEq for HtmlWriterOptions
impl Eq for HtmlWriterOptions
impl StructuralPartialEq for HtmlWriterOptions
Auto Trait Implementations§
impl Freeze for HtmlWriterOptions
impl RefUnwindSafe for HtmlWriterOptions
impl Send for HtmlWriterOptions
impl Sync for HtmlWriterOptions
impl Unpin for HtmlWriterOptions
impl UnwindSafe for HtmlWriterOptions
Blanket Implementations§
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
Mutably borrows from an owned value. Read more