This library implements an adapter to allow rendering strings as markdown inside a maud macro using pulldown-cmark efficiently.
#![feature(plugin)]
#![plugin(maud_macros)]
extern crate maud;
extern crate maud_pulldown_cmark;
use maud_pulldown_cmark::Markdown;
fn main() {
let markdown = "
1. A list
2. With some
3. Values";
let mut buffer = String::new();
html!(buffer, {
div {
^(Markdown::from_string(markdown))
}
}).unwrap();
println!("{}", buffer);
}
#![feature(plugin)]
#![plugin(maud_macros)]
extern crate maud;
extern crate maud_pulldown_cmark;
extern crate pulldown_cmark;
use maud_pulldown_cmark::Markdown;
use pulldown_cmark::{Parser, Event};
fn main() {
let markdown = "
1. A list
2. With some
3. Inline html";
let events = Parser::new(markdown).map(|ev| match ev {
// Escape inline html
Event::Html(html) | Event::InlineHtml(html) => Event::Text(html),
_ => ev,
});
let mut buffer = String::new();
html!(buffer, {
div {
^(Markdown::from_events(events))
}
}).unwrap();
println!("{}", buffer);
}