Merge remote-tracking branch 'origin/markdown-update' into testing

This commit is contained in:
Frisk 2023-09-16 19:41:02 +02:00
commit 9964dbc363
2 changed files with 2 additions and 2 deletions

View file

@ -42,7 +42,7 @@ def clean_link(link: str) -> str:
def sanitize_to_markdown(text: str) -> 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).replace('//', "/\\/").replace('](', "]\\(")
return re.sub(r"([`_*~:<>{}@|#\-\.\\])", "\\\\\\1", text).replace('//', "/\\/").replace('](', "]\\(")
def sanitize_to_url(text: str) -> str: # TODO ) replaces needed?

View file

@ -173,7 +173,7 @@ class ContentParser(HTMLParser):
def handle_data(self, data):
def escape_formatting(data: str) -> str:
"""Escape Discord formatting"""
return re.sub(r"([`_*~<>{}@/|\\])", "\\\\\\1", data)
return re.sub(r"([`_*~:<>{}@/|#\-\.\\\[\]\(\)])", "\\\\\\1", data)
data = escape_formatting(data)
if self.current_tag == "ins" and self.ins_length <= 1000:
self.ins_length += len("**" + data + "**")