string_to_string/
string-to-string.rs1use pulldown_cmark::{html, Options, Parser};
2
3fn main() {
4 let markdown_input: &str = "Hello world, this is a ~~complicated~~ *very simple* example.";
5 println!("Parsing the following markdown string:\n{}", markdown_input);
6
7 let mut options = Options::empty();
10 options.insert(Options::ENABLE_STRIKETHROUGH);
11 let parser = Parser::new_ext(markdown_input, options);
12
13 let mut html_output: String = String::with_capacity(markdown_input.len() * 3 / 2);
15 html::push_html(&mut html_output, parser);
16
17 let expected_html: &str =
19 "<p>Hello world, this is a <del>complicated</del> <em>very simple</em> example.</p>\n";
20 assert_eq!(expected_html, &html_output);
21
22 println!("\nHTML output:\n{}", &html_output);
24}