diff options
| author | Rapptz <[email protected]> | 2020-10-17 01:36:31 -0400 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2020-10-17 01:36:31 -0400 |
| commit | d9acc2f491a31706b8d883ee5441437aa14e6ce7 (patch) | |
| tree | 1892c77117c9e0f551bf1e0fb938b3dfbe40287b | |
| parent | Fix Colour.dark_theme docstring. (diff) | |
| download | discord.py-d9acc2f491a31706b8d883ee5441437aa14e6ce7.tar.xz discord.py-d9acc2f491a31706b8d883ee5441437aa14e6ce7.zip | |
Escape multi-line quotes properly
Fix #5897
| -rw-r--r-- | discord/utils.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/discord/utils.py b/discord/utils.py index 39e097d5..56ac6699 100644 --- a/discord/utils.py +++ b/discord/utils.py @@ -482,7 +482,7 @@ _MARKDOWN_ESCAPE_SUBREGEX = '|'.join(r'\{0}(?=([\s\S]*((?<!\{0})\{0})))'.format( _MARKDOWN_ESCAPE_COMMON = r'^>(?:>>)?\s|\[.+\]\(.+\)' -_MARKDOWN_ESCAPE_REGEX = re.compile(r'(?P<markdown>%s|%s)' % (_MARKDOWN_ESCAPE_SUBREGEX, _MARKDOWN_ESCAPE_COMMON)) +_MARKDOWN_ESCAPE_REGEX = re.compile(r'(?P<markdown>%s|%s)' % (_MARKDOWN_ESCAPE_SUBREGEX, _MARKDOWN_ESCAPE_COMMON), re.MULTILINE) def escape_markdown(text, *, as_needed=False, ignore_links=True): r"""A helper function that escapes Discord's markdown. @@ -521,7 +521,7 @@ def escape_markdown(text, *, as_needed=False, ignore_links=True): regex = r'(?P<markdown>[_\\~|\*`]|%s)' % _MARKDOWN_ESCAPE_COMMON if ignore_links: regex = '(?:%s|%s)' % (url_regex, regex) - return re.sub(regex, replacement, text) + return re.sub(regex, replacement, text, 0, re.MULTILINE) else: text = re.sub(r'\\', r'\\\\', text) return _MARKDOWN_ESCAPE_REGEX.sub(r'\\\1', text) |