Skip to main content

escape

Function escape 

Source
pub fn escape(text: &str) -> String
Expand description

Escape text for an element body or an attribute value. The five characters that can leave either context are replaced; nothing else is touched, so UTF-8 stays UTF-8.

use majordomus_cli::cockpit::html::escape;
assert_eq!(escape("<script>&\"'"), "&lt;script&gt;&amp;&quot;&#39;");
assert_eq!(escape("příkaz"), "příkaz");