#[cfg(feature = "docs-scalar")]
pub(crate) mod config;
#[cfg(feature = "docs-scalar")]
pub(crate) mod scalar;
#[cfg(feature = "docs-scalar")]
pub use config::{DeveloperTools, DocumentDownload, ScalarConfig, ScalarLayout, ScalarTheme};
#[cfg(feature = "docs-scalar")]
pub(crate) fn html_escape(input: &str) -> String {
let mut out = String::with_capacity(input.len());
for c in input.chars() {
match c {
'&' => out.push_str("&"),
'<' => out.push_str("<"),
'>' => out.push_str(">"),
'"' => out.push_str("""),
'\'' => out.push_str("'"),
c => out.push(c),
}
}
out
}
#[cfg(test)]
mod tests {
#[test]
#[cfg(feature = "docs-scalar")]
fn html_escape_replaces_dangerous_chars() {
assert_eq!(super::html_escape("&"), "&");
assert_eq!(super::html_escape("<"), "<");
assert_eq!(super::html_escape(">"), ">");
assert_eq!(super::html_escape("\""), """);
assert_eq!(super::html_escape("'"), "'");
assert_eq!(super::html_escape("plain"), "plain");
}
}