Telegram does not escape some markdown characters, for example:
This works fine
_test\_test_
But this return parse error
*test\*test*
What I do wrong?
The way to escape a special character is to add a backslash before it, e.g., I do not want \_italic text\_ here . Similarly, if # does not indicate a section heading, you may write \# This is not a heading . As mentioned in Section 4.12, a sequence of whitespaces will be rendered as a single regular space.
Telegram supports styled text using message entities. A client that wants to send styled messages would simply have to integrate a Markdown/HTML parser, and generate an array of message entities by iterating through the parsed tags.
String escapedMsg = toEscapeMsg .replace("_", "\\_") .replace("*", "\\*") .replace("[", "\\[") .replace("`", "\\`");
Do not escape ]
character. If [
is escaped, ]
is treated like a normal character.
The only workaround is to use HTML
in the parse_mode
https://core.telegram.org/bots/api#html-style
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With