]> git.giacomolli.uk - onechat/commitdiff
Split long replies between Markdown blocks
authorAnderson A. Giacomolli <redacted>
Sat, 7 Nov 2026 15:23:09 +0000 (12:23 -0300)
committerAnderson A. Giacomolli <redacted>
Sat, 7 Nov 2026 15:23:09 +0000 (12:23 -0300)
splitRich cuts the Markdown of a reply into parts of at most 32768
bytes, the limit of the Markdown of one rich message. It cuts after a
blank line outside a code block, so a table, a code block, and a
paragraph stay whole, and each part renders as the reply would. When no
such cut fits, it cuts after a line break outside a code block, and then
inside a code block, which it closes at the end of the part and opens
again with the same fence line in the next part. A single line over the
limit is cut at the limit, never inside a character.

The Bot API allows 32768 characters of rendered text and does not say if
a character is a byte. The bytes of the Markdown are at least the
characters of the text, so a part is never over the limit. The bot does
not use splitRich yet.

Issue: fec23f9


No differences found