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 shallow_copy(&self) -> Node
pub fn shallow_copy(&self) -> Node
docutils Element.copy(): same kind, span and attributes, but no
children (docutils copies rawsource and attributes only;
deepcopy is the one that takes the subtree).
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§
Source§impl<'de> Deserialize<'de> for Node
impl<'de> Deserialize<'de> for Node
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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