diff --git a/dailyreleases/util.py b/dailyreleases/util.py index 672e296..20727f5 100644 --- a/dailyreleases/util.py +++ b/dailyreleases/util.py @@ -39,8 +39,25 @@ def case_insensitive_close_matches(word: str, possibilities: Sequence[str], n=3, def markdown_escape(text: str) -> str: """ - Escape markdown. + Escape reddit markdown. """ - special = ("\\", "`", "*", "_", "{", "}", "[", "]", "(", ")", "#", "+", "-", ".", "!", "|") - table = {s: f"\\{s}" for s in special} + table = { + "\\": "\\\\", + "`": "\\`", + "*": "\\*", + "_": "\\_", + "{": "\\{", + "}": "\\}", + "[": "\\[", + "]": "\\]", + "(": "\\(", + ")": "\\)", + "#": "\\#", + "+": "\\+", + "-": "\\-", + ".": "\\.", + "!": "\\!", + "~": "\\~", + "|": "|", + } return text.translate(str.maketrans(table))