diff --git a/aiogram/utils/text_decorations.py b/aiogram/utils/text_decorations.py
index 5b9502b7..125547e8 100644
--- a/aiogram/utils/text_decorations.py
+++ b/aiogram/utils/text_decorations.py
@@ -22,6 +22,7 @@ class TextDecoration:
italic: str
code: str
pre: str
+ pre_language: str
underline: str
strikethrough: str
quote: Callable[[AnyStr], AnyStr]
@@ -34,8 +35,12 @@ class TextDecoration:
:param text:
:return:
"""
- if entity.type in ("bold", "italic", "code", "pre", "underline", "strikethrough"):
+ if entity.type in ("bold", "italic", "code", "underline", "strikethrough"):
return getattr(self, entity.type).format(value=text)
+ if entity.type == "pre":
+ return (self.pre_language if entity.language else self.pre).format(
+ value=text, language=entity.language
+ )
elif entity.type == "text_mention":
return self.link.format(value=text, link=f"tg://user?id={entity.user.id}")
elif entity.type == "text_link":
@@ -94,6 +99,7 @@ html_decoration = TextDecoration(
italic="{value}",
code="{value}",
pre="
{value}",
+ pre_language='{value}',
underline="{value}",
strikethrough="test"],
[html_decoration, MessageEntity(type="pre", offset=0, length=5), "test"], + [ + html_decoration, + MessageEntity(type="pre", offset=0, length=5, language="python"), + '
test',
+ ],
[html_decoration, MessageEntity(type="underline", offset=0, length=5), "test"],
[
html_decoration,
@@ -51,6 +56,11 @@ class TestTextDecoration:
[markdown_decoration, MessageEntity(type="italic", offset=0, length=5), "_test_\r"],
[markdown_decoration, MessageEntity(type="code", offset=0, length=5), "`test`"],
[markdown_decoration, MessageEntity(type="pre", offset=0, length=5), "```test```"],
+ [
+ markdown_decoration,
+ MessageEntity(type="pre", offset=0, length=5, language="python"),
+ "```python\ntest\n```",
+ ],
[markdown_decoration, MessageEntity(type="underline", offset=0, length=5), "__test__"],
[
markdown_decoration,