From c418689dc1a69e930dc533f5d9107104130195c7 Mon Sep 17 00:00:00 2001 From: Nikita <78080842+NiKuma0@users.noreply.github.com> Date: Sat, 13 May 2023 14:10:15 +0300 Subject: [PATCH] Fix markdown spoiler (#1176) * Fix spoiler * added a explanation * Updated the TestTextDecoration.test_apply_single_entity --------- Co-authored-by: = <=> --- CHANGES/1176.bugfix.rst | 1 + aiogram/utils/text_decorations.py | 2 +- tests/test_utils/test_text_decorations.py | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 CHANGES/1176.bugfix.rst diff --git a/CHANGES/1176.bugfix.rst b/CHANGES/1176.bugfix.rst new file mode 100644 index 00000000..57f67202 --- /dev/null +++ b/CHANGES/1176.bugfix.rst @@ -0,0 +1 @@ +Fixed the markdown spoiler parser. diff --git a/aiogram/utils/text_decorations.py b/aiogram/utils/text_decorations.py index 70f96388..97430a32 100644 --- a/aiogram/utils/text_decorations.py +++ b/aiogram/utils/text_decorations.py @@ -233,7 +233,7 @@ class MarkdownDecoration(TextDecoration): return f"~{value}~" def spoiler(self, value: str) -> str: - return f"|{value}|" + return f"||{value}||" def quote(self, value: str) -> str: return re.sub(pattern=self.MARKDOWN_QUOTE_PATTERN, repl=r"\\\1", string=value) diff --git a/tests/test_utils/test_text_decorations.py b/tests/test_utils/test_text_decorations.py index 01fbabb6..056bd1cb 100644 --- a/tests/test_utils/test_text_decorations.py +++ b/tests/test_utils/test_text_decorations.py @@ -90,7 +90,7 @@ class TestTextDecoration: [markdown_decoration, MessageEntity(type="bot_command", offset=0, length=5), "test"], [markdown_decoration, MessageEntity(type="email", offset=0, length=5), "test"], [markdown_decoration, MessageEntity(type="phone_number", offset=0, length=5), "test"], - [markdown_decoration, MessageEntity(type="spoiler", offset=0, length=5), "|test|"], + [markdown_decoration, MessageEntity(type="spoiler", offset=0, length=5), "||test||"], [ markdown_decoration, MessageEntity(type="custom_emoji", offset=0, length=5, custom_emoji_id="42"),