Document

Struct Document 

Source
pub struct Document {
    pub blocks: Vec<Block>,
}
Expand description

Root of a Markdown document

Fields§

§blocks: Vec<Block>

Top‑level block sequence in document order.

Trait Implementations§

Source§

impl Clone for Document

Source§

fn clone(&self) -> Document

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Document

Source§

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

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

impl<'de> Deserialize<'de> for Document

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl ExpandWith for Document

Source§

fn expand_with<T: Transformer>(self, transformer: &mut T) -> Vec<Self>

Apply an expandable transformer to this AST node, returning multiple nodes
Source§

impl FilterTransform for Document

Source§

fn remove_empty_paragraphs(self) -> Self

Remove empty paragraphs
Source§

fn remove_empty_text(self) -> Self

Remove empty text elements
Source§

fn normalize_whitespace(self) -> Self

Normalize whitespace in text elements
Source§

fn filter_blocks<F>(self, predicate: F) -> Self
where F: Fn(&Block) -> bool,

Remove specific block types
Source§

impl PartialEq for Document

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PipeExt for Document

Source§

fn pipe<F, R>(self, f: F) -> R
where F: FnOnce(Self) -> R, Self: Sized,

Apply a function to self (functional pipe operator)
Source§

impl Query for Document

Source§

fn find_all_inlines<F>(&self, predicate: F) -> Vec<&Inline>
where F: Fn(&Inline) -> bool,

Find all inline elements matching a predicate
Source§

fn find_all_blocks<F>(&self, predicate: F) -> Vec<&Block>
where F: Fn(&Block) -> bool,

Find all block elements matching a predicate
Source§

fn find_first_inline<F>(&self, predicate: F) -> Option<&Inline>
where F: Fn(&Inline) -> bool,

Find the first inline element matching a predicate
Source§

fn find_first_block<F>(&self, predicate: F) -> Option<&Block>
where F: Fn(&Block) -> bool,

Find the first block element matching a predicate
Source§

fn count_inlines<F>(&self, predicate: F) -> usize
where F: Fn(&Inline) -> bool,

Count inline elements matching a predicate
Source§

fn count_blocks<F>(&self, predicate: F) -> usize
where F: Fn(&Block) -> bool,

Count block elements matching a predicate
Source§

fn any_inline<F>(&self, predicate: F) -> bool
where F: Fn(&Inline) -> bool,

Check if any inline element matches a predicate
Source§

fn any_block<F>(&self, predicate: F) -> bool
where F: Fn(&Block) -> bool,

Check if any block element matches a predicate
Find all links in the document
Source§

fn find_all_images(&self) -> Vec<&Image>

Find all images in the document
Source§

fn find_all_headings(&self) -> Vec<&Heading>

Find all headings in the document
Find all autolinks in the document
Source§

fn find_all_text(&self) -> Vec<&str>

Find all text nodes in the document
Source§

fn find_all_code_spans(&self) -> Vec<&str>

Find all code spans in the document
Source§

fn find_all_code_blocks(&self) -> Vec<&CodeBlock>

Find all code blocks in the document
Source§

fn find_all_tables(&self) -> Vec<&Table>

Find all tables in the document
Source§

fn find_all_lists(&self) -> Vec<&List>

Find all lists in the document
Source§

impl Serialize for Document

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 Transform for Document

Source§

fn transform_text<F>(self, f: F) -> Self
where F: Fn(String) -> String,

Transform all text elements with a function Read more
Source§

fn transform_image_urls<F>(self, f: F) -> Self
where F: Fn(String) -> String,

Transform all image URLs with a function Read more
Transform all link URLs with a function Read more
Transform all autolink URLs with a function
Source§

fn transform_code<F>(self, f: F) -> Self
where F: Fn(String) -> String,

Transform all code spans with a function
Source§

fn transform_html<F>(self, f: F) -> Self
where F: Fn(String) -> String,

Transform all HTML content with a function
Source§

fn transform_with<T: Transformer>(self, transformer: T) -> Self

Apply a custom transformer
Source§

fn transform_if_doc<P, F>(self, predicate: P, transform: F) -> Self
where P: Fn(&Self) -> bool, F: FnOnce(Self) -> Self,

Transform conditionally based on a document predicate
Source§

impl TransformWith for Document

Source§

fn transform_with<T: Transformer>(self, transformer: &mut T) -> Self

Apply a transformer to this AST node
Source§

impl VisitWith for Document

Source§

fn visit_with<V: Visitor>(&self, visitor: &mut V)

Apply a visitor to this AST node
Source§

impl<T: Default> WithData<T> for Document

Source§

type WithDataType = Document<T>

The type with user data attached
Source§

fn with_data(self, data: T) -> Self::WithDataType

Add user data to this AST node
Source§

fn with_default_data(self) -> Self::WithDataType
where T: Default,

Add default user data to this AST node
Source§

impl StructuralPartialEq for Document

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,