Skip to main content

Node

Enum Node 

Source
pub enum Node {
Show 18 variants Paragraph { children: Vec<Node>, }, Heading { level: u8, children: Vec<Node>, }, BulletList { items: Vec<Node>, }, OrderedList { start: u32, items: Vec<Node>, }, ListItem { checked: Option<bool>, children: Vec<Node>, }, Table { align: Vec<Align>, rows: Vec<Vec<TableCell>>, }, BlockQuote { children: Vec<Node>, }, ThematicBreak, CodeBlock { lang: Option<String>, code: String, }, Code { code: String, }, Emphasis { children: Vec<Node>, }, Strong { children: Vec<Node>, }, Strikethrough { children: Vec<Node>, }, Link { href: String, children: Vec<Node>, }, Image { src: String, alt: String, }, SoftBreak, LineBreak, Text { value: String, },
}
Expand description

One node of parsed markdown.

Shaped for a client to walk and turn into DOM nodes directly — every variant is either a container (children, or for a list or table, a nested collection) or a leaf that carries exactly the data needed to build one element. There is no HTML anywhere in this type; see the module documentation for the two places that turn attacker-controlled markup into plain Node::Text instead of a live link or image.

Variants§

§

Paragraph

A paragraph.

Fields

§children: Vec<Node>

Inline content.

§

Heading

A heading.

Fields

§level: u8

Heading level, 1 through 6.

§children: Vec<Node>

Inline content.

§

BulletList

An unordered (bullet) list.

Fields

§items: Vec<Node>

The list’s items. Always Node::ListItem.

§

OrderedList

An ordered (numbered) list.

Fields

§start: u32

The number the list starts counting from.

§items: Vec<Node>

The list’s items. Always Node::ListItem.

§

ListItem

One item of a list, or of a GFM task list.

Fields

§checked: Option<bool>

Some(true) for a checked task item, Some(false) for an unchecked one, None for a plain list item.

§children: Vec<Node>

The item’s block content, which may include a nested list.

§

Table

A GFM table.

Fields

§align: Vec<Align>

One alignment per column, in column order.

§rows: Vec<Vec<TableCell>>

Rows in reading order; the first is the header row.

§

BlockQuote

A block quote.

Fields

§children: Vec<Node>

The quote’s block content.

§

ThematicBreak

A horizontal rule (---).

§

CodeBlock

A fenced or indented code block.

Never syntax-highlighted: magi does not add a highlighting dependency, so lang is carried only as a label for the client to show, not as a hint the server has already acted on.

Fields

§lang: Option<String>

The fence’s info string (e.g. rust), if the source gave one.

§code: String

The block’s literal text.

§

Code

An inline code span.

Fields

§code: String

The span’s literal text.

§

Emphasis

Emphasized (*italic*) inline content.

Fields

§children: Vec<Node>

Inline content.

§

Strong

Strongly emphasized (**bold**) inline content.

Fields

§children: Vec<Node>

Inline content.

§

Strikethrough

Struck-through (~~text~~) inline content.

Fields

§children: Vec<Node>

Inline content.

A link. Only ever produced for an http:/https: destination; any other scheme becomes Node::Text instead, see [normalize_link].

Fields

§href: String

The link’s destination.

§children: Vec<Node>

The link’s inline text.

§

Image

An image. Only ever produced for a data: image URI or a resolved question panel asset; anything else becomes Node::Text instead, see [normalize_image].

Fields

§src: String

The image’s resolved source.

§alt: String

The image’s alt text.

§

SoftBreak

A soft line break: a single newline in the source, conventionally rendered as a space or an ordinary wrap.

§

LineBreak

A hard line break: two trailing spaces, or a trailing backslash, in the source.

§

Text

Plain text.

Also stands in for anything to_nodes refuses to render as markup: raw HTML from the source, a link with a disallowed scheme, an image with a disallowed source.

Fields

§value: String

The text itself.

Trait Implementations§

Source§

impl Clone for Node

Source§

fn clone(&self) -> Node

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Node

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Node

Source§

fn eq(&self, other: &Node) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for Node

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more