Skip to content

Telegram: bold section headers lack paragraph spacing when preceded by single newline #18558

@silentconsensus-bot

Description

@silentconsensus-bot

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:

  1. LLM outputs markdown with single \n before bold section headers
  2. createMarkdownIt() is configured with breaks: false (CommonMark standard) — single \n = softbreak (same paragraph)
  3. markdownToIR() converts: paragraph_close\n\n, softbreak\n
  4. renderTelegramHtml() preserves literal \n characters (no <p> or <br> tags)
  5. Telegram Bot API renders \n as line break (no gap), \n\n as 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() with breaks: false
  • appendParagraphSeparator() — adds \n\n
  • renderTokens() softbreak case — adds \n
  • renderTelegramHtml() / markdownToTelegramHtml() with headingStyle: "none"

Metadata

Metadata

Assignees

No one assigned

    Labels

    staleMarked as stale due to inactivity

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions