From 60d825103364c44528bbebf8378ba2f3b41d1633 Mon Sep 17 00:00:00 2001 From: MarkusRost <2701034-MarkusRost@users.noreply.gitlab.com> Date: Thu, 26 Sep 2024 22:09:12 +0000 Subject: [PATCH] Escape subtext --- src/api/util.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/api/util.py b/src/api/util.py index 3982bab..081c3bc 100644 --- a/src/api/util.py +++ b/src/api/util.py @@ -45,6 +45,7 @@ def sanitize_to_markdown(text: str) -> str: text = text.replace("\\", "\\\\").replace('//', '/\\/').replace("](", "]\\(") # replace escaping and links text = re.sub(r"([`_*~:<>{}@|])", "\\\\\\1", text) # Escape common Markdown characters text = re.sub(r"^(#+ )", '\\\\\\1', text, 0, re.MULTILINE) # Escape headers + text = re.sub(r"^(-# )", '\\\\\\1', text, 0, re.MULTILINE) # Escape subtext text = re.sub(r"^(\s*)- ", '\\1\\\\- ', text, 0, re.MULTILINE) # Escape lists text = re.sub(r"^(\s*\d+)\. ", "\\1\\\\. ", text, 0, re.MULTILINE) # Escape numbered lists return text