← Back to PRs

#8990: fix(markdown): add paragraph separator after top-level lists

by r00k open 2026-02-04 18:07 View on GitHub →
stale
## 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 ![Before - broken spacing](https://i.imgur.com/F6glXkX.jpeg) Notice how "Use Cron when:" runs directly into the previous bullet list with no separation. ### After Fix ![After - clean formatting](https://i.imgur.com/JrBDrXO.jpeg) 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