[Utils] Spoiler Function for Chat Formatting (#4754)

* [Utils] Additional chat formatting functions

* [Utils] Updated docstrings to unify with other docstrings

* [Utils] Spoiler feature for chat_formatting

* Fixes for black style

Co-authored-by: kreusada <67752638+kreus7@users.noreply.github.com>
This commit is contained in:
kreusada 2021-02-11 21:31:47 +00:00 committed by GitHub
parent 1920212eda
commit 82595df730
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -145,6 +145,28 @@ def italics(text: str, escape_formatting: bool = True) -> str:
return "*{}*".format(text) return "*{}*".format(text)
def spoiler(text: str, escape_formatting: bool = True) -> str:
"""Get the given text as a spoiler.
Note: By default, this function will escape ``text`` prior to making the text a spoiler.
Parameters
----------
text : str
The text to be marked up.
escape_formatting : `bool`, optional
Set to :code:`False` to not escape markdown formatting in the text.
Returns
-------
str
The marked up text.
"""
text = escape(text, formatting=escape_formatting)
return "||{}||".format(text)
def bordered(*columns: Sequence[str], ascii_border: bool = False) -> str: def bordered(*columns: Sequence[str], ascii_border: bool = False) -> str:
"""Get two blocks of text inside borders. """Get two blocks of text inside borders.