Repository navigation
fix(shared): inline HTML before a code fence no longer turns sample text into a heading - #43725
Conversation
…ext into a heading
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
EvidenceOpened the exact 4,129-byte inline-HTML fixture through the thread’s Files panel, selected Show rendered markdown, and scrolled to the fenced sample. Both captures use Chromium, 1280×800, light theme, and fresh seeded state.
Scenario proof: failed on base with one literal heading and no code sample; passed on head with zero literal headings and the sample inside code. Not shown:
|
…ext into a heading (pingdotgg#43725) Co-authored-by: SAPHID <saphid@users.noreply.github.com> Co-authored-by: Julius Marminge <julius0216@outlook.com> (cherry picked from commit 6bec332)


Problem
When a Markdown paragraph starting with inline HTML (such as
<b>...</b>) is immediately followed by a fenced code block containing a blank line and# literal, chunked file previews cut before# literaland render it as an<h1>heading followed by an empty code fence. Whole-file CommonMark rendering keeps# literalinside<pre><code>.Deterministic repro on
origin/main(2e830d77334715a72602d907ed7d78d8cfc430d1, also reproduced on rebased basea066eb0935da44bbb16571638138c218bfdbf775)Create the exact synthetic fixture in a task-owned project:
Open
inline-html-fence.mdin the File Preview panel (rendered Markdown mode), or pass its text tosplitMarkdown(text)with the default 4 KB chunk target.splitMarkdownsplits into 2 chunks (chunk[0]ends at the blank line inside the fence;chunk[1]begins with# literal\n\``), so the preview rendersliteral
followed by an emptysplitMarkdownkeeps the paragraph and following code fence in 1 chunk so# literalrenders inside<pre><code class="language-md">and not as an<h1>.Change
Split
HTML_BLOCK_STARTinpackages/shared/src/markdownChunks.tsinto CommonMark type-6 block tags (HTML_BLOCK_TAG, which start an HTML block even with trailing text or across lines) and CommonMark type-7 generic tags (HTML_STANDALONE_TAG, which require a complete standalone open or closing tag on the line). Paragraphs starting with inline HTML such as<b>...</b>no longer enter the blank-line-terminated HTML block state, so an immediately following code fence opens normally while real<div>blocks and standalone generic tags keep their CommonMark behavior. Web, desktop, and mobile file previews all consumesplitMarkdownfrom@t3tools/shared/markdownChunks, so no client-specific changes or translations are needed.Scope
Small fix for an obvious bug; no issue needed under CONTRIBUTING.md.
Verification
2e830d77334715a72602d907ed7d78d8cfc430d1):vp test run packages/shared/src/markdownChunks.test.ts -t "treats inline HTML paragraphs differently from block and standalone HTML tags"failed withAssertionError: expected [ { …(2) }, …(1) ] to have a length of 1 but got 2.bcf52b4e05901049f66c366b9823382cfe1543a3, rebased ona066eb0935da):vp test run packages/shared/src/markdownChunks.test.tspassed 18/18 across 3 consecutive runs, covering inline<b>and<span class="lead">paragraphs before fences, a<div>block control, a<div>...</div>block before a fence, and a standalone type-7<span class="box">block.vp run check:changed: exit0on committed HEADbcf52b4e0590(format, lint, knip 1/2 & 2/2, typecheck across 37 packages, and 20 tests across 2 affected files).chunks.lengthchanging from2(chunk[1]rendering<h1>literal</h1>) on base to1(matching whole-documentremark-parse/remark-rehypeoutput verbatim) on head while<div>controls stay unchanged.Not shown: Live web, Electron desktop, or native mobile UI captures; all three surfaces render chunks directly from the shared
splitMarkdownparser with no client or UI code changes.Authored by Gemini 4 Neon (Antigravity).