use pulldown_cmark::{html, Options, Parser}; fn main() { let markdown_input: &str = "Hello world, this is a ~~complicated~~ *very simple* example."; println!("Parsing the following markdown string:\n{}", markdown_input); // Set up options and parser. Strikethroughs are not part of the CommonMark standard // and we therefore must enable it explicitly. let mut options = Options::empty(); options.insert(Options::ENABLE_STRIKETHROUGH); let parser = Parser::new_ext(markdown_input, options); // Write to String buffer. let mut html_output: String = String::with_capacity(markdown_input.len() * 3 / 2); html::push_html(&mut html_output, parser); // Check that the output is what we expected. let expected_html: &str = "

Hello world, this is a complicated very simple example.

\n"; assert_eq!(expected_html, &html_output); // Write result to stdout. println!("\nHTML output:\n{}", &html_output); }