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.
The markdown footer elements.
Implementations§
Source§impl<'a> Markdown
impl<'a> Markdown
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new default Markdown
instance.
Examples found in repository?
examples/basic.rs (line 6)
5fn main() {
6 let mut md = Markdown::new();
7 for _ in 1..=10 {
8 md.header1("hello").list(
9 ListBuilder::new()
10 .add("first")
11 .add("second")
12 .add(CheckmarkItem {
13 text: "Buy groceries",
14 checked: true,
15 })
16 .ordered(),
17 );
18 let link = Link::builder()
19 .footer(true)
20 .text("Hello")
21 .inlined()
22 .url("https://hello.world")
23 .build();
24 md.link(link);
25 }
26 println!("{}", md);
27}
Sourcepub fn with(
elements: Vec<Box<dyn MarkdownElement>>,
footers: Vec<Box<dyn MarkdownElement>>,
) -> Self
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.
Sourcepub fn header1(&mut self, text: impl Into<String>) -> &mut Self
pub fn header1(&mut self, text: impl Into<String>) -> &mut Self
Examples found in repository?
examples/basic.rs (line 8)
5fn main() {
6 let mut md = Markdown::new();
7 for _ in 1..=10 {
8 md.header1("hello").list(
9 ListBuilder::new()
10 .add("first")
11 .add("second")
12 .add(CheckmarkItem {
13 text: "Buy groceries",
14 checked: true,
15 })
16 .ordered(),
17 );
18 let link = Link::builder()
19 .footer(true)
20 .text("Hello")
21 .inlined()
22 .url("https://hello.world")
23 .build();
24 md.link(link);
25 }
26 println!("{}", md);
27}
Sourcepub fn list(&mut self, list: List) -> &mut Self
pub fn list(&mut self, list: List) -> &mut Self
Examples found in repository?
examples/basic.rs (lines 8-17)
5fn main() {
6 let mut md = Markdown::new();
7 for _ in 1..=10 {
8 md.header1("hello").list(
9 ListBuilder::new()
10 .add("first")
11 .add("second")
12 .add(CheckmarkItem {
13 text: "Buy groceries",
14 checked: true,
15 })
16 .ordered(),
17 );
18 let link = Link::builder()
19 .footer(true)
20 .text("Hello")
21 .inlined()
22 .url("https://hello.world")
23 .build();
24 md.link(link);
25 }
26 println!("{}", md);
27}
Sourcepub fn link(&mut self, link: Link) -> &mut Self
pub fn link(&mut self, link: Link) -> &mut Self
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.
Examples found in repository?
examples/basic.rs (line 24)
5fn main() {
6 let mut md = Markdown::new();
7 for _ in 1..=10 {
8 md.header1("hello").list(
9 ListBuilder::new()
10 .add("first")
11 .add("second")
12 .add(CheckmarkItem {
13 text: "Buy groceries",
14 checked: true,
15 })
16 .ordered(),
17 );
18 let link = Link::builder()
19 .footer(true)
20 .text("Hello")
21 .inlined()
22 .url("https://hello.world")
23 .build();
24 md.link(link);
25 }
26 println!("{}", md);
27}
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Markdown
impl !RefUnwindSafe for Markdown
impl !Send for Markdown
impl !Sync for Markdown
impl Unpin for Markdown
impl !UnwindSafe for Markdown
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more