Convert Markdown to a format usable by Telegram.
Project description
telegramify-markdown
🪄 Python Telegram markdown Converter | No more worrying about formatting.
Raw Markdown -> Telegram MarkdownV2 Style
Before this repo came along, when you wanted to send and render unknown Markdown content (like GitHub's Readme), you had to use complex parsing and reconstruction methods. Today, you can make it easier and customize it to achieve better results!
I used a custom Render to achieve this, using a real environment server to verify the applicability of this tool.
Installation
pip install telegramify-markdown
or if you use pdm
:
pdm add telegramify-markdown
Use case
import telegramify_markdown
from telegramify_markdown.customize import markdown_symbol
markdown_symbol.head_level_1 = "📌" # If you want, Customizing the head level 1 symbol
markdown_symbol.link = "🔗" # If you want, Customizing the link symbol
md = """
# 一级标题 `c!ode` # 一级标题 `code`
[Link!AA](https://www.example.com)
[key!]: https://www.google.com "a title!"
[这是!链接2][asd!asd](https://www.example.com)
[rttt]()
![PIC](https://www.example.com/image.jpg)
1. Order!ed
1. Order!ed sub
- Unord*-.ered
"""
converted = telegramify_markdown.convert(md)
print(converted)
output as follows:
*📌 一级标题 `c\!ode` \# 一级标题 `code`*
[Link\!AA](https://www\.example\.com)
🔗[a title\!](https://www\.google\.com)
\[这是\!链接2\][asd\!asd](https://www\.example\.com)
[rttt]()
🖼[PIC](https://www\.example\.com/image\.jpg)
1\. Order\!ed
1\. Order\!ed sub
⦁ Unord\*\-\.ered
Note: Telegram Server automatically processes the double of
\
(\\
) again (even after escaping), which is beyond the control of us.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for telegramify_markdown-0.1.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1305ed2f72892a52d7fc6b9bc67958eb4fd593ee0f5255c29e4bbee55afde373 |
|
MD5 | 23c7be317c3dc0946585f227d8c8be3d |
|
BLAKE2b-256 | 0aa09bf74ecc08ab13977610a7119c9f0e86fd3db44bab9d4de6e4052cccf7c9 |
Hashes for telegramify_markdown-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0ea42ec0d7f15a42fa674d63c682c4cedf22a844ac9ee592f6ceec41d01e5714 |
|
MD5 | 080fa3351a6d34de1bb7c9ae2c96f4cd |
|
BLAKE2b-256 | e9329eae134683249215495718ed5d96512f08e34b7b25caea88241b4df493f6 |