diff options
author | Titus Wormer <tituswormer@gmail.com> | 2022-06-08 15:52:16 +0200 |
---|---|---|
committer | Titus Wormer <tituswormer@gmail.com> | 2022-06-08 15:52:16 +0200 |
commit | 4c06c8554c35887f8f5147783953b2b7e7c2327f (patch) | |
tree | 1b2463848a3ae4c645f7f1a325877ee829ab65c5 /examples/lib.rs | |
download | markdown-rs-4c06c8554c35887f8f5147783953b2b7e7c2327f.tar.gz markdown-rs-4c06c8554c35887f8f5147783953b2b7e7c2327f.tar.bz2 markdown-rs-4c06c8554c35887f8f5147783953b2b7e7c2327f.zip |
.
Diffstat (limited to 'examples/lib.rs')
-rw-r--r-- | examples/lib.rs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/examples/lib.rs b/examples/lib.rs new file mode 100644 index 0000000..4d01161 --- /dev/null +++ b/examples/lib.rs @@ -0,0 +1,22 @@ +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 + } + ) + ); +} |