From 29a241d228ce3700f34baef85348d72f56095c1f Mon Sep 17 00:00:00 2001 From: MarkusRost <2701034-MarkusRost@users.noreply.gitlab.com> Date: Sat, 1 May 2021 21:27:30 +0000 Subject: [PATCH] sanitize_to_markdown --- src/api/util.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/api/util.py b/src/api/util.py index 0aae16a..3a0651e 100644 --- a/src/api/util.py +++ b/src/api/util.py @@ -42,6 +42,7 @@ def clean_link(link: str) -> str: def sanitize_to_markdown(text: str): """Sanitizes given text to escape markdown formatting. It is used in values that will be visible on Discord in messages""" + return re.sub(r"([`_*~:<>{}@|\\])", "\\\\\\1", text, 0).replace('//', "/\\/").replace('](', "]\\(") def sanitize_to_url(text: str) -> str: # TODO ) replaces needed?