Skip to main content

Plugin mistune for converting markdown into Telegram format.

Project description

Mistune Telegram

Plugin mistune for converting Markdown into Telegram format.

Supported Markdown elements

Markdown element Telegram Markdown Telegram Markdown V2 Telegram HTML
Headings :white_check_mark: :white_check_mark: :white_check_mark:
Paragraphs :white_check_mark: :white_check_mark: :white_check_mark:
Line Breaks :white_check_mark: :white_check_mark: :white_check_mark:
Bold :white_check_mark: :white_check_mark: :white_check_mark:
Italic :white_check_mark: :white_check_mark: :white_check_mark:
Blockquotes :x: :x: :x:
Lists :x: :x: :white_check_mark:
Code :white_check_mark: :white_check_mark: :white_check_mark:
Code blocks :white_check_mark: :white_check_mark: :white_check_mark:
Horizontal rules :white_check_mark: :white_check_mark: :white_check_mark:
Links :white_check_mark: :white_check_mark: :white_check_mark:
Images :x: :x: :x:

Install

$ pip install mistune-telegram

Or use your python package manager.

Usage

Markdown style example:

import mistune
from mistune_telegram import TelegramMarkdownRenderer
telegram_style = mistune.create_markdown(renderer=TelegramMarkdownRenderer())

print(telegram_style(
"""
# Heading level 1
## Heading level 2
### Heading level 3
#### Heading level 4
##### Heading level 5
###### Heading level 6

Heading level 1
===============
Heading level 2
---------------

First paragraph.

Second paragraph.

First line.
Second line.

**bold**
__bold__

*italic*
_italic_

`code`

```
code blocks
```

```python
code blocks written in the Python programming language
```

[link](http://www.example.com/)

"""))

Output:

*Heading level 1*

*Heading level 2*

*Heading level 3*

*Heading level 4*

*Heading level 5*

*Heading level 6*

*Heading level 1*

*Heading level 2*

First paragraph.

Second paragraph.

First line.
Second line.

*bold*
*bold*

_italic_
_italic_

`code`

```
code blocks
```

```python
code blocks written in the Python programming language
```

[link](http://www.example.com/)

MarkdownV2 style example:

import mistune
from mistune.plugins.formatting import strikethrough
from mistune_telegram import TelegramMarkdownV2Renderer

telegram_style = mistune.create_markdown(renderer=TelegramMarkdownV2Renderer(), plugins=[strikethrough])

print(telegram_style(
"""
# Heading level 1
## Heading level 2
### Heading level 3
#### Heading level 4
##### Heading level 5
###### Heading level 6

Heading level 1
===============
Heading level 2
---------------

First paragraph.

Second paragraph.

First line.
Second line.

**bold**
__bold__

*italic*
_italic_

`code`

```
code blocks
```

```python
code blocks written in the Python programming language
```

[link](http://www.example.com/)

~~strikethrough~~

"""))

Output:

*Heading level 1*

*Heading level 2*

*Heading level 3*

*Heading level 4*

*Heading level 5*

*Heading level 6*

*Heading level 1*

*Heading level 2*

First paragraph.

Second paragraph.

First line.
Second line.

*bold*
*bold*

_italic_
_italic_

`code`

```
code blocks
```

```python
code blocks written in the Python programming language
```

[link](http://www.example.com/)

~strikethrough~

HTML style example:

import mistune
from mistune.plugins.formatting import strikethrough
from mistune_telegram import TelegramHTMLRenderer

telegram_style = mistune.create_markdown(renderer=TelegramHTMLRenderer(), plugins=[strikethrough])

print(telegram_style(
"""
# Heading level 1
## Heading level 2
### Heading level 3
#### Heading level 4
##### Heading level 5
###### Heading level 6

Heading level 1
===============
Heading level 2
---------------

First paragraph.

Second paragraph.

First line.
Second line.

**bold**
__bold__

*italic*
_italic_

1. First item
2. Second item

- First item
- Second item

* First item
* Second item

`code`

```
code blocks
```

```python
code blocks written in the Python programming language
```

[link](http://www.example.com/)

~~strikethrough~~

"""))

Output:

<strong>Heading level 1</strong>

<strong>Heading level 2</strong>

<strong>Heading level 3</strong>

<strong>Heading level 4</strong>

<strong>Heading level 5</strong>

<strong>Heading level 6</strong>

<strong>Heading level 1</strong>

<strong>Heading level 2</strong>

First paragraph.

Second paragraph.

First line.
Second line.

<strong>bold</strong>
<strong>bold</strong>

<em>italic</em>
<em>italic</em>

- First item
- Second item

- First item
- Second item

- First item
- Second item

<code>code</code>

<pre>code blocks
</pre>
<pre><code class="language-python">code blocks written in the Python programming language
</code></pre>
<a href="http://www.example.com/">link</a>

<s>strikethrough</s>

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

mistune_telegram-0.5.0.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

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

mistune_telegram-0.5.0-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file mistune_telegram-0.5.0.tar.gz.

File metadata

  • Download URL: mistune_telegram-0.5.0.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.13.5 Linux/6.12.34_1

File hashes

Hashes for mistune_telegram-0.5.0.tar.gz
Algorithm Hash digest
SHA256 fbbf0dc6eff436ce363afcbc8552512ac3e2246cd93418de90663993624058b3
MD5 e3b6d258cdfd7892650987ee984e2d44
BLAKE2b-256 5069e66a39c53706cfe0aba513bed18b815664a4b6b53be7ab58b8dbc559b782

See more details on using hashes here.

File details

Details for the file mistune_telegram-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: mistune_telegram-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 4.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.13.5 Linux/6.12.34_1

File hashes

Hashes for mistune_telegram-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 eff36a38df1d30c4d180a5129d6025206a81f99ffd504c31421e13fecfff1925
MD5 09b954df4f596caf5bcfce51c6446012
BLAKE2b-256 5732231baa72f84e8f817533aea1dec82dded42d48232eae07c48f11e9791961

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