Formatting Errors - mkotb/Telegram-Errors GitHub Wiki

If you tell the API to parse your text as Markdown or HTML, it may throw errors if the text is not formatted correctly.

In the case of markdown, it will send an error with the following message: Can't parse message text: Can't find end of the entity starting at byte offset x. In the case of HTML formatting, however, it will send an error with the following message: Can't parse message text: Can't found end tag corresponding to start tag at byte offset x.

This issue may be caused by a simple typo or error, or a case where user input isn't escaped.

Escaping your text for Telegram can be a little confusing due to the lack of documentation out there:

Escaping Markdown

After a little bit of trial and error, I found out by chance that there is an extremely easy way to escape your text, use square brackets! Merely wrapping your text in square brackets will escape the text, you will have to escape ] though, which you can do by replacing it by ]][. Although a backslash would've been more simple and easy to guess, it's a fairly simple solution.

Escaping HTML

Assuming your text is in unicode, you can escape the HTML as if it were XML:

& becomes &
< becomes &lt;
> becomes &gt;
⚠️ **GitHub.com Fallback** ⚠️