-
-
Notifications
You must be signed in to change notification settings - Fork 53k
Description
Problem
When the LLM outputs markdown with bold text used as section headers (e.g. **Newegg:**, **Bottom line:**), Telegram renders them crammed against the preceding line with no visual gap. This makes longer structured messages hard to read.
Root Cause
Traced the full rendering pipeline:
- LLM outputs markdown with single
\nbefore bold section headers createMarkdownIt()is configured withbreaks: false(CommonMark standard) — single\n= softbreak (same paragraph)markdownToIR()converts:paragraph_close→\n\n,softbreak→\nrenderTelegramHtml()preserves literal\ncharacters (no<p>or<br>tags)- Telegram Bot API renders
\nas line break (no gap),\n\nas paragraph break (with visual gap)
So a single newline before a bold header produces no visual separation in Telegram, even though it looks fine in most other renderers.
Example
Input markdown:
https://example.com/long-url
**Newegg:**
7. NVIDIA 4-slot — out of stock
Produces: url\n<b>Newegg:</b>\n7. NVIDIA... — no gap before the header.
With a blank line before **Newegg:**, it would produce url\n\n<b>Newegg:</b> — proper paragraph spacing.
Suggested Fix
A Telegram-specific post-processing pass in the IR that detects bold-at-start-of-line patterns (e.g. \n**Text:**) and promotes the preceding \n to \n\n to create paragraph spacing. This would only affect the Telegram renderer.
Alternatively: detect lines starting with bold text followed by a colon and ensure they're preceded by a paragraph separator.
Code Locations (bundled dist)
createMarkdownIt()withbreaks: falseappendParagraphSeparator()— adds\n\nrenderTokens()softbreak case — adds\nrenderTelegramHtml()/markdownToTelegramHtml()withheadingStyle: "none"