11 releases (5 breaking)

Uses old Rust 2015

0.5.0 Dec 3, 2016
0.4.0 Oct 30, 2016
0.3.0 Sep 27, 2016
0.2.2 Aug 17, 2016
0.0.6 Jan 31, 2016

#3 in #pulldown-cmark

Download history 11/week @ 2021-07-17 13/week @ 2021-07-24 23/week @ 2021-07-31 11/week @ 2021-08-14 1/week @ 2021-09-04 11/week @ 2021-09-25 1/week @ 2021-10-02 12/week @ 2021-10-09

55 downloads per month

MIT/Apache

22KB
475 lines

maud-pulldown-cmark downloads-badge release-badge license-badge

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.

Example

#![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());
}

License

Licensed under either of

at your option.

Contribution

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.

Dependencies

~525KB
~12K SLoC

BX