diff --git a/aiogram/utils/text_decorations.py b/aiogram/utils/text_decorations.py index 77dc0ff3..3d22f637 100644 --- a/aiogram/utils/text_decorations.py +++ b/aiogram/utils/text_decorations.py @@ -163,7 +163,7 @@ class HtmlDecoration(TextDecoration): class MarkdownDecoration(TextDecoration): - MARKDOWN_QUOTE_PATTERN: Pattern[str] = re.compile(r"([_*\[\]()~`>#+\-|{}.!])") + MARKDOWN_QUOTE_PATTERN: Pattern[str] = re.compile(r"([_*\[\]()~`>#+\-=|{}.!\\])") def link(self, value: str, link: str) -> str: return f"[{value}]({link})" diff --git a/tests/test_utils/test_markdown.py b/tests/test_utils/test_markdown.py new file mode 100644 index 00000000..02faea2a --- /dev/null +++ b/tests/test_utils/test_markdown.py @@ -0,0 +1,11 @@ +import pytest + +from aiogram.utils import markdown + + +class TestMarkdownEscape: + def test_equality_sign_is_escaped(self): + assert markdown.escape_md(r"e = mc2") == r"e \= mc2" + + def test_pre_escaped(self): + assert markdown.escape_md(r"hello\.") == r"hello\\\."