mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-07-11 04:17:58 +00:00
Fix escape behaviour for lists and headers in escape_markdown
Fixes #9516
This commit is contained in:
parent
e6a0dc5bc0
commit
e5da7f23cb
@ -899,13 +899,13 @@ def resolve_template(code: Union[Template, str]) -> str:
|
|||||||
|
|
||||||
_MARKDOWN_ESCAPE_SUBREGEX = '|'.join(r'\{0}(?=([\s\S]*((?<!\{0})\{0})))'.format(c) for c in ('*', '`', '_', '~', '|'))
|
_MARKDOWN_ESCAPE_SUBREGEX = '|'.join(r'\{0}(?=([\s\S]*((?<!\{0})\{0})))'.format(c) for c in ('*', '`', '_', '~', '|'))
|
||||||
|
|
||||||
_MARKDOWN_ESCAPE_COMMON = r'^>(?:>>)?\s|\[.+\]\(.+\)'
|
_MARKDOWN_ESCAPE_COMMON = r'^>(?:>>)?\s|\[.+\]\(.+\)|^#{1,3}|^\s*-'
|
||||||
|
|
||||||
_MARKDOWN_ESCAPE_REGEX = re.compile(fr'(?P<markdown>{_MARKDOWN_ESCAPE_SUBREGEX}|{_MARKDOWN_ESCAPE_COMMON})', re.MULTILINE)
|
_MARKDOWN_ESCAPE_REGEX = re.compile(fr'(?P<markdown>{_MARKDOWN_ESCAPE_SUBREGEX}|{_MARKDOWN_ESCAPE_COMMON})', re.MULTILINE)
|
||||||
|
|
||||||
_URL_REGEX = r'(?P<url><[^: >]+:\/[^ >]+>|(?:https?|steam):\/\/[^\s<]+[^<.,:;\"\'\]\s])'
|
_URL_REGEX = r'(?P<url><[^: >]+:\/[^ >]+>|(?:https?|steam):\/\/[^\s<]+[^<.,:;\"\'\]\s])'
|
||||||
|
|
||||||
_MARKDOWN_STOCK_REGEX = fr'(?P<markdown>[_\\~|\*`#-]|{_MARKDOWN_ESCAPE_COMMON})'
|
_MARKDOWN_STOCK_REGEX = fr'(?P<markdown>[_\\~|\*`]|{_MARKDOWN_ESCAPE_COMMON})'
|
||||||
|
|
||||||
|
|
||||||
def remove_markdown(text: str, *, ignore_links: bool = True) -> str:
|
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.
|
The text with the markdown special characters removed.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def replacement(match):
|
def replacement(match: re.Match[str]) -> str:
|
||||||
groupdict = match.groupdict()
|
groupdict = match.groupdict()
|
||||||
return groupdict.get('url', '')
|
return groupdict.get('url', '')
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user