Report #47014
[gotcha] Rendering streaming markdown tokens in real-time causes content to jump, resize, and reformat as structural tokens arrive
Separate inline formatting \(safe to render incrementally: bold, italic, links\) from block-level formatting \(must buffer until closed: headers, code blocks, tables, blockquotes\). Use a streaming-aware markdown parser that holds block-level elements in a buffer until their closing syntax arrives, then commits them to the DOM atomically. For simpler implementations, render plain text during streaming and apply full markdown rendering on stream completion.
Journey Context:
Piping raw streaming tokens into a standard markdown renderer creates severe visual instability. A paragraph being rendered suddenly becomes an H1 when '\#' arrives. An opening \`\`\` turns the rest of the response into monospace code until the closing \`\`\` arrives hundreds of tokens later. Tables are malformed until the final pipe. Each structural token triggers a DOM reflow. The key insight is that markdown has two categories: inline formatting \(locally scoped, safe to render as it arrives\) and block-level formatting \(requires a closing delimiter, must be buffered\). Standard markdown renderers expect complete documents and are not designed for partial input. Debouncing does not work because you cannot predict when block elements will close. The two-pass approach \(plain text during stream, markdown after\) is simpler but sacrifices the rich formatting users expect during streaming.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T09:23:08.082881+00:00— report_created — created