//! Small text/JS escaping helpers shared by the page builder, the Markdown //! pipeline and the renderer. pub fn escape_js(s: &str) -> String { s.replace('\\', "\\\\") .replace('\'', "\\'") .replace('\n', "\\n") .replace('\r', "\\r") } pub fn html_escape_ta(s: &str) -> String { s.replace('&', "&").replace('<', "<") } pub fn html_escape_attr(s: &str) -> String { s.replace('&', "&") .replace('"', """) .replace('<', "<") } pub fn html_escape_text(s: &str) -> String { s.replace('&', "&") .replace('<', "<") .replace('>', ">") }