pub enum Node {
Show 35 variants
Root(Root),
Fragment(Fragment),
Blockquote(Blockquote),
FootnoteDefinition(FootnoteDefinition),
MdxJsxFlowElement(MdxJsxFlowElement),
List(List),
MdxjsEsm(MdxjsEsm),
Toml(Toml),
Yaml(Yaml),
Break(Break),
InlineCode(InlineCode),
InlineMath(InlineMath),
Delete(Delete),
Emphasis(Emphasis),
MdxTextExpression(MdxTextExpression),
FootnoteReference(FootnoteReference),
Html(Html),
Image(Image),
ImageReference(ImageReference),
MdxJsxTextElement(MdxJsxTextElement),
Link(Link),
LinkReference(LinkReference),
Strong(Strong),
Text(Text),
Code(Code),
Math(Math),
MdxFlowExpression(MdxFlowExpression),
Heading(Heading),
Table(Table),
ThematicBreak(ThematicBreak),
TableRow(TableRow),
TableCell(TableCell),
ListItem(ListItem),
Definition(Definition),
Paragraph(Paragraph),
}Expand description
Nodes.
Variants§
Root(Root)
Root.
Fragment(Fragment)
A transparent fragment containing a sequence of nodes.
Fragments are useful for holding children extracted from another node.
Blockquote(Blockquote)
Block quote.
FootnoteDefinition(FootnoteDefinition)
Footnote definition.
MdxJsxFlowElement(MdxJsxFlowElement)
MDX: JSX element (container).
List(List)
List.
MdxjsEsm(MdxjsEsm)
MDX.js ESM.
Toml(Toml)
Toml.
Yaml(Yaml)
Yaml.
Break(Break)
Break.
InlineCode(InlineCode)
Code (phrasing).
InlineMath(InlineMath)
Math (phrasing).
Delete(Delete)
Delete.
Emphasis(Emphasis)
Emphasis.
MdxTextExpression(MdxTextExpression)
FootnoteReference(FootnoteReference)
Footnote reference.
Html(Html)
Html (phrasing).
Image(Image)
Image.
ImageReference(ImageReference)
Image reference.
MdxJsxTextElement(MdxJsxTextElement)
Link(Link)
Link.
LinkReference(LinkReference)
Link reference.
Strong(Strong)
Strong
Text(Text)
Text.
Code(Code)
Code (flow).
Math(Math)
Math (flow).
MdxFlowExpression(MdxFlowExpression)
Heading(Heading)
Heading.
Table(Table)
Html (flow). Table.
ThematicBreak(ThematicBreak)
Thematic break.
TableRow(TableRow)
Table row.
TableCell(TableCell)
Table cell.
ListItem(ListItem)
List item.
Definition(Definition)
Definition.
Paragraph(Paragraph)
Paragraph.
Implementations§
Source§impl Node
impl Node
pub fn children(&self) -> Option<&Vec<Node>>
pub fn children_mut(&mut self) -> Option<&mut Vec<Node>>
pub fn position(&self) -> Option<&Position>
pub fn position_mut(&mut self) -> Option<&mut Position>
pub fn position_set(&mut self, position: Option<Position>)
Sourcepub fn walk<'a>(&'a self, visitor: impl FnMut(&'a Node))
pub fn walk<'a>(&'a self, visitor: impl FnMut(&'a Node))
Visit this node and its descendants in depth-first, pre-order.
Sourcepub fn walk_mut(&mut self, visitor: impl FnMut(&mut Node))
pub fn walk_mut(&mut self, visitor: impl FnMut(&mut Node))
Mutably visit this node and its descendants in depth-first, pre-order.
Sourcepub fn text_content(&self) -> String
pub fn text_content(&self) -> String
Return the concatenated text represented by this node.
Image nodes contribute their alt text and hard breaks contribute a newline. Structural nodes concatenate the text of their children.
Sourcepub fn find_heading(&self, title: &str) -> Option<&Node>
pub fn find_heading(&self, title: &str) -> Option<&Node>
Find a direct child heading with the requested text.
Sourcepub fn code_language(&self) -> Option<&str>
pub fn code_language(&self) -> Option<&str>
Return the language identifier of inline or fenced code.
Sourcepub fn code_info(&self) -> Option<String>
pub fn code_info(&self) -> Option<String>
Return code metadata for inline or fenced code.
Inline code metadata is its language token. Fenced code metadata is
reconstructed from lang and meta when either is present.
Sourcepub fn extract_children(&mut self) -> Option<Node>
pub fn extract_children(&mut self) -> Option<Node>
Take all direct children from this node and return them in a fragment.
Returns None for nodes that cannot contain children. The extracted
child nodes retain their own positions; the new fragment has no source
position of its own.
Sourcepub fn render_with<R: Renderer>(&self, renderer: &mut R) -> String
pub fn render_with<R: Renderer>(&self, renderer: &mut R) -> String
Render this node with a user-provided renderer.
Sourcepub fn to_markdown(&self) -> String
pub fn to_markdown(&self) -> String
Serialize this AST node or fragment as Markdown.
Markdown output ends with a newline. For custom formatting, use
to_markdown_with_options.
§Example
let markdown = node.to_markdown();Sourcepub fn to_markdown_with_options(
&self,
options: &Options,
) -> Result<String, Message>
pub fn to_markdown_with_options( &self, options: &Options, ) -> Result<String, Message>
Serialize this AST node or fragment as Markdown with custom options.
§Errors
Returns an error if an option contains an invalid marker or the AST contains a node that cannot be serialized.
Sourcepub fn replace_heading_section(
&mut self,
heading_index: usize,
replacement: Vec<Node>,
replace_heading: bool,
remove_subsections: bool,
) -> bool
pub fn replace_heading_section( &mut self, heading_index: usize, replacement: Vec<Node>, replace_heading: bool, remove_subsections: bool, ) -> bool
Replace a heading and the section below it in this node’s children.
heading_index is the direct-child index of the heading. When
replace_heading is false, the heading stays and only its section
content is replaced. When remove_subsections is true, nested heading
sections are included through the next heading of the same or higher
level. Returns false if the index is not a heading.