Escape a character that would be interpreted as styling markup. Characters `{`, `}`, `|`, and `\` are prefixed with `\`.
(ch: char)
| 1843 | /// Escape a character that would be interpreted as styling markup. |
| 1844 | /// Characters `{`, `}`, `|`, and `\` are prefixed with `\`. |
| 1845 | pub fn escape_char(ch: char) -> String { |
| 1846 | match ch { |
| 1847 | '{' | '}' | '|' | '\\' => format!("\\{}", ch), |
| 1848 | _ => ch.to_string(), |
| 1849 | } |
| 1850 | } |
| 1851 | |
| 1852 | /// Escape all styling-significant characters in a string. |
| 1853 | pub fn escape_str(s: &str) -> String { |