diff options
author | Titus Wormer <tituswormer@gmail.com> | 2022-07-05 09:46:03 +0200 |
---|---|---|
committer | Titus Wormer <tituswormer@gmail.com> | 2022-07-05 09:46:03 +0200 |
commit | 5a3b8a3e98dc8c7248dcc08757537f96aca60917 (patch) | |
tree | 5de981cec44cc521b57d190c2aa3c61cde8e2207 /examples | |
parent | 1baad17d92108de592905f8c69bf29fbec02a57b (diff) | |
download | markdown-rs-5a3b8a3e98dc8c7248dcc08757537f96aca60917.tar.gz markdown-rs-5a3b8a3e98dc8c7248dcc08757537f96aca60917.tar.bz2 markdown-rs-5a3b8a3e98dc8c7248dcc08757537f96aca60917.zip |
Fix example
Diffstat (limited to 'examples')
-rw-r--r-- | examples/lib.rs | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/examples/lib.rs b/examples/lib.rs index ce06738..718e400 100644 --- a/examples/lib.rs +++ b/examples/lib.rs @@ -1,7 +1,24 @@ extern crate micromark; -use micromark::micromark; +use micromark::{micromark, micromark_with_options, Options}; fn main() { + // Turn on debugging. + // You can show it with `RUST_LOG=debug cargo run --example lib` env_logger::init(); - println!("{:?}", micromark("a *b c* d")); + + // 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>", + &Options { + allow_dangerous_html: true, + allow_dangerous_protocol: true, + default_line_ending: None + } + ) + ); } |