fix: prevent italic regex from spanning newlines in Telegram formatter
The italic regex \*([^*]+)\* used [^*] which matches newlines, causing bullet lists with * markers to be incorrectly converted to italic text. Changed to [^*\n]+ to prevent cross-line matching. Adds 43 tests for _escape_mdv2 and format_message covering code blocks, bold/italic, headers, links, mixed formatting, and the regression case.
This commit is contained in:
parent
6366177118
commit
b759602483
2 changed files with 365 additions and 1 deletions
|
|
@ -372,8 +372,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,
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue