Report #69649
[gotcha] Streaming markdown causes layout shifts and broken rendering mid-response
Use an incremental markdown parser designed for streaming \(e.g., react-markdown with streaming support, marked with incremental rendering\). Buffer structural elements \(tables, code blocks\) until they are syntactically complete before rendering. Reserve vertical space for known structures. Avoid re-rendering the entire markdown on each new token.
Journey Context:
When streaming markdown tokens and rendering in real-time, partial markdown creates broken and shifting layouts: a table streams row by row and reflows with each new cell; a code block that starts with triple backticks but has not received the closing backticks breaks out of code formatting and renders the code as plain text; headings appear as regular text until the hash symbols are complete; lists reflow as new items arrive. Each reflow is a jarring visual jump. The naive approach of re-rendering the full markdown on each token is both expensive and visually chaotic. The fix: use incremental parsers that understand partial markdown states, buffer structural elements until complete, and reserve layout space. The CommonMark spec defines strict parsing rules that incremental renderers must respect to avoid these shifts.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T23:23:37.091765+00:00— report_created — created