Function crowbook_text_processing::escape::html [] [src]

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

Escape characters for HTML output, replacing <, >, and & with appropriate HTML entities.

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

Example

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