🪄 Python Telegram Markdown Converter | No more formatting headaches.
Convert Raw Markdown to Telegram's MarkdownV2 Style
Introducing a robust Python library that enhances Markdown formatting support in Telegram. This library automatically processes various Markdown inputs, preserving the original formatting without requiring manual escaping. It simplifies your Markdown interactions on Telegram with seamless auto-processing.
Before this library, sending and rendering unknown Markdown content (like GitHub's README files) required complex parsing and reconstruction. Now, you can easily handle this and customize it for better results!
Utilizing a custom renderer, the library has been tested in a real server environment to ensure its efficacy.
For those interested, there is also a Node.js version of the library with the same name: npm:telegramify-markdown
To install the library, run:
pip install telegramify-markdown
or, if you use pdm
:
pdm add telegramify-markdown
Links [text](url)
Images ![alt](url)
|-|-|
----
*Italic*
and **Bold**
__Underline__
(if customize.strict_markdown
is False)>
~~Strikethrough~~
||Spoiler||
~Strikethrough~
[!NOTE] Despite
~Strikethrough~
being mentioned in Telegram's official documentation, it can't be parsed as strikethrough.
import telegramify_markdown
from telegramify_markdown import customize
customize.markdown_symbol.head_level_1 = "📌" # If you want, Customizing the head level 1 symbol
customize.markdown_symbol.link = "🔗" # If you want, Customizing the link symbol
customize.strict_markdown = True # If you want to use __underline__ as underline, set it to False, or it will be converted to bold.
customize.cite_expandable = True # If you want to enable expandable citation, set it to True.
markdown_text = """
# Title
## Subtitle
### Subsubtitle
#### Subsubsubtitle
'\_', '\*', '\[', '\]', '\(', '\)', '\~', '\`', '\>', '\#', '\+', '\-', '\=', '\|', '\{', '\}', '\.', '\!'
_ , * , [ , ] , ( , ) , ~ , ` , > , # , + , - , = , | , { , } , . , !
We will remove the \ symbol from the original text.
**bold text**
*bold text*
_italic text_
__underline__
~no valid strikethrough~
~~strikethrough~~
||spoiler||
*bold _italic bold ~~italic bold strikethrough ||italic bold strikethrough spoiler||~~ __underline italic bold___ bold*
__underline italic bold__
[link](https://www.google.com)
- [ ] Uncompleted task list item
- [x] Completed task list item
> Quote
> Multiline Quote In Markdown it's not possible to send multiline quote in telegram without using code block or html tag but telegramify_markdown can do it.
> If you quote is too long, it will be automatically set in expandable citation.
> This is the second line of the quote.
> This is the third line of the quote.
> This is the fourth line of the quote.
> This is the fifth line of the quote.
```python
print("Hello, World!")
This is inline code
output as follows:
Exp 1 | Exp 2 |
---|---|