Skip to content

Commit

Permalink
Added mcite and hcite support to formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
coder2020official committed Jan 12, 2024
1 parent be2c1e4 commit a8252d7
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions telebot/formatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,3 +324,37 @@ def hide_link(url: str) -> str:
:rtype: :obj:`str`
"""
return f'<a href="{url}">&#8288;</a>'


def mcite(content: str, escape: Optional[bool]=True) -> str:
"""
Returns a Markdown-formatted block-quotation string.
:param content: The string to bold.
:type content: :obj:`str`
:param escape: True if you need to escape special characters. Defaults to True.
:type escape: :obj:`bool`
:return: The formatted string.
:rtype: :obj:`str`
"""
content = escape_markdown(content) if escape else content
content = '\n'.join(['>' + line for line in content.split('\n')])
return content


def hcite(content: str, escape: Optional[bool]=True) -> str:
"""
Returns a html-formatted block-quotation string.
:param content: The string to bold.
:type content: :obj:`str`
:param escape: True if you need to escape special characters. Defaults to True.
:type escape: :obj:`bool`
:return: The formatted string.
:rtype: :obj:`str`
"""
return '<blockquote>{}</blockquote>'.format(escape_html(content) if escape else content)

0 comments on commit a8252d7

Please sign in to comment.