[][src]Function ammonia::clean_text

pub fn clean_text(src: &str) -> String

Turn an arbitrary string into unformatted HTML.

This function is roughly equivalent to PHP's htmlspecialchars and htmlentities. It is maximally strict on purpose, encoding every character that has special meaning to the HTML parser.

This function cannot be used to package strings into a <script> or <style> tag; you need a JavaScript or CSS escaper to do that.

It also does not make user text safe for HTML attribute microsyntaxes such as class or id. Only use this function for places where HTML accepts unrestricted text such as title attributes and paragraph contents.