#8990: fix(markdown): add paragraph separator after top-level lists
stale
Cluster:
WhatsApp Enhancements and Fixes
## Problem
List formatting in the IR markdown renderer had two issues on platforms like Telegram, Discord, and WhatsApp:
1. **No spacing after lists** — Content immediately following a list would run into it
2. **Unwanted spacing before lists** — Headers followed by lists had unnecessary blank lines
### Before Fix

Notice how "Use Cron when:" runs directly into the previous bullet list with no separation.
### After Fix

Proper spacing between sections, tight coupling between headers and their lists.
## Solution
1. **Add paragraph separator after top-level lists** — When `listStack.length === 0` on list close, append separator
2. **Skip separator before immediate lists** — On `paragraph_close` and `heading_close`, check if next token is a list and skip the separator if so
## Changes
```typescript
// Add spacing after lists
case "bullet_list_close":
case "ordered_list_close":
state.env.listStack.pop();
if (state.env.listStack.length === 0) {
appendParagraphSeparator(state);
}
break;
// Skip spacing before lists
case "paragraph_close":
case "heading_close":
if (nextToken?.type !== "bullet_list_open" && nextToken?.type !== "ordered_list_open") {
appendParagraphSeparator(state);
}
break;
```
## Impact
Fixes markdown formatting across all platforms using the IR renderer.
Most Similar PRs
#4249: fix(telegram): properly nest link tags inside bold/italic formatting
by pradeeppeddineni · 2026-01-29
67.1%
#20795: fix(markdown): prevent triple newlines after blockquotes
by novalis133 · 2026-02-19
61.6%
#7395: fix(whatsapp): strip markdown bold/italic from URLs before sending
by lailoo · 2026-02-02
60.0%
#2716: Fix #2678: markdown horizontal rules not rendering in web chat
by Ambar-13 · 2026-01-27
59.1%
#17629: fix(telegram): fall back to plain text when HTML formatter produces...
by Glucksberg · 2026-02-16
58.0%
#20419: fix(webchat): explicitly pass gfm and breaks options to marked.parse()
by Limitless2023 · 2026-02-18
57.6%
#6596: Fix pre-existing formatting issues causing CI failures
by ryancnelson · 2026-02-01
56.6%
#23077: fix: block chunker breaks at arbitrary whitespace after minChars - ...
by TarogStar · 2026-02-22
56.2%
#17814: fix(tui): add OSC 8 hyperlinks for wrapped URLs
by Phineas1500 · 2026-02-16
56.2%
#12257: fix(mattermost): default table mode to 'off' for native Markdown re...
by mcaxtr · 2026-02-09
56.2%