#[non_exhaustive]pub struct Node {
pub tag_name: Option<NodeType>,
pub value: Option<String>,
pub attributes: Option<Attributes>,
pub explicitly_self_closing: bool,
pub within_special_tag: Option<Vec<NodeType>>,
pub children: Vec<Node>,
}Expand description
A node in the parsed HTML tree.
This struct is non-exhaustive. Construct nodes with Node::new, then call
Node::with_explicit_self_closing when the source opening tag used />.
A tag_name of None represents a synthetic container for zero or multiple top-level nodes.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.tag_name: Option<NodeType>Element type, or None for a synthetic container.
value: Option<String>Text or comment content stored by this node.
attributes: Option<Attributes>Element attributes, when present.
explicitly_self_closing: boolWhether the source opening tag used explicit self-closing syntax (/>).
within_special_tag: Option<Vec<NodeType>>Parser-populated ancestor tags that affect list and blockquote formatting.
Manually constructed trees normally use None.
children: Vec<Node>Child nodes in source order.
Implementations§
Source§impl Node
impl Node
Sourcepub fn is_in_special_tag(&self, tags: &[NodeType]) -> bool
pub fn is_in_special_tag(&self, tags: &[NodeType]) -> bool
Returns whether this node is inside any supplied formatting-sensitive tag.
Sourcepub fn leading_spaces(&self) -> String
pub fn leading_spaces(&self) -> String
Returns indentation used when rendering nested list items.
Sourcepub fn new(
tag_name: Option<NodeType>,
value: Option<String>,
attributes: Option<Attributes>,
within_special_tag: Option<Vec<NodeType>>,
children: Vec<Node>,
) -> Self
pub fn new( tag_name: Option<NodeType>, value: Option<String>, attributes: Option<Attributes>, within_special_tag: Option<Vec<NodeType>>, children: Vec<Node>, ) -> Self
Creates a node that was not explicitly self-closing.
Use tag_name: None for a synthetic container. value is used by text and comment nodes;
manually constructed trees normally pass None for within_special_tag.
Sourcepub fn with_explicit_self_closing(self) -> Self
pub fn with_explicit_self_closing(self) -> Self
Marks this node as using explicit self-closing syntax (/>).
HTML void semantics are derived independently from NodeType, so <img> closes
immediately even when this flag is false.