Repository navigation
Conversation
Mark the trailing unclosed fenced code block's <pre> with data-streaming so custom pre components can defer highlighting until the fence closes. The site's CodeBlock now reads the flag instead of a 180ms settle debounce.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
βΉοΈ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with π while any review is running, comments if it has suggestions, and reacts with π once all reviews finish with no findings. |
Deploying streamdown with Β
|
| Latest commit: |
259ed06
|
| Status: | Β β Β Deploy successful! |
| Preview URL: | https://f562bffc.streamdown-6nu.pages.dev |
| Branch Preview URL: | https://feat-streaming-fence-flag.streamdown-6nu.pages.dev |
There was a problem hiding this comment.
π‘ Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 259ed061ac
βΉοΈ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with π.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| return inFence ? lang : null; | ||
| }; | ||
|
|
||
| const FENCE_OPEN_RE = /^[\t >]*(`{3,}|~{3,})/; |
There was a problem hiding this comment.
Reject indented code when detecting fence openers
When a trailing indented code block begins with four or more spaces followed by backticks, such as ```js\n const x = 1, Markdown parses it as an indented <pre>, not a fenced block. This regex nevertheless accepts unlimited leading whitespace, so the block receives data-streaming and consumers may wait indefinitely for a closing fence that does not apply. Restrict fence indentation to the Markdown-supported range rather than accepting arbitrary spaces or tabs.
Useful? React with πΒ / π.
| const lastNewline = source.lastIndexOf('\n'); | ||
| if (lastNewline === -1) return true; |
There was a problem hiding this comment.
Recognize carriage returns when locating the closing fence
For Markdown using CR-only line endings, such as `````js\rconst x = 1\r``` ``, the parser recognizes a complete fenced block, but lastIndexOf('\n') returns `-1` and this function unconditionally classifies it as unclosed. The resulting `
` remains marked `data-streaming`, preventing consumers such as the site highlighter from upgrading the completed block; handle `\r` line boundaries as well as `\n`.Useful? React with πΒ / π.
Summary
rehypeStreamingFence: marks the trailing unclosed fenced code block's<pre>withdata-streaming, so customprecomponents can skip highlighting / diagram rendering until the fence closes.Streamdown, ahead of user rehype plugins.CodeBlockreads the flag instead of the 180msuseSettleddebounce; also stops briefly showing a stale highlight after a stream restart.Why
Browser trace (production build, ~200 cps, 120-line TS fence): a
precomponent that re-highlights with shiki on every reveal commit spent 880ms in shiki vs 57ms total markdown parse β 43% of main-thread busy time, growing quadratically with fence length. Markdown re-parsing itself stays ~1% of wall time and is not the bottleneck.Notes
Streamdownhas no end-of-stream signal.Test plan
vitest runβ 208 passed (13 new cases for the flag)tscfor lib and site