pulldown_cmark::html

Function push_html

Source
pub fn push_html<'a, I>(s: &mut String, iter: I)
where I: Iterator<Item = Event<'a>>,
Expand description

Iterate over an Iterator of Events, generate HTML for each Event, and push it to a String.

ยงExamples

use pulldown_cmark::{html, Parser};

let markdown_str = r#"
hello
=====

* alpha
* beta
"#;
let parser = Parser::new(markdown_str);

let mut html_buf = String::new();
html::push_html(&mut html_buf, parser);

assert_eq!(html_buf, r#"<h1>hello</h1>
<ul>
<li>alpha</li>
<li>beta</li>
</ul>
"#);