pub fn escape(val: &mut String) {
let replacements = val
.char_indices()
.filter_map(|(i, ch)| match ch {
'>' => Some((i, ">")),
'<' => Some((i, "<")),
'&' => Some((i, "&")),
'\'' => Some((i, "'")),
'"' => Some((i, """)),
_ => None,
})
.collect::<Vec<(usize, &str)>>();
let mut offset = 0;
for (i, new_str) in replacements {
val.replace_range(offset + i..=offset + i, new_str);
offset += new_str.len() - 1;
}
}