pub struct CommonMarkWriter {
pub options: WriterOptions,
pub buffer: EcoString,
/* private fields */
}Expand description
CommonMark writer responsible for serializing AST nodes to CommonMark text.
Fields§
§options: WriterOptionsWriter options.
buffer: EcoStringBuffer for storing the output text.
Implementations§
Source§impl CommonMarkWriter
impl CommonMarkWriter
Sourcepub fn with_options(options: WriterOptions) -> Self
pub fn with_options(options: WriterOptions) -> Self
Create a new CommonMark writer with specified options.
Sourcepub fn with_diagnostic_sink(
self,
sink: Box<dyn DiagnosticSink + 'static>,
) -> Self
pub fn with_diagnostic_sink( self, sink: Box<dyn DiagnosticSink + 'static>, ) -> Self
Replace the diagnostic sink used to capture non-fatal issues.
Sourcepub fn set_diagnostic_sink(&mut self, sink: Box<dyn DiagnosticSink + 'static>)
pub fn set_diagnostic_sink(&mut self, sink: Box<dyn DiagnosticSink + 'static>)
Swap the diagnostic sink on an existing writer.
Sourcepub fn diagnostic_sink(&mut self) -> &mut dyn DiagnosticSink
pub fn diagnostic_sink(&mut self) -> &mut dyn DiagnosticSink
Get a mutable handle to the diagnostic sink.
Sourcepub fn write(&mut self, node: &Node) -> WriteResult<()>
pub fn write(&mut self, node: &Node) -> WriteResult<()>
Write an AST node as CommonMark format.
Sourcepub fn into_string(self) -> EcoString
pub fn into_string(self) -> EcoString
Get the generated CommonMark format text.
Sourcepub fn write_str(&mut self, s: &str) -> WriteResult<()>
pub fn write_str(&mut self, s: &str) -> WriteResult<()>
Write a string to the output buffer.
Sourcepub fn write_char(&mut self, c: char) -> WriteResult<()>
pub fn write_char(&mut self, c: char) -> WriteResult<()>
Write a character to the output buffer.
Trait Implementations§
Source§impl Debug for CommonMarkWriter
impl Debug for CommonMarkWriter
Source§impl Default for CommonMarkWriter
impl Default for CommonMarkWriter
Source§impl NodeHandler for CommonMarkWriter
impl NodeHandler for CommonMarkWriter
Source§type Error = WriteError
type Error = WriteError
Error type produced during traversal.
fn document(&mut self, children: &[Node]) -> WriteResult<()>
fn paragraph(&mut self, content: &[Node]) -> WriteResult<()>
fn text(&mut self, text: &EcoString) -> WriteResult<()>
fn emphasis(&mut self, content: &[Node]) -> WriteResult<()>
fn strong(&mut self, content: &[Node]) -> WriteResult<()>
fn thematic_break(&mut self) -> WriteResult<()>
fn heading( &mut self, level: u8, content: &[Node], heading_type: &HeadingType, ) -> WriteResult<()>
fn inline_code(&mut self, code: &EcoString) -> WriteResult<()>
fn code_block( &mut self, language: &Option<EcoString>, content: &EcoString, block_type: &CodeBlockType, ) -> WriteResult<()>
fn html_block(&mut self, content: &EcoString) -> WriteResult<()>
fn html_element(&mut self, element: &HtmlElement) -> WriteResult<()>
fn block_quote(&mut self, content: &[Node]) -> WriteResult<()>
fn unordered_list(&mut self, items: &[ListItem]) -> WriteResult<()>
fn ordered_list(&mut self, start: u32, items: &[ListItem]) -> WriteResult<()>
fn table(&mut self, headers: &[Node], rows: &[Vec<Node>]) -> WriteResult<()>
fn link( &mut self, url: &EcoString, title: &Option<EcoString>, content: &[Node], ) -> WriteResult<()>
fn image( &mut self, url: &EcoString, title: &Option<EcoString>, alt: &[Node], ) -> WriteResult<()>
fn soft_break(&mut self) -> WriteResult<()>
fn hard_break(&mut self) -> WriteResult<()>
fn autolink(&mut self, url: &EcoString, is_email: bool) -> WriteResult<()>
fn link_reference_definition( &mut self, label: &EcoString, destination: &EcoString, title: &Option<EcoString>, ) -> WriteResult<()>
fn reference_link( &mut self, label: &EcoString, content: &[Node], ) -> WriteResult<()>
fn custom(&mut self, node: &dyn CustomNode) -> WriteResult<()>
fn unsupported(&mut self, node: &Node) -> WriteResult<()>
Auto Trait Implementations§
impl Freeze for CommonMarkWriter
impl !RefUnwindSafe for CommonMarkWriter
impl !Send for CommonMarkWriter
impl !Sync for CommonMarkWriter
impl Unpin for CommonMarkWriter
impl !UnwindSafe for CommonMarkWriter
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