mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-12 10:11:52 +00:00
Parse message entities (As HTML and markdown) and update markdown utils (add html mode)
This commit is contained in:
parent
bc917ec9f5
commit
42245fc58a
3 changed files with 84 additions and 3 deletions
|
|
@ -4,7 +4,11 @@ MD_SYMBOLS = (
|
|||
(LIST_MD_SYMBOLS[0], LIST_MD_SYMBOLS[0]),
|
||||
(LIST_MD_SYMBOLS[1], LIST_MD_SYMBOLS[1]),
|
||||
(LIST_MD_SYMBOLS[2], LIST_MD_SYMBOLS[2]),
|
||||
(LIST_MD_SYMBOLS[2] * 3 + '\n', '\n' + LIST_MD_SYMBOLS[2] * 3)
|
||||
(LIST_MD_SYMBOLS[2] * 3 + '\n', '\n' + LIST_MD_SYMBOLS[2] * 3),
|
||||
('<b>', '</b>'),
|
||||
('<i>', '</i>'),
|
||||
('<code>', '</code>'),
|
||||
('<pre>', '</pre>'),
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -24,28 +28,48 @@ def _md(string, symbols=('', '')):
|
|||
|
||||
|
||||
def text(*content, sep=' '):
|
||||
return _md('', _join(*content, sep=sep))
|
||||
return _join(*content, sep=sep)
|
||||
|
||||
|
||||
def bold(*content, sep=' '):
|
||||
return _md(_join(*content, sep=sep), symbols=MD_SYMBOLS[0])
|
||||
|
||||
|
||||
def hbold(*content, sep=' '):
|
||||
return _md(_join(*content, sep=sep), symbols=MD_SYMBOLS[4])
|
||||
|
||||
|
||||
def italic(*content, sep=' '):
|
||||
return _md(_join(*content, sep=sep), symbols=MD_SYMBOLS[1])
|
||||
|
||||
|
||||
def hitalic(*content, sep=' '):
|
||||
return _md(_join(*content, sep=sep), symbols=MD_SYMBOLS[5])
|
||||
|
||||
|
||||
def code(*content, sep=' '):
|
||||
return _md(_join(*content, sep=sep), symbols=MD_SYMBOLS[2])
|
||||
|
||||
|
||||
def hcode(*content, sep=' '):
|
||||
return _md(_join(*content, sep=sep), symbols=MD_SYMBOLS[6])
|
||||
|
||||
|
||||
def pre(*content, sep='\n'):
|
||||
return _md(_join(*content, sep=sep), symbols=MD_SYMBOLS[3])
|
||||
|
||||
|
||||
def hpre(*content, sep='\n'):
|
||||
return _md(_join(*content, sep=sep), symbols=MD_SYMBOLS[7])
|
||||
|
||||
|
||||
def link(title, url):
|
||||
return f"[{_escape(title)}]({url})"
|
||||
|
||||
|
||||
def hlink(title, url):
|
||||
return f"<a href=\"{url}\">{_escape(title)}</a>"
|
||||
|
||||
|
||||
def escape_md(*content, sep=' '):
|
||||
return _escape(_join(*content, sep=sep))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue