From e5da7f23cb1405c341431d1592538880e4d54d4d Mon Sep 17 00:00:00 2001 From: Rapptz Date: Tue, 1 Aug 2023 21:25:47 -0400 Subject: [PATCH] Fix escape behaviour for lists and headers in escape_markdown Fixes #9516 --- discord/utils.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/discord/utils.py b/discord/utils.py index 3ee867975..a3f830019 100644 --- a/discord/utils.py +++ b/discord/utils.py @@ -899,13 +899,13 @@ def resolve_template(code: Union[Template, str]) -> str: _MARKDOWN_ESCAPE_SUBREGEX = '|'.join(r'\{0}(?=([\s\S]*((?(?:>>)?\s|\[.+\]\(.+\)' +_MARKDOWN_ESCAPE_COMMON = r'^>(?:>>)?\s|\[.+\]\(.+\)|^#{1,3}|^\s*-' _MARKDOWN_ESCAPE_REGEX = re.compile(fr'(?P{_MARKDOWN_ESCAPE_SUBREGEX}|{_MARKDOWN_ESCAPE_COMMON})', re.MULTILINE) _URL_REGEX = r'(?P<[^: >]+:\/[^ >]+>|(?:https?|steam):\/\/[^\s<]+[^<.,:;\"\'\]\s])' -_MARKDOWN_STOCK_REGEX = fr'(?P[_\\~|\*`#-]|{_MARKDOWN_ESCAPE_COMMON})' +_MARKDOWN_STOCK_REGEX = fr'(?P[_\\~|\*`]|{_MARKDOWN_ESCAPE_COMMON})' def remove_markdown(text: str, *, ignore_links: bool = True) -> str: @@ -932,7 +932,7 @@ def remove_markdown(text: str, *, ignore_links: bool = True) -> str: The text with the markdown special characters removed. """ - def replacement(match): + def replacement(match: re.Match[str]) -> str: groupdict = match.groupdict() return groupdict.get('url', '')