[][src]Struct markdown_composer::types::markdown::Markdown

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

A markdown document.

Fields

elements: Vec<Box<dyn MarkdownElement>>

The markdown elements.

footers: Vec<Box<dyn MarkdownElement>>

The markdown footer elements.

Implementations

impl<'a> Markdown[src]

pub fn new() -> Self[src]

Creates a new default Markdown instance.

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

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

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

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

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

Adds a header with level 1 to the document.

Arguments

  • text: The header's text.

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

Adds a header with level 2 to the document.

Arguments

  • text: The header's text.

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

Adds a header with level 3 to the document.

Arguments

  • text: The header's text.

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

Adds a header with level 4 to the document.

Arguments

  • text: The header's text.

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

Adds a header with level 5 to the document.

Arguments

  • text: The header's text.

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

Adds a header with level 6 to the document.

Arguments

  • text: The header's text.

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

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.

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

Adds a paragraph to the document.

Arguments

  • text: The paragraph's text.

pub fn render(&self) -> String[src]

Renders the markdown document to a String.

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

Trait Implementations

impl Default for Markdown[src]

impl Display for Markdown[src]

Auto Trait Implementations

impl !RefUnwindSafe for Markdown

impl !Send for Markdown

impl !Sync for Markdown

impl Unpin for Markdown

impl !UnwindSafe for Markdown

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.