mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-06-15 07:14:08 +00:00
Move the fenced-code-block-aware splitting logic out of the shared split_message helper (used by Signal, Slack, Discord, Weixin, etc.) and into a Telegram-specific _split_telegram_markdown function. The shared split_message remains a plain-text chunker. The Telegram channel now uses _split_telegram_markdown for its raw Markdown paths that feed _markdown_to_telegram_html, preventing broken HTML rendering when splits fall inside fenced code blocks. Also fixes a regression where content beginning with whitespace before a fence could emit a whitespace-only chunk. Addresses review feedback on #4257.
8 lines
220 B
Python
8 lines
220 B
Python
from nanobot.utils.helpers import split_message
|
|
|
|
|
|
def test_split_message_no_code_blocks_unchanged():
|
|
content = "alpha beta gamma delta"
|
|
|
|
assert split_message(content, max_len=12) == ["alpha beta", "gamma delta"]
|