pub struct Node {
pub kind: &'static str,
pub span: Span,
pub text: Option<String>,
pub attrs: Attrs,
pub children: Vec<Node>,
}Expand description
One doctree node. Element nodes have text == None; text leaves have
kind == kinds::TEXT, Some(text), and no children or attributes.
Fields§
§kind: &'static str§span: Span§text: Option<String>§attrs: Attrs§children: Vec<Node>Implementations§
Source§impl Node
impl Node
pub fn elem(kind: &'static str, span: Span) -> Node
pub fn text_node(s: impl Into<String>, span: Span) -> Node
Sourcepub fn set(&mut self, key: &'static str, value: AttrValue)
pub fn set(&mut self, key: &'static str, value: AttrValue)
Set a scalar attribute, keeping attrs.extra sorted by key and
overwriting any existing value for the same key.
pub fn get(&self, key: &'static str) -> Option<&AttrValue>
Sourcepub fn astext(&self) -> String
pub fn astext(&self) -> String
Concatenated text of all text descendants.
Wave-1 simplification of docutils Node.astext(): children join with
"" (docutils joins with a per-element child_text_separator, which
only matters for elements wave 1 never calls astext on — revisit in
wave 2 when inline nodes need " " and table cells need "\n\n").
Trait Implementations§
impl StructuralPartialEq for Node
Auto Trait Implementations§
impl Freeze for Node
impl RefUnwindSafe for Node
impl Send for Node
impl Sync for Node
impl Unpin for Node
impl UnsafeUnpin for Node
impl UnwindSafe for Node
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more