Repository navigation
fix(shared): nonbreaking spaces no longer end Markdown fences or paragraphs during chunking - #43702
Conversation
…graphs during chunking
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
EvidenceReal web app, Chromium, 1280×800, light theme, fresh synthetic state on each commit. Steps: Render a fenced file with 4,100 x characters followed by a fence plus U+00A0 and
Scenario source · Before recording · After recording The scenario fails on base and passes on head; both short controls pass on both. Not shown:
|
…graphs during chunking (pingdotgg#43702) Co-authored-by: SAPHID <saphid@users.noreply.github.com> Co-authored-by: Julius Marminge <julius0216@outlook.com> (cherry picked from commit a066eb0)
…graphs during chunking (pingdotgg#43702) Co-authored-by: SAPHID <saphid@users.noreply.github.com> Co-authored-by: Julius Marminge <julius0216@outlook.com> (cherry picked from commit a066eb0)








Problem
In
packages/shared/src/markdownChunks.ts,splitMarkdownuses JavaScriptString.prototype.trim()to check whether a line is blank and whether a closing code fence has trailing characters. Because.trim()strips Unicode whitespace such as U+00A0 (nonbreaking space) while the Markdown renderer (@pierre/words) follows CommonMark and treats U+00A0 as content, chunking can split inside a still-open fenced code block, emphasized paragraph, or blank-line HTML block.Deterministic repro on
origin/main(39388dd0d6aebb2de775739b4696249d2f6a2c48):@pierre/wordskeeps# literalinside<pre><code>(no<h1>) and rendersproseas one<p><em>...</em></p>. Chunked rendering viasplitMarkdownsplits both fixtures into 2 chunks, emitting a live<h1>literal</h1>formdand two<p>elements with literal*forprose.Change
Replace
.trim()for blank-line detection (closesAtBlankLineandafterBlankLine) and fence-closer suffix checks (blockCloser) inpackages/shared/src/markdownChunks.tswith an explicit CommonMark ASCII space/tab check allowing the retained CR of CRLF (const BLANK_LINE = /^[ \t]*\r?$/), checkingnext.slice(match[0].length)after the matched closing fence. Because web, desktop, and mobile Markdown file previews all consumesplitMarkdownfrom@t3tools/shared/markdownChunks, this single change covers every client surface.Scope
Small fix for an obvious bug; no issue needed under CONTRIBUTING.md.
Verification
origin/main39388dd0d6aebb2de775739b4696249d2f6a2c48):vp test run packages/shared/src/markdownChunks.test.ts -t "nonbreaking"failed withAssertionError: expected [ { …(2) }, …(1) ] to have a length of 1 but got 2.origin/mainbc0f04da94f6atfebf90b4dbdd0e0243ae637b58c2cf4cde62f664):vp test run packages/shared/src/markdownChunks.test.tspassed 3/3 consecutive runs (14/14 tests, including U+00A0 backtick/tilde fence, prose, HTML block, link-definition continuation, and ASCII space/tab + CRLF controls).vp run check:changedexited0(format,lint,knip,typecheckacross 37 packages, and affected tests all passed).@pierre/wordstranscript: https://gist.github.com/saphid/ad554c04869e422e618e9e3636276c22splitMarkdownand the same@pierre/words/corerenderer used byFileMarkdownPreview. Cross-provider review viaclaudeAgent(claude-opus-5-5) returned503 auth_unavailable, so a self-audit against the diff and checklist was performed instead.Authored by Gemini 4 Neon (Antigravity).