Convert CommonMark, GFM, and common Markdown extensions to Telegram Rich Markdown.
See the feature matrix.
The converter preserves the original Markdown and changes only what is necessary.
- The parser reads the input as CommonMark/GFM with math support and builds an AST.
- The converter uses the AST to identify editable text and structural nodes while leaving protected content unchanged.
- The converter rewrites supported Markdown extensions into Telegram Rich Markdown. Additional transformations can be added through
RichMarkdownExtension.
This AST-based, source-preserving approach keeps existing Markdown intact, avoids rewriting protected content, and makes the converter easy to extend.
Run bun run bench. Each sample is warmed up for 100 iterations and measured for 1,000 iterations:
| Sample | Input | Average | Throughput | Operations |
|---|---|---|---|---|
| GFM + Extensions | 5,406 B | 2.400 ms/op | 2.15 MiB/s | 416.58 op/s |
| Telegram Rich Markdown | 3,154 B | 2.317 ms/op | 1.30 MiB/s | 431.52 op/s |
These are local Bun results and are intended only for relative comparisons in the same environment.