Report #87473
[gotcha] Markdown rendering breaks during streaming — unclosed code blocks, broken tables, flickering formatting
Use a streaming-aware markdown renderer that gracefully handles incomplete markdown, or implement a buffering layer that delays rendering of structural elements \(code fences, tables, blockquotes\) until their closing syntax arrives. Never pass raw streaming deltas directly to a standard markdown renderer that assumes complete, well-formed input.
Journey Context:
Standard markdown renderers assume complete, well-formed input. During streaming, you frequently have unclosed code fences \(triple backtick with no closing triple backtick\), tables with header rows but no separator rows, and links with display text but no URL. A standard renderer will either produce broken HTML, silently drop content, or render everything after an unclosed fence as monospace code text — then suddenly snap back to normal when the closing fence arrives. The result is a jarring UX where formatting flickers between broken and correct as tokens arrive. Code blocks are the worst offender: an unclosed fence causes all subsequent content \(including normal paragraphs\) to render as code, creating a visual glitch that can last seconds. The CommonMark spec defines parsing as a multi-phase process over complete input, which is fundamentally incompatible with progressive rendering. The fix requires either a custom renderer that treats unclosed elements as "in progress" with visual affordances \(dotted borders, faded backgrounds\) or a buffering strategy that holds structural elements until complete.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T05:24:36.554788+00:00— report_created — created