Formatting options¶
Markdown & HTML formatting functions.
- telebot.formatting.apply_html_entities(text: str, entities: List | None = None, custom_subs: Dict[str, str] | None = None) str¶
Apply HTML formatting to text based on provided entities. Handles nested and overlapping entities correctly.
- telebot.formatting.escape_html(content: str) str¶
Escapes HTML characters in a string of HTML.
- Parameters:
content (
str) – The string of HTML to escape.- Returns:
The escaped string.
- Return type:
str
- telebot.formatting.escape_markdown(content: str) str¶
Escapes Markdown characters in a string of Markdown.
Credits to: simonsmh
- Parameters:
content (
str) – The string of Markdown to escape.- Returns:
The escaped string.
- Return type:
str
- telebot.formatting.format_text(*args, separator='\n')¶
Formats a list of strings into a single string.
format_text( # just an example mbold('Hello'), mitalic('World') )
- Parameters:
args (
str) – Strings to format.separator (
str) – The separator to use between each string.
- Returns:
The formatted string.
- Return type:
str
- telebot.formatting.hbold(content: str, escape: bool | None = True) str¶
Returns an HTML-formatted bold string.
- Parameters:
content (
str) – The string to bold.escape (
bool) – True if you need to escape special characters. Defaults to True.
- Returns:
The formatted string.
- Return type:
str
- telebot.formatting.hcite(content: str, escape: bool | None = True, expandable: bool | None = False) str¶
Returns a html-formatted block-quotation string.
- Parameters:
content (
str) – The string to bold.escape (
bool) – True if you need to escape special characters. Defaults to True.expandable (
bool) – True if you need the quote to be expandable. Defaults to False.
- Returns:
The formatted string.
- Return type:
str
- telebot.formatting.hcode(content: str, escape: bool | None = True) str¶
Returns an HTML-formatted code string.
- Parameters:
content (
str) – The string to code.escape (
bool) – True if you need to escape special characters. Defaults to True.
- Returns:
The formatted string.
- Return type:
str
- telebot.formatting.hide_link(url: str) str¶
Hide url of an image.
- Parameters:
url (
str) – The url of the image.- Returns:
The hidden url.
- Return type:
str
- telebot.formatting.hitalic(content: str, escape: bool | None = True) str¶
Returns an HTML-formatted italic string.
- Parameters:
content (
str) – The string to italicize.escape (
bool) – True if you need to escape special characters. Defaults to True.
- Returns:
The formatted string.
- Return type:
str
- telebot.formatting.hlink(content: str, url: str, escape: bool | None = True) str¶
Returns an HTML-formatted link string.
- Parameters:
content (
str) – The string to link.url (
str) – The URL to link to.escape (
bool) – True if you need to escape special characters. Defaults to True.
- Returns:
The formatted string.
- Return type:
str
- telebot.formatting.hpre(content: str, escape: bool | None = True, language: str = '') str¶
Returns an HTML-formatted preformatted string.
- Parameters:
content (
str) – The string to preformatted.escape (
bool) – True if you need to escape special characters. Defaults to True.language (
str) – The programming language of the code. Defaults to an empty string.
- Returns:
The formatted string.
- Return type:
str
- telebot.formatting.hspoiler(content: str, escape: bool | None = True) str¶
Returns an HTML-formatted spoiler string.
- Parameters:
content (
str) – The string to spoiler.escape (
bool) – True if you need to escape special characters. Defaults to True.
- Returns:
The formatted string.
- Return type:
str
- telebot.formatting.hstrikethrough(content: str, escape: bool | None = True) str¶
Returns an HTML-formatted strikethrough string.
- Parameters:
content (
str) – The string to strikethrough.escape (
bool) – True if you need to escape special characters. Defaults to True.
- Returns:
The formatted string.
- Return type:
str
- telebot.formatting.hunderline(content: str, escape: bool | None = True) str¶
Returns an HTML-formatted underline string.
- Parameters:
content (
str) – The string to underline.escape (
bool) – True if you need to escape special characters. Defaults to True.
- Returns:
The formatted string.
- Return type:
str
- telebot.formatting.mbold(content: str, escape: bool | None = True) str¶
Returns a Markdown-formatted bold string.
- Parameters:
content (
str) – The string to bold.escape (
bool) – True if you need to escape special characters. Defaults to True.
- Returns:
The formatted string.
- Return type:
str
- telebot.formatting.mcite(content: str, escape: bool | None = True, expandable: bool | None = False) str¶
Returns a Markdown-formatted block-quotation string.
- Parameters:
content (
str) – The string to bold.escape (
bool) – True if you need to escape special characters. Defaults to True.expandable (
bool) – True if you need the quote to be expandable. Defaults to False.
- Returns:
The formatted string.
- Return type:
str
- telebot.formatting.mcode(content: str, language: str = '', escape: bool | None = True) str¶
Returns a Markdown-formatted code string.
- Parameters:
content (
str) – The string to code.language (
str) – The programming language of the code. Defaults to an empty string.escape (
bool) – True if you need to escape special characters. Defaults to True.
- Returns:
The formatted string.
- Return type:
str
- telebot.formatting.mitalic(content: str, escape: bool | None = True) str¶
Returns a Markdown-formatted italic string.
- Parameters:
content (
str) – The string to italicize.escape (
bool) – True if you need to escape special characters. Defaults to True.
- Returns:
The formatted string.
- Return type:
str
- telebot.formatting.mlink(content: str, url: str, escape: bool | None = True) str¶
Returns a Markdown-formatted link string.
- Parameters:
content (
str) – The string to link.url (str) – The URL to link to.
escape (
bool) – True if you need to escape special characters. Defaults to True.
- Returns:
The formatted string.
- Return type:
str
- telebot.formatting.mspoiler(content: str, escape: bool | None = True) str¶
Returns a Markdown-formatted spoiler string.
- Parameters:
content (
str) – The string to spoiler.escape (
bool) – True if you need to escape special characters. Defaults to True.
- Returns:
The formatted string.
- Return type:
str
- telebot.formatting.mstrikethrough(content: str, escape: bool | None = True) str¶
Returns a Markdown-formatted strikethrough string.
- Parameters:
content (
str) – The string to strikethrough.escape (
bool) – True if you need to escape special characters. Defaults to True.
- Returns:
The formatted string.
- Return type:
str
- telebot.formatting.munderline(content: str, escape: bool | None = True) str¶
Returns a Markdown-formatted underline string.
- Parameters:
content (
str) – The string to underline.escape (
bool) – True if you need to escape special characters. Defaults to True.
- Returns:
The formatted string.
- Return type:
str