Skip to content

Commit

Permalink
Added the ability to make blockquote expandable
Browse files Browse the repository at this point in the history
  • Loading branch information
EgorKhabarov committed Jul 10, 2024
1 parent 3ea0fc1 commit 77e3f13
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions telebot/formatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ def hide_link(url: str) -> str:
return f'<a href="{url}">&#8288;</a>'


def mcite(content: str, escape: Optional[bool]=True) -> str:
def mcite(content: str, escape: Optional[bool] = True, expandable: Optional[bool] = False) -> str:
"""
Returns a Markdown-formatted block-quotation string.
Expand All @@ -333,11 +333,16 @@ def mcite(content: str, escape: Optional[bool]=True) -> str:
:param escape: True if you need to escape special characters. Defaults to True.
:type escape: :obj:`bool`
:param expandable: True if you need the quote to be expandable. Defaults to False.
:type expandable: :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')])
content = "\n".join([">" + line for line in content.split("\n")])
if expandable:
return f"**{content}||"
return content


Expand Down

0 comments on commit 77e3f13

Please sign in to comment.