/telegramify-markdown

🪄 Markdown To Telegram Markdown Converter Python| No more worrying about formatting.

Primary LanguagePythonMIT LicenseMIT

telegramify-markdown

PyPI version Downloads

🪄 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

Supported Features

  • Headings (1-6)
  • Links text
  • Images ![alt]
  • Lists (Ordered, Unordered)
  • Tables |-|-|
  • Horizontal Rule ----
  • Text Styles
  • Underline
  • Code Blocks
  • Inline Code
  • Block Quotes
  • ~~Strikethrough~~
  • Task Lists
  • ~Strikethrough~
  • ||Spoiler||
  • Tg Emoji
  • Tg User At

Note

Since mistletoe doesn't parse - [] TODO and Spoiler, we can't apply it. ~Strikethrough~ is incorrect, even if it comes from official documentation, please use ~~Strikethrough~~ format.

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 = """
'\_', '\*', '\[', '\]', '\(', '\)', '\~', '\`', '\>', '\#', '\+', '\-', '\=', '\|', '\{', '\}', '\.', '\!'
_ , * , [ , ] , ( , ) , ~ , ` , > , # , + , - , = , | , { , } , . , !
**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
```python
print("Hello, World!")
```
This is `inline code`
1. First ordered list item
2. Another item
    - Unordered sub-list.
1. Actual numbers don't matter, just that it's a number
"""
converted = telegramify_markdown.convert(md)
print(converted)

output as follows:

.github/result.png