Fix markdown spoiler (#1176)

* Fix spoiler

* added a explanation

* Updated the TestTextDecoration.test_apply_single_entity

---------

Co-authored-by: = <=>
This commit is contained in:
Nikita 2023-05-13 14:10:15 +03:00 committed by GitHub
parent 68a6c2c192
commit c418689dc1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 2 deletions

1
CHANGES/1176.bugfix.rst Normal file
View file

@ -0,0 +1 @@
Fixed the markdown spoiler parser.

View file

@ -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)

View file

@ -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"),