Merge pull request #184 from rsmidt/add-missing-markdown-escape-char

Escape '>' using markdown utilities
This commit is contained in:
Temirkhan Myrzamadi 2020-02-28 15:25:29 +06:00 committed by GitHub
commit 637dcd2535
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -97,6 +97,7 @@ pub fn escape(s: &str) -> String {
.replace(")", r"\)")
.replace("~", r"\~")
.replace("`", r"\`")
.replace(">", r"\>")
.replace("#", r"\#")
.replace("+", r"\+")
.replace("-", r"\-")
@ -218,8 +219,8 @@ mod tests {
fn test_escape() {
assert_eq!(escape("* foobar *"), r"\* foobar \*");
assert_eq!(
escape(r"_ * [ ] ( ) ~ \ ` # + - = | { } . !"),
r"\_ \* \[ \] \( \) \~ \ \` \# \+ \- \= \| \{ \} \. \!",
escape(r"_ * [ ] ( ) ~ \ ` > # + - = | { } . !"),
r"\_ \* \[ \] \( \) \~ \ \` \> \# \+ \- \= \| \{ \} \. \!",
);
}