Crates.io | maud-pulldown-cmark |
lib.rs | maud-pulldown-cmark |
version | 0.5.0 |
source | src |
created_at | 2016-01-19 10:00:22.481612 |
updated_at | 2016-12-03 12:39:50.680139 |
description | An adapter between maud and pulldown-cmark |
homepage | https://nemo157.com/maud-pulldown-cmark |
repository | https://git.nemo157.com/rust/maud-pulldown-cmark |
max_upload_size | |
id | 3926 |
size | 34,114 |
This library implements an adapter to allow rendering markdown strings inside a maud macro using pulldown-cmark efficiently.
This library requires nightly rust to run the tests as they use the
maud_macros
plugin.
#![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 buffer = html! {
div {
(Markdown::from_string(markdown))
}
};
println!("{}", buffer.into_string());
}
#![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. <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());
}
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you shall be dual licensed as above, without any additional terms or conditions.