fix(markdown): keep only inline content when parsing inline HTML - #8169
Conversation
🦋 Changeset detectedLatest commit: cd59360 The changes in this PR will be included in the next version bump. This PR includes changesets to release 74 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
✅ Deploy Preview for tiptap-embed ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository YAML (base), Organization UI (inherited) Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughSummary
WalkthroughThe parser now filters block wrappers from inline HTML content and preserves valid inline text. Tests cover unclosed tags, empty elements, block elements, and hard breaks. A patch changeset documents the fix. ChangesMarkdown inline HTML parsing
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related issues
Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/markdown/__tests__/mixed-html.spec.ts (1)
80-85: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd tests for empty inline HTML cases.
These tests cover unclosed
<b>tags, but not empty<span></span>or unsupported<img>. Add deterministic assertions for these inputs. Verify the exactdoc.contentshape and the absence of nested paragraph nodes.As per coding guidelines, deterministic user-visible behavior in TypeScript requires unit-test coverage.
Also applies to: 87-94
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/markdown/__tests__/mixed-html.spec.ts` around lines 80 - 85, Extend the mixed HTML parsing tests near the existing unclosed <b> case with deterministic cases for empty <span></span> and unsupported <img> input. Assert each exact doc.content structure and explicitly verify that no nested paragraph nodes are produced, matching the parser’s intended user-visible behavior.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.changeset/2026-08-07-markdown-unclosed-inline-html.md:
- Line 5: Shorten the changeset sentence to one brief, user-facing statement
describing the corrected handling of unclosed inline HTML in Markdown, removing
internal parsing details, nested-paragraph terminology, and schema references.
---
Nitpick comments:
In `@packages/markdown/__tests__/mixed-html.spec.ts`:
- Around line 80-85: Extend the mixed HTML parsing tests near the existing
unclosed <b> case with deterministic cases for empty <span></span> and
unsupported <img> input. Assert each exact doc.content structure and explicitly
verify that no nested paragraph nodes are produced, matching the parser’s
intended user-visible behavior.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository YAML (base), Organization UI (inherited)
Review profile: CHILL
Plan: Pro Plus
Run ID: a2fced40-9b48-457a-897c-6d38e4af6186
📒 Files selected for processing (3)
.changeset/2026-08-07-markdown-unclosed-inline-html.mdpackages/markdown/__tests__/mixed-html.spec.tspackages/markdown/src/MarkdownManager.ts
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/markdown/__tests__/mixed-html.spec.ts (1)
102-109: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd coverage for a schema-recognized inline node.
These tests cover text nodes, marks, empty HTML, and block wrappers. They do not verify that a custom inline node survives the schema-based filtering. Add one deterministic inline-node test and assert that it remains in the surrounding paragraph.
As per coding guidelines, add or update unit tests for user-visible behavior when deterministic; use Vitest tests under
packages/**/__tests__/.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/markdown/__tests__/mixed-html.spec.ts` around lines 102 - 109, Add a deterministic Vitest case near the existing mixed HTML parsing tests that parses a schema-recognized custom inline node surrounded by text, then assert the node remains inside the resulting paragraph in document order. Reuse the existing manager and established inline-node schema symbol or fixture rather than introducing unrelated test setup.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/markdown/src/MarkdownManager.ts`:
- Around line 62-63: Update registerExtension() to register extensions before
schema-dependent parsing, keep baseExtensions synchronized with the current
extensions, and invalidate both inlineNodeTypesCache and schemaParseDomTagsCache
whenever registration changes the schema. Ensure schemaParseDomTagsCache is
built from the current extensions rather than only baseExtensions.
---
Nitpick comments:
In `@packages/markdown/__tests__/mixed-html.spec.ts`:
- Around line 102-109: Add a deterministic Vitest case near the existing mixed
HTML parsing tests that parses a schema-recognized custom inline node surrounded
by text, then assert the node remains inside the resulting paragraph in document
order. Reuse the existing manager and established inline-node schema symbol or
fixture rather than introducing unrelated test setup.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository YAML (base), Organization UI (inherited)
Review profile: CHILL
Plan: Pro Plus
Run ID: c132764f-5aab-4d76-94dc-ca3c538f5d61
📒 Files selected for processing (3)
.changeset/2026-08-07-markdown-unclosed-inline-html.mdpackages/markdown/__tests__/mixed-html.spec.tspackages/markdown/src/MarkdownManager.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- .changeset/2026-08-07-markdown-unclosed-inline-html.md
Fixes
Fixes #8168
Changes and Review
Markdown like
<b>123has no closing tag, so the inline HTML parsed to an empty paragraph that got returned into the inline stream, producing a paragraph inside a paragraph. Inline HTML now keeps only the inline content it parses to, somanager.parse('<b>123')returns a plain paragraph with the text123. The same held for other tags that gave a block node inline, for example<span></span>or<h1>. Verify with the added tests inpackages/markdown/__tests__/mixed-html.spec.ts.Checklist
Responsibility