pub struct Markdown<'a, I: 'a + Iterator<Item = Event<'a>>> { /* private fields */ }
Expand description
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());
Implementations§
Source§impl<'a> Markdown<'a, Parser<'a>>
impl<'a> Markdown<'a, Parser<'a>>
Sourcepub fn from_string(s: &'a str) -> Markdown<'a, Parser<'a>>
pub fn from_string(s: &'a str) -> Markdown<'a, Parser<'a>>
To allow rendering from a string.
Source§impl<'a, I: 'a + Iterator<Item = Event<'a>>> Markdown<'a, I>
impl<'a, I: 'a + Iterator<Item = Event<'a>>> Markdown<'a, I>
Sourcepub fn from_events(events: I) -> Markdown<'a, I>
pub 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).
Sourcepub fn with_header_ids(self) -> Markdown<'a, I>
pub 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§
Source§impl<'a, I: 'a + Iterator<Item = Event<'a>>> RenderOnce for Markdown<'a, I>
impl<'a, I: 'a + Iterator<Item = Event<'a>>> RenderOnce for Markdown<'a, I>
Source§fn render_once_to(self, w: &mut String)
fn render_once_to(self, w: &mut String)
Source§fn render_once(self) -> PreEscaped<String>
fn render_once(self) -> PreEscaped<String>
Renders
self
as a block of Markup
, consuming it in the
process.Auto Trait Implementations§
impl<'a, I> Freeze for Markdown<'a, I>where
I: Freeze,
impl<'a, I> RefUnwindSafe for Markdown<'a, I>where
I: RefUnwindSafe,
impl<'a, I> Send for Markdown<'a, I>
impl<'a, I> Sync for Markdown<'a, I>where
I: Sync,
impl<'a, I> Unpin for Markdown<'a, I>where
I: Unpin,
impl<'a, I> UnwindSafe for Markdown<'a, I>where
I: UnwindSafe + RefUnwindSafe,
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