Merge PR #204: fix Telegram italic regex newline bug

Authored by 0xbyt4.

The italic regex [^*]+ matched across newlines, corrupting bullet lists
using * markers (e.g. '* Item one\n* Item two' became italic garbage).
Fixed by adding \n to the negated character class: [^*\n]+.
This commit is contained in:
teknium1 2026-03-04 19:52:03 -08:00
commit 90e6fa2612
2 changed files with 365 additions and 1 deletions

View file

@ -406,8 +406,10 @@ class TelegramAdapter(BasePlatformAdapter):
)
# 6) Convert italic: *text* (single asterisk) → _text_ (MarkdownV2 italic)
# [^*\n]+ prevents matching across newlines (which would corrupt
# bullet lists using * markers and multi-line content).
text = re.sub(
r'\*([^*]+)\*',
r'\*([^*\n]+)\*',
lambda m: _ph(f'_{_escape_mdv2(m.group(1))}_'),
text,
)