Skip to main content

md2tgmd is a Markdown to Telegram-specific-markdown converter.

Project description

md2tgmd

English | Chinese

md2tgmd is a Markdown to Telegram-specific-markdown converter.

Feature

  • Supports most of the specific Markdown syntax for Telegram, including: headings, bold, italic, strikethrough, code blocks, links, and quotes.
  • Support the conversion of LaTeX formulas in Markdown to Unicode characters to improve the readability of mathematical formulas in Telegram.
  • Support syntax highlighting for code blocks in Markdown.

Install

pip install md2tgmd

Usage

From md2tgmd import escape

text = '''
# Title

\[ \\varphi(35) = 35 \\left(1 - \\frac{1}{5}\\right) \\left(1 - \\frac{1}{7}\\right) \]

**Bold**
```
# Comment
print(qwer) # ferfe
ni1
```
# bn

# b

# Title
## Subtitle

[1.0.0](http://version.com)
![1.0.0](http://version.com)

- Item 1 -
    - Item 1 -
    - Item 1 -
* Item 2 #
* Item 3 ~

1. Item 1
2. Item 2

sudo apt install mesa-utils # Install

```python

# Comment
print("1.1\n")_
\subsubsection{1.1}
```
\subsubsection{1.1}

And simple text `with-ten`  `with+ten` + some - **symbols**. # `-` inside `with-ten` will not be escaped


```
print("Hello, World!") -
```

Cxy = abs (Pxy)**2/ (Pxx*Pyy)

`a`a-b-c`n`

`-a----++++`++a-b-c`-n-`
`[^``]*`a``b-c``d``
# pattern = r"`[^`]*`-([^`-]*)``
w`-a----`ccccc`-n-`bbbb``a
'''

print(escape(text))


'''
▎*Title*

ϕ(35) = 35(1 - ⅕)(1 - 1/7)

*Bold*
```
\# Comment
print\(qwer\) \# ferfe
ni1
```
▎*bn*

▎*b*

▎*Title*
▎*Subtitle*

[1\.0\.0](http://version\.com)
[1\.0\.0](http://version\.com)


• Item 1 \-

    • Item 1 \-

    • Item 1 \-

• Item 2 \#

• Item 3 \~


1\. Item 1

2\. Item 2

sudo apt install mesa\-utils \# Install

```python

\# Comment
print\("1\.1\\n"\)\_
\\subsubsection\{1\.1\}
```
\\subsubsection\{1\.1\}

And simple text `with-ten`  `with+ten` \+ some \- *symbols*\. \# `-` inside `with-ten` will not be escaped


```
print\("Hello, World\!"\) -
```

Cxy \= abs \(Pxy\)\*\*2/ \(Pxx\*Pyy\)

`a`a\-b\-c`n`

`-a----++++`\+\+a\-b\-c`-n-`
`\[^\`\`\]\*`a\`\`b\-c\`\`d\`\`
▎*pattern*
w`-a----`ccccc`-n-`bbbb\`\`a
'''

Reference

https://github.com/skoropadas/telegramify-markdown

License

This project is licensed under GPLv3, which means you are free to copy, distribute, and modify the software, as long as all modifications and derivative works are also released under the same license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

md2tgmd-0.3.10.tar.gz (28.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

md2tgmd-0.3.10-py3-none-any.whl (28.2 kB view details)

Uploaded Python 3

File details

Details for the file md2tgmd-0.3.10.tar.gz.

File metadata

  • Download URL: md2tgmd-0.3.10.tar.gz
  • Upload date:
  • Size: 28.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for md2tgmd-0.3.10.tar.gz
Algorithm Hash digest
SHA256 613fef6da1c00101ea94d3b8658974f7f21ae8cb84d9ab16814fdd9daa5026f3
MD5 5886c70b27cecb3f7c46f7c5ce0eba05
BLAKE2b-256 bfe7f43e7f79c72d12fd8f038c6523e9b17d98b619d09806376e04e6b0787ad1

See more details on using hashes here.

File details

Details for the file md2tgmd-0.3.10-py3-none-any.whl.

File metadata

  • Download URL: md2tgmd-0.3.10-py3-none-any.whl
  • Upload date:
  • Size: 28.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for md2tgmd-0.3.10-py3-none-any.whl
Algorithm Hash digest
SHA256 bc3d43831a0b1d1db6c03ce66dfc37878b5b76322f39d5c0caea4e7e7c3c6192
MD5 ec8b6d11cdccfa46aca90ee54d1dc633
BLAKE2b-256 51ea2afb0a931873469fc9f81a218153b12678cd100ac42107e30fe178fd6aa9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page