Formatting options#

Markdown & HTML formatting functions.

New in version 4.5.1.

telebot.formatting.escape_html(content: str) str#

Escapes HTML characters in a string of HTML.

Parameters

content – The string of HTML to escape.

telebot.formatting.escape_markdown(content: str) str#

Escapes Markdown characters in a string of Markdown.

Credits: simonsmh

Parameters

content – The string of Markdown to escape.

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 – Strings to format.

  • separator – The separator to use between each string.

telebot.formatting.hbold(content: str, escape: bool = True) str#

Returns an HTML-formatted bold string.

Parameters
  • content – The string to bold.

  • escape – True if you need to escape special characters.

telebot.formatting.hcode(content: str, escape: bool = True) str#

Returns an HTML-formatted code string.

Parameters
  • content – The string to code.

  • escape – True if you need to escape special characters.

Hide url of an image.

Parameters

url

Returns

str

telebot.formatting.hitalic(content: str, escape: bool = True) str#

Returns an HTML-formatted italic string.

Parameters
  • content – The string to italicize.

  • escape – True if you need to escape special characters.

Returns an HTML-formatted link string.

Parameters
  • content – The string to link.

  • url – The URL to link to.

  • escape – True if you need to escape special characters.

telebot.formatting.hpre(content: str, escape: bool = True, language: str = '') str#

Returns an HTML-formatted preformatted string.

Parameters
  • content – The string to preformatted.

  • escape – True if you need to escape special characters.

telebot.formatting.hspoiler(content: str, escape: bool = True) str#

Returns an HTML-formatted spoiler string.

Parameters
  • content – The string to spoiler.

  • escape – True if you need to escape special characters.

telebot.formatting.hstrikethrough(content: str, escape: bool = True) str#

Returns an HTML-formatted strikethrough string.

Parameters
  • content – The string to strikethrough.

  • escape – True if you need to escape special characters.

telebot.formatting.hunderline(content: str, escape: bool = True) str#

Returns an HTML-formatted underline string.

Parameters
  • content – The string to underline.

  • escape – True if you need to escape special characters.

telebot.formatting.mbold(content: str, escape: bool = True) str#

Returns a Markdown-formatted bold string.

Parameters
  • content – The string to bold.

  • escape – True if you need to escape special characters.

telebot.formatting.mcode(content: str, language: str = '', escape: bool = True) str#

Returns a Markdown-formatted code string.

Parameters
  • content – The string to code.

  • escape – True if you need to escape special characters.

telebot.formatting.mitalic(content: str, escape: bool = True) str#

Returns a Markdown-formatted italic string.

Parameters
  • content – The string to italicize.

  • escape – True if you need to escape special characters.

Returns a Markdown-formatted link string.

Parameters
  • content – The string to link.

  • url – The URL to link to.

  • escape – True if you need to escape special characters.

telebot.formatting.mspoiler(content: str, escape: bool = True) str#

Returns a Markdown-formatted spoiler string.

Parameters
  • content – The string to spoiler.

  • escape – True if you need to escape special characters.

telebot.formatting.mstrikethrough(content: str, escape: bool = True) str#

Returns a Markdown-formatted strikethrough string.

Parameters
  • content – The string to strikethrough.

  • escape – True if you need to escape special characters.

telebot.formatting.munderline(content: str, escape: bool = True) str#

Returns a Markdown-formatted underline string.

Parameters
  • content – The string to underline.

  • escape – True if you need to escape special characters.