pub enum Node {
Show 25 variants
Document(Vec<Node>),
ThematicBreak,
Heading {
level: u8,
content: Vec<Node>,
heading_type: HeadingType,
},
CodeBlock {
language: Option<EcoString>,
content: EcoString,
block_type: CodeBlockType,
},
HtmlBlock(EcoString),
LinkReferenceDefinition {
label: EcoString,
destination: EcoString,
title: Option<EcoString>,
},
Paragraph(Vec<Node>),
BlockQuote(Vec<Node>),
OrderedList {
start: u32,
items: Vec<ListItem>,
},
UnorderedList(Vec<ListItem>),
Table {
headers: Vec<Node>,
rows: Vec<Vec<Node>>,
},
InlineCode(EcoString),
Emphasis(Vec<Node>),
Strong(Vec<Node>),
Strikethrough(Vec<Node>),
Link {
url: EcoString,
title: Option<EcoString>,
content: Vec<Node>,
},
ReferenceLink {
label: EcoString,
content: Vec<Node>,
},
Image {
url: EcoString,
title: Option<EcoString>,
alt: Vec<Node>,
},
Autolink {
url: EcoString,
is_email: bool,
},
ExtendedAutolink(EcoString),
HtmlElement(HtmlElement),
HardBreak,
SoftBreak,
Text(EcoString),
Custom(Box<dyn CustomNode>),
}Expand description
Main node type, representing an element in a CommonMark document
Variants§
Document(Vec<Node>)
Root document node, contains child nodes
ThematicBreak
Thematic break (horizontal rule)
Heading
Heading, contains level (1-6) and inline content
Fields
heading_type: HeadingTypeHeading type (ATX or Setext)
CodeBlock
Code block, containing optional language identifier and content
Fields
language: Option<EcoString>Optional language identifier (None for indented code blocks, Some for fenced code blocks)
block_type: CodeBlockTypeThe type of code block (Indented or Fenced)
HtmlBlock(EcoString)
HTML block
LinkReferenceDefinition
Link reference definition
Fields
Paragraph(Vec<Node>)
Paragraph node, containing inline elements
BlockQuote(Vec<Node>)
Block quote, containing any block-level elements
OrderedList
Ordered list, containing starting number and list items
UnorderedList(Vec<ListItem>)
Unordered list, containing list items
Table
Table (extension to CommonMark)
Fields
InlineCode(EcoString)
Inline code
Emphasis(Vec<Node>)
Emphasis (italic)
Strong(Vec<Node>)
Strong emphasis (bold)
Strikethrough(Vec<Node>)
Strikethrough (GFM extension)
Link
Link
Fields
ReferenceLink
Reference link
Fields
Image
Image
Fields
Autolink
Autolink (URI or email wrapped in < and >)
ExtendedAutolink(EcoString)
GFM Extended Autolink (without angle brackets, automatically detected)
HtmlElement(HtmlElement)
HTML inline element
HardBreak
Hard break (two spaces followed by a line break, or backslash followed by a line break)
SoftBreak
Soft break (single line break)
Text(EcoString)
Plain text
Custom(Box<dyn CustomNode>)
Custom node that allows users to implement their own writing behavior
Implementations§
Source§impl Node
impl Node
Sourcepub fn code_block(language: Option<EcoString>, content: EcoString) -> Self
pub fn code_block(language: Option<EcoString>, content: EcoString) -> Self
Sourcepub fn strikethrough(content: Vec<Node>) -> Self
pub fn strikethrough(content: Vec<Node>) -> Self
Sourcepub fn as_custom_type<T: CustomNode + 'static>(&self) -> Option<&T>
pub fn as_custom_type<T: CustomNode + 'static>(&self) -> Option<&T>
Check if a custom node is of a specific type, and return a reference to that type
Sourcepub fn is_custom_type<T: CustomNode + 'static>(&self) -> bool
pub fn is_custom_type<T: CustomNode + 'static>(&self) -> bool
Check if a node is a custom node of a specific type