Skip to content

fix(shared): keep fenced examples intact after inline HTML - #43803

Merged
juliusmarminge merged 11 commits into
pingdotgg:mainfrom
StiensWout:wf/find-fc0e4d552c73f8977c689a38
Nov 26, 2026
Merged

juliusmarminge merged 11 commits into
pingdotgg:mainfrom
StiensWout:wf/find-fc0e4d552c73f8977c689a38

Conversation

@StiensWout

Copy link
Copy Markdown
Contributor

Large Markdown previews could split a code fence after a standalone inline HTML tag and render a sample heading as a document heading. The splitter now uses bounded tag classification and defers cuts when it is uncertain, while continuing to track fences and other multiline blocks through their closers. A browser test asserts that the sample text and literal heading render inside the same code block.

Related: #43647, #23503, #33969, #43654, #43673, #43711, #43709

Reproduction on main

Commit f08bafe07f (main), in the running web app:

  1. Open the web app and a project.
  2. Add a Markdown file whose first paragraph is plain text of at least 4,100 characters, with no blank line in it.
  3. On the next line, with no blank line above it, write a line that contains only .
  4. On the next lines, write a fenced code block that starts at the beginning of the line with a md fence, then the words Sample Markdown, a blank line, the line # Sample heading, and the closing fence.
  5. Open the Files panel.
  6. Open that Markdown file.
  7. Click Show rendered markdown.

Sample heading appears as a heading of the document, outside the code example. Expected: Sample heading stays inside the code example.

The cause is at packages/shared/src/markdownChunks.ts:84. Ran pnpm scenarios:prove scripts/scenarios/markdown-inline-tag-before-fence.e2e.ts --target web with the repro scenario added: it failed in 2 of 2 runs on a clean checkout, with expect.not.toBeVisible failed in the output.

Evidence

Environment: The web app in Chromium on Linux x64, a fresh checkout.

Proven: the repro fails at the test commit 012fc62e1a and passes on the head d18e7f21a8, both on main f4b252309f.

Before After
Commit 012fc62e1a d18e7f21a8
Result ASSERTION_FAILED: expect.not.toBeVisible failed passed
sample heading Before: sample heading After: sample heading
failure Before: failure

Before the fix, recorded:

https://pub-b182a4071edc4521829926b34990540b.r2.dev/files/9086af4f-fdd8-482f-91c9-a9bad5fbd862/before-recording.webm

After the fix, recorded:

https://pub-b182a4071edc4521829926b34990540b.r2.dev/files/1a6ac44e-10ce-4adc-9691-ca6521608eaf/after-recording.webm

Outside view: a person sees it in the running web app by following the steps under Reproduction on main.

Tests

  • 012fc62e1a adds the failing test, alone, before the fix.
  • pnpm exec vp run check:changed f4b252309ff9c5acc18c180141d92c6ac08b0027 passed on head.

Not in this change

  • An ambiguous tag can delay the next chunk boundary until a blank line and the end of any open block. Oversized chunks use the existing source preview.

Who did the work

  • Repro written by GPT 6.2 Sol, in Codex
  • Outside view by Grok 4.7, in Grok
  • Duplicate check judged by Claude Opus 5.5, in Claude Code
  • Written by GPT 6.2 Sol, in Codex
  • Trimmed by Claude Opus 5.5, in Claude Code
  • Reviewed by Claude Opus 5.5, in Claude Code, and by GPT 6.2 Sol, in Codex, and by Gemini 4 Neon, in Antigravity
  • Reproduction, checks and proof run by a program on base and head, not by an agent

Made in T3 Code by GPT 6.2 Sol, Claude Opus 5.5, Grok 4.7 and Gemini 4 Neon

StiensWout and others added 7 commits November 26, 2026 23:31
Co-authored-by: GPT 6.2 Sol <codex@openai.com>
Co-authored-by: GPT 6.2 Sol <codex@openai.com>
Co-authored-by: GPT 6.2 Sol <codex@openai.com>
Co-authored-by: GPT 6.2 Sol <codex@openai.com>
Co-authored-by: GPT 6.2 Sol <codex@openai.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:L 100-499 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 chunker uses bounded GFM-enabled parsing to identify standalone HTML and suppresses cuts while classification remains unresolved. Unit tests cover Markdown chunk boundaries. An end-to-end test checks rendering of a fenced sample after an inline tag.

Changes: Markdown Chunking

Layer / File(s) Summary
Bounded HTML classification and chunk boundaries
packages/shared/src/markdownChunks.ts
The chunker uses a frozen parser with remark-parse and remark-gfm within configured per-flow and total parsing limits. It tracks ambiguous HTML and suppresses chunk cuts and link-definition recognition while classification is unresolved.
Chunk and preview regression coverage
packages/shared/src/markdownChunks.test.ts, scripts/scenarios/markdown-inline-tag-before-fence.e2e.ts
Unit tests cover chunk boundaries around fences, comments, math, horizontal rules, oversized regions, and quote continuations. The end-to-end test checks that a heading inside the fenced sample does not render as a heading.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Suggested reviewers: juliusmarminge, saphid, marve10s

Merge Risk: Minimal · up to 1a2cd

This change keeps fenced examples intact after an inline HTML tag in large Markdown previews. No actionable merge-blocking risk was identified. An ambiguous tag can delay the next chunk boundary until a blank line, which the author notes as intended.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "fix(shared): keep fenced examples intact after inline HTML" matches the main change. The raw summary and objectives show the splitter now classifies standalone HTML tags with a bounded pars…
Description check Passed The description follows the template. It has a problem statement with reproduction steps and environment, a change section that explains the bounded tag classification and deferred cuts, a scope secti…
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 "fix(shared): keep fenced examples intact after inline HTML" matches the main change. The raw summary and objectives show the splitter now classifies standalone HTML tags with a bounded parser and defers cuts when uncertain, so fenced code blocks are not split. The title is specific and follows conventional commit style. It names the affected package and the behavior fixed.

Full details: Description check

Explanation

The description follows the template. It has a problem statement with reproduction steps and environment, a change section that explains the bounded tag classification and deferred cuts, a scope section that links related issues but does not clearly link a single bug issue or explain why no issue is needed, and a verification section with focused test evidence, before/after results, and screenshots. It names the models that did the work. The scope section is the weakest part. It lists related issues but does not say which issue shows the bug, or whether a maintainer asked for the PR. The description is mostly complete, so it 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 af8120a and 1a2cd9e.

Files selected for processing: 1

  • packages/shared/src/markdownChunks.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
juliusmarminge and others added 4 commits November 26, 2026 22:49
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Splitting a long document with many prose paragraphs followed by a lone
tag line parsed every such paragraph, so splitMarkdown grew from a linear
scan to seconds on multi-megabyte files. One 16 KB parse budget now covers
the whole document; past it, tags fall back to the existing hold until the
next blank line.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…8977c689a38

Keep main's multi-line link definitions and gate them on the unresolved
inline HTML hold, as the single-line definitions were.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@juliusmarminge

Copy link
Copy Markdown
Member

Evidence

Created release.md with a long paragraph, immediately followed by and a Markdown fence containing Sample Markdown, a blank line, and literal # Sample heading. Opened the same file preview flow on both commits and selected Show rendered markdown. Chromium, 1280×800, light theme, fresh synthetic state with Replay (dev).

Before After
Before: sample heading escapes fence After: sample heading stays inside fence
da36859cbe — real heading and empty trailing block 1a2cd9ea93 — both lines in one code block

Scenario source. Before recording, after recording.

scenarios:prove exited 0: fails on base and passes on head.

@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 b79a254 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
…#43803)

Co-authored-by: Julius Marminge <julius0216@outlook.com>
(cherry picked from commit b79a254)
github-actions Bot pushed a commit to Ryoku-dev/hyakki that referenced this pull request Nov 27, 2026
…#43803)

Co-authored-by: Julius Marminge <julius0216@outlook.com>
(cherry picked from commit b79a254)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 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