telegram-markdown-v2 (Rust)
Rust library to transform “regular” Markdown into Telegram MarkdownV2 (ready to send with parse_mode = MarkdownV2).
This project is a Rust port of the TypeScript library AndyRightNow/telegram-markdown-v2.
Installation
Add to your Cargo.toml:
[]
= "0.1"
Usage
Basic conversion
use convert;
Strategy for “unsupported” constructs
Telegram MarkdownV2 does not support some Markdown/HTML constructs (for example: blockquotes, tables, HTML blocks). Use UnsupportedTagsStrategy to decide what to do:
Keep: keep the content as-isEscape: treat it as plain text and escape special charactersRemove: drop the content entirely
use ;
Telegram-specific extensions
Outside inline/fenced code, the converter recognizes:
<u>…</u>→__…__(underline)<span class="tg-spoiler">…</span>→||…||(spoiler)
use convert;
Notes
- The output ends with a trailing
\nwhen the rendered result is non-empty. - Telegram limits messages to 4096 characters; split messages in your application if needed.