Function crowbook_text_processing::escape::escape_html [] [src]

pub fn escape_html<'a, S: Into<Cow<'a, str>>>(input: S) -> Cow<'a, str>

Escape characters <, >, and &

Warning: this function was written for escaping text in a markdown text processor that is designed to run on a local machine, so the content can actually be trusted, it should not be used for untrusted content.

Example

use crowbook_text_processing::escape::escape_html;
let s = escape_html("<foo> & <bar>");
assert_eq!(&s, "&lt;foo&gt; &amp; &lt;bar&gt;");