mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Fix markdown escaping issues (#363)
* #360 - Fix: escape '=' sign in markdown * fix more escaping issues * Rename test suite Co-authored-by: Alex Root Junior <jroot.junior@gmail.com>
This commit is contained in:
parent
c9cbde4595
commit
f9c367548f
2 changed files with 12 additions and 1 deletions
|
|
@ -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})"
|
||||
|
|
|
|||
11
tests/test_utils/test_markdown.py
Normal file
11
tests/test_utils/test_markdown.py
Normal file
|
|
@ -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\\\."
|
||||
Loading…
Add table
Add a link
Reference in a new issue