Closed
Description
At telegram api docs present parse_mode = MarkdownV2.
I tried to send some data and find, that needed new escape for support this format.
https://core.telegram.org/bots/api#markdownv2-style
public static function escapeMarkdownV2($text)
{
$markdown = [
'#',
'*',
'_',
'=',
'.',
'[',
']',
'(',
')',
// ... rest of markdown entities
];
//'_‘, ’*‘, , ’~‘, ’`‘, ’>‘, ’#‘, ’+‘, ’-‘, ’=‘, ’|‘, ’{‘, ’}‘, ’.‘, ’!‘
$replacements = [
'\#',
'\*',
'\_',
'\\=',
'\.',
'\[',
'\]',
'\(',
'\)',
// ... rest of corresponding escaped markdown
];
return str_replace($markdown, $replacements, $text);
}
Something like this, as i think.