aboutsummaryrefslogtreecommitdiffstats
path: root/examples/lib.rs
blob: 00f45dcb60233d48024a08a5d84344ed21d866db (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
extern crate micromark;
use micromark::{micromark, micromark_with_options, CompileOptions};

fn main() {
    // Turn on debugging.
    // You can show it with `RUST_LOG=debug cargo run --example lib`
    env_logger::init();

    // Safely turn (untrusted?) markdown into HTML.
    println!("{:?}", micromark("# Hello, world!"));

    // Turn trusted markdown into HTML.
    println!(
        "{:?}",
        micromark_with_options(
            "<div style=\"color: tomato\">\n\n# Hello, tomato!\n\n</div>",
            &CompileOptions {
                allow_dangerous_html: true,
                allow_dangerous_protocol: true
            }
        )
    );
}