Struct maud_pulldown_cmark::Markdown
[−]
[src]
pub struct Markdown<'a, I: 'a + Iterator<Item = Event<'a>>> { /* fields omitted */ }
The adapter that allows rendering markdown inside a maud
macro.
Examples
let markdown = " 1. A list 2. With some 3. <span>Inline html</span> "; let buffer = html! { div { (Markdown::from_string(markdown)) } }; println!("{}", buffer.into_string());
let markdown = " 1. A list 2. With some 3. <span>Inline html</span> "; let events = Parser::new(markdown).map(|ev| match ev { // Escape inline html Event::Html(html) | Event::InlineHtml(html) => Event::Text(html), _ => ev, }); let buffer = html! { div { (Markdown::from_events(events)) } }; println!("{}", buffer.into_string());
Methods
impl<'a> Markdown<'a, Parser<'a>>
[src]
fn from_string(s: &'a str) -> Markdown<'a, Parser<'a>>
To allow rendering from a string.
impl<'a, I: 'a + Iterator<Item = Event<'a>>> Markdown<'a, I>
[src]
fn from_events(events: I) -> Markdown<'a, I>
To allow rendering from a stream of events (useful for modifying the output of the general parser).
fn with_header_ids(self) -> Markdown<'a, I>
Generate ids for all headers, lowercases the text in the header and replaces spaces with -.
Examples
let markdown = "# Header # A Sub Header "; let buffer = html!( (Markdown::from_string(markdown).with_header_ids()) ); assert_eq!(buffer.into_string(), "<h1 id=\"header\">Header</h1>\n<h2 id=\"a-sub-header\">A Sub Header</h2>\n");
Trait Implementations
impl<'a, I: 'a + Iterator<Item = Event<'a>>> RenderOnce for Markdown<'a, I>
[src]
fn render_once_to(self, w: &mut String)
Appends a representation of self
to the given string, consuming self
in the process. Read more
fn render_once(self) -> PreEscaped<String>
Renders self
as a block of Markup
, consuming it in the process. Read more