Skip to content

fix(shared): inline HTML before a code fence no longer turns sample text into a heading - #43725

Merged
juliusmarminge merged 2 commits into
pingdotgg:mainfrom
saphid:hunter/c-698fa37883
Nov 26, 2026
Merged

juliusmarminge merged 2 commits into
pingdotgg:mainfrom
saphid:hunter/c-698fa37883

Conversation

@saphid

@saphid saphid commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

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 # literal and render it as an <h1> heading followed by an empty code fence. Whole-file CommonMark rendering keeps # literal inside <pre><code>.

Deterministic repro on origin/main (2e830d77334715a72602d907ed7d78d8cfc430d1, also reproduced on rebased base a066eb0935da44bbb16571638138c218bfdbf775)

Create the exact synthetic fixture in a task-owned project:

node --input-type=module <<'JS'
import { writeFileSync } from "node:fs";
writeFileSync("inline-html-fence.md", "<b>" + "x".repeat(4100) + "</b>\n```md\n\n# literal\n```");
JS

Open inline-html-fence.md in the File Preview panel (rendered Markdown mode), or pass its text to splitMarkdown(text) with the default 4 KB chunk target.

  • Observed: splitMarkdown splits into 2 chunks (chunk[0] ends at the blank line inside the fence; chunk[1] begins with # literal\n\``), so the preview renders

    literal

    followed by an empty
    `.
  • Expected: splitMarkdown keeps the paragraph and following code fence in 1 chunk so # literal renders inside <pre><code class="language-md"> and not as an <h1>.

Change

Split HTML_BLOCK_START in packages/shared/src/markdownChunks.ts into 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 consume splitMarkdown from @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

  • Base failure (2e830d77334715a72602d907ed7d78d8cfc430d1): vp test run packages/shared/src/markdownChunks.test.ts -t "treats inline HTML paragraphs differently from block and standalone HTML tags" failed with AssertionError: expected [ { …(2) }, …(1) ] to have a length of 1 but got 2.
  • Head pass (bcf52b4e05901049f66c366b9823382cfe1543a3, rebased on a066eb0935da): vp test run packages/shared/src/markdownChunks.test.ts passed 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: exit 0 on committed HEAD bcf52b4e0590 (format, lint, knip 1/2 & 2/2, typecheck across 37 packages, and 20 tests across 2 affected files).
  • Runtime before/after evidence: before-after-transcript.md shows chunks.length changing from 2 (chunk[1] rendering <h1>literal</h1>) on base to 1 (matching whole-document remark-parse/remark-rehype output 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 splitMarkdown parser with no client or UI code changes.

Authored by Gemini 4 Neon (Antigravity).

@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Nov 26, 2026
@coderabbitai

coderabbitai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The Markdown chunker now uses separate patterns for CommonMark type-6 and type-7 HTML blocks. Tests cover heading-like text inside HTML elements and a fenced block after inline HTML.

Changes: HTML block detection

Layer / File(s) Summary
Recognize and test HTML blocks
packages/shared/src/markdownChunks.ts, packages/shared/src/markdownChunks.test.ts
The chunker uses separate patterns for type-6 tags and complete standalone type-7 tags. Matching blocks end at a blank line. Tests cover heading-like text inside paragraph and span elements, and a fenced block following inline HTML.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: juliusmarminge, marve10s

Merge Risk: Minimal · up to ca6ed

This fixes a Markdown preview bug where a fenced code block after inline HTML could render # literal as a heading. The change is small and covered by shared tests, so no actionable merge-blocking risk is identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the actual change: inline HTML before a code fence no longer makes sample text render as a heading. It matches the changed HTML-block detection in markdownChunks.ts and the bug describ…
Description check Passed The description follows the template sections (Problem, Change, Scope, Verification). It gives a deterministic reproduction, explains the fix by splitting HTML_BLOCK_START into type-6 and type-7 patte…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the actual change: inline HTML before a code fence no longer makes sample text render as a heading. It matches the changed HTML-block detection in markdownChunks.ts and the bug described in the PR objectives. It is specific and follows conventional commit form, so it passes.

Full details: Description check

Explanation

The description follows the template sections (Problem, Change, Scope, Verification). It gives a deterministic reproduction, explains the fix by splitting HTML_BLOCK_START into type-6 and type-7 patterns, and states the scope reason. Verification lists focused test runs, a base failure and head pass, and a check run. It also states what was not shown (live web, Electron, and native mobile UI captures). The template does not require UI screenshots here because the change is in shared parser logic, so the description is mostly complete and passes.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between bcf52b4 and ca6edb5.

Files selected for processing: 1

  • packages/shared/src/markdownChunks.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

@juliusmarminge juliusmarminge added the takeover:in-progress A takeover lead is working on this PR label Nov 26, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@juliusmarminge

Copy link
Copy Markdown
Member

Evidence

Opened 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.

Before After
a066eb0935 ca6edb50e1
Before: literal rendered as a heading between empty code blocks After: # literal remains inside one fenced code block

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.

Scenario driver

Not shown:

  • The short control file was seeded but not opened; this proof compares the reported failing fixture on both commits.

@juliusmarminge juliusmarminge added takeover:ready Takeover done; auto-lands when gates pass and removed takeover:in-progress A takeover lead is working on this PR labels Nov 26, 2026
@juliusmarminge
juliusmarminge merged commit 6bec332 into pingdotgg:main Nov 26, 2026
60 checks passed
@juliusmarminge juliusmarminge removed the takeover:ready Takeover done; auto-lands when gates pass label Nov 26, 2026
github-actions Bot pushed a commit to Ryoku-dev/hyakki that referenced this pull request Nov 27, 2026
…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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 changed lines (additions + deletions). vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants