Skip to main content

MdNode

Struct MdNode 

Source
pub struct MdNode {
Show 29 fields pub node_type: NodeType, pub parent: Option<NodeId>, pub first_child: Option<NodeId>, pub last_child: Option<NodeId>, pub prev: Option<NodeId>, pub next: Option<NodeId>, pub sourcepos: SourcePos, pub literal: String, pub level: usize, pub destination: String, pub title: Option<String>, pub info: Option<String>, pub is_fenced: bool, pub fence_char: u8, pub fence_length: usize, pub fence_offset: usize, pub list_data: Option<ListData>, pub table_align: Option<Vec<TableAlign>>, pub is_header_row: bool, pub checked: Option<bool>, pub gfm: bool, pub open: bool, pub string_content: String, pub last_line_blank: bool, pub last_line_checked: bool, pub content_line: usize, pub label: String, pub reference_type: Option<ReferenceType>, pub definitions: Vec<DefinitionSite>,
}
Expand description

One node of the tree.

Fields§

§node_type: NodeType§parent: Option<NodeId>§first_child: Option<NodeId>§last_child: Option<NodeId>§prev: Option<NodeId>§next: Option<NodeId>§sourcepos: SourcePos§literal: String

Text payload for text / code / html_block / html_inline / code_block.

§level: usize

Heading level 1..6.

§destination: String

Link/image destination, already entity-decoded and backslash-unescaped.

§title: Option<String>

Link/image title, already entity-decoded and backslash-unescaped. None is the canonical runtime’s null (the Go port’s HasTitle false).

§info: Option<String>

Fenced code info string (raw, entity-decoded); None for indented code, which is the canonical null and Go’s HasInfo false.

§is_fenced: bool

True for fenced code blocks, false for indented.

§fence_char: u8§fence_length: usize§fence_offset: usize§list_data: Option<ListData>§table_align: Option<Vec<TableAlign>>

GFM tables: one entry per column, in order, set on the table node by the block phase from the delimiter row. Every row of the table, header and body alike, has exactly this many cells, because short rows are padded and long ones are truncated. None on every other node type.

§is_header_row: bool

GFM tables: true on the one table_row that is the header row, which is always the table’s first child. mdast has no header flag and relies on that convention, but the renderer needs to choose <th> over <td> without walking back up to the table.

§checked: Option<bool>

GFM task list items (- [x] foo): Some(true) / Some(false) for a checked / unchecked item, None for an ordinary one. Set on item nodes by the block phase when gfm is on, once the marker has been consumed from the item’s first paragraph. mdast’s field and mdast’s semantics; ast.rs projects it straight through to listItem.checked.

§gfm: bool

The gfm parse option, recorded on the document node by the block phase and meaningless anywhere else. The renderer defaults to it when called without options, so a tree parsed as plain CommonMark renders as plain CommonMark.

§open: bool

Open blocks accept further lines; closed ones are finalized.

§string_content: String

Accumulated raw content, consumed by the inline phase.

§last_line_blank: bool

A block whose last line was blank cannot be lazily continued.

§last_line_checked: bool§content_line: usize

A paragraph’s source line where string_content begins: its first line, moved on past each definition read off the front, so a definition read later knows its lines.

§label: String

A link_reference’s or image_reference’s label (its raw source text, between its brackets) and the form that named it.

§reference_type: Option<ReferenceType>§definitions: Vec<DefinitionSite>

A container’s link reference definitions, read from paragraphs among its children, each with where it stands.

Implementations§

Source§

impl MdNode

Source

pub fn new(node_type: NodeType) -> Self

An open, unlinked node of the given type.

Source

pub fn is_container(&self) -> bool

Containers may hold children; leaves carry only literal.

Trait Implementations§

Source§

impl Clone for MdNode

Source§

fn clone(&self) -> Self

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 MdNode

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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, 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> 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.