mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-09 09:22:03 +00:00
More comments in markdown util.
This commit is contained in:
parent
479308bac3
commit
5853973db8
1 changed files with 86 additions and 0 deletions
|
|
@ -28,48 +28,134 @@ def _md(string, symbols=('', '')):
|
|||
|
||||
|
||||
def text(*content, sep=' '):
|
||||
"""
|
||||
Join all elements with separator
|
||||
|
||||
:param content:
|
||||
:param sep:
|
||||
:return:
|
||||
"""
|
||||
return _join(*content, sep=sep)
|
||||
|
||||
|
||||
def bold(*content, sep=' '):
|
||||
"""
|
||||
Make bold text (Markdown)
|
||||
|
||||
:param content:
|
||||
:param sep:
|
||||
:return:
|
||||
"""
|
||||
return _md(_join(*content, sep=sep), symbols=MD_SYMBOLS[0])
|
||||
|
||||
|
||||
def hbold(*content, sep=' '):
|
||||
"""
|
||||
Make bold text (HTML)
|
||||
|
||||
:param content:
|
||||
:param sep:
|
||||
:return:
|
||||
"""
|
||||
return _md(_join(*content, sep=sep), symbols=MD_SYMBOLS[4])
|
||||
|
||||
|
||||
def italic(*content, sep=' '):
|
||||
"""
|
||||
Make italic text (Markdown)
|
||||
|
||||
:param content:
|
||||
:param sep:
|
||||
:return:
|
||||
"""
|
||||
return _md(_join(*content, sep=sep), symbols=MD_SYMBOLS[1])
|
||||
|
||||
|
||||
def hitalic(*content, sep=' '):
|
||||
"""
|
||||
Make italic text (HTML)
|
||||
|
||||
:param content:
|
||||
:param sep:
|
||||
:return:
|
||||
"""
|
||||
return _md(_join(*content, sep=sep), symbols=MD_SYMBOLS[5])
|
||||
|
||||
|
||||
def code(*content, sep=' '):
|
||||
"""
|
||||
Make mono-width text (Markdown)
|
||||
|
||||
:param content:
|
||||
:param sep:
|
||||
:return:
|
||||
"""
|
||||
return _md(_join(*content, sep=sep), symbols=MD_SYMBOLS[2])
|
||||
|
||||
|
||||
def hcode(*content, sep=' '):
|
||||
"""
|
||||
Make mono-width text (HTML)
|
||||
|
||||
:param content:
|
||||
:param sep:
|
||||
:return:
|
||||
"""
|
||||
return _md(_join(*content, sep=sep), symbols=MD_SYMBOLS[6])
|
||||
|
||||
|
||||
def pre(*content, sep='\n'):
|
||||
"""
|
||||
Make mono-width text block (Markdown)
|
||||
|
||||
:param content:
|
||||
:param sep:
|
||||
:return:
|
||||
"""
|
||||
return _md(_join(*content, sep=sep), symbols=MD_SYMBOLS[3])
|
||||
|
||||
|
||||
def hpre(*content, sep='\n'):
|
||||
"""
|
||||
Make mono-width text block (HTML)
|
||||
|
||||
:param content:
|
||||
:param sep:
|
||||
:return:
|
||||
"""
|
||||
return _md(_join(*content, sep=sep), symbols=MD_SYMBOLS[7])
|
||||
|
||||
|
||||
def link(title, url):
|
||||
"""
|
||||
Format URL (Markdown)
|
||||
|
||||
:param title:
|
||||
:param url:
|
||||
:return:
|
||||
"""
|
||||
return "[{0}]({1})".format(_escape(title), url)
|
||||
|
||||
|
||||
def hlink(title, url):
|
||||
"""
|
||||
Format URL (HTML)
|
||||
|
||||
:param title:
|
||||
:param url:
|
||||
:return:
|
||||
"""
|
||||
return "<a href=\"{0}\">{1}</a>".format(url, _escape(title))
|
||||
|
||||
|
||||
def escape_md(*content, sep=' '):
|
||||
"""
|
||||
Escape markdown text
|
||||
|
||||
E.g. for usernames
|
||||
|
||||
:param content:
|
||||
:param sep:
|
||||
:return:
|
||||
"""
|
||||
return _escape(_join(*content, sep=sep))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue