Struct Markdown

Source
pub struct Markdown {
    pub elements: Vec<Box<dyn MarkdownElement>>,
    pub footers: Vec<Box<dyn MarkdownElement>>,
}
Expand description

A markdown document.

Fields§

§elements: Vec<Box<dyn MarkdownElement>>

The markdown elements.

§footers: Vec<Box<dyn MarkdownElement>>

The markdown footer elements.

Implementations§

Source§

impl Markdown

Source

pub fn new() -> Self

Creates a new default Markdown instance.

Source

pub fn with( elements: Vec<Box<dyn MarkdownElement>>, footers: Vec<Box<dyn MarkdownElement>>, ) -> Self

Creates a new Markdown instance with the given elements and footers.

Source

pub fn header( &mut self, text: impl Into<String>, level: impl ToUsize, ) -> &mut Self

Adds a header to the document.

§Arguments
  • text: The header’s text.
  • level: The header’s level.
§Panics

Panics if the header level is not valid (one to six inclusive).

Source

pub fn header1(&mut self, text: impl Into<String>) -> &mut Self

Adds a header with level 1 to the document.

§Arguments
  • text: The header’s text.
Source

pub fn header2(&mut self, text: impl Into<String>) -> &mut Self

Adds a header with level 2 to the document.

§Arguments
  • text: The header’s text.
Source

pub fn header3(&mut self, text: impl Into<String>) -> &mut Self

Adds a header with level 3 to the document.

§Arguments
  • text: The header’s text.
Source

pub fn header4(&mut self, text: impl Into<String>) -> &mut Self

Adds a header with level 4 to the document.

§Arguments
  • text: The header’s text.
Source

pub fn header5(&mut self, text: impl Into<String>) -> &mut Self

Adds a header with level 5 to the document.

§Arguments
  • text: The header’s text.
Source

pub fn header6(&mut self, text: impl Into<String>) -> &mut Self

Adds a header with level 6 to the document.

§Arguments
  • text: The header’s text.
Source

pub fn list(&mut self, list: List) -> &mut Self

Adds a list to the document.

§Arguments
  • list: The list instance to add.

Adds a link to the document.

§Arguments
  • link: The link instance to add.
§Note

The associated footer element is added as well if the passed link is marked as footer.

Source

pub fn image(&mut self, image: Image) -> &mut Self

Adds an image to the document.

§Argument
  • image: The image instance to add.
§Note

The associated footer element is added as well if the passed link is marked as footer.

Source

pub fn paragraph(&mut self, text: impl Into<String>) -> &mut Self

Adds a paragraph to the document.

§Arguments
  • text: The paragraph’s text.
Source

pub fn render(&self) -> String

Renders the markdown document to a String.

The method does render each element in order, followed by each footer.

Trait Implementations§

Source§

impl Default for Markdown

Source§

fn default() -> Markdown

Returns the “default value” for a type. Read more
Source§

impl Display for Markdown

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> 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.