Convert reply Markdown to Telegram entities
A converter on the standard library turns the Markdown of a model reply
into plain text and Telegram message entities. It knows bold, italic,
strikethrough, inline code, fenced code blocks with an optional
language, links, and ATX headings, which become bold. Lists, quotes and
tables stay as their text. With entities, the text needs no escaping, so
a mark that does not close only stays as text, and it cannot make
Telegram refuse the message.
Inline marks do not cross a line break, so one open mark cannot change
the rest of a reply. Underscores inside a word stay as text, so
snake_case names do not turn italic, and an asterisk that a space
follows, as in a list item, opens nothing. Code holds no entity. The
offsets and lengths count UTF-16 code units, as Telegram does.
Issue:
3309f9b