Uh oh!
There was an error while loading. Please reload this page.
fix(rich-md-editor): raw-HTML-block fragmentation + styling follow-up - #5440
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview UI: raw HTML/footnote snippets drop the warning-tinted background in favor of the same neutral surface as inline Tests add structural assertions ( Reviewed by Cursor Bugbot for commit c043d9c. Configure here. |
Greptile SummaryThis PR fixes raw HTML handling in the rich markdown editor. The main changes are:
Confidence Score: 5/5This looks safe to merge.
Important Files Changed
Reviews (5): Last reviewed commit: "fix(rich-md-editor): mask HTML comments ..." | Re-trigger Greptile |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
0269c2a to
64c7b40Comparewaleedlatif1
commented
Jul 6, 2026
waleedlatif1
commented
Jul 6, 2026
@cursor review |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- RawHtmlBlock previously delegated to marked's built-in block-HTML tokenizer, which (per CommonMark's HTML-block-type-6 rule) stops at the first blank line. A real <details> with a paragraph inside — the common case — fragmented into a raw chip, an ordinary rendered paragraph, and a second raw chip, stranding real content in between. - Fixed with a custom block-level tokenizer that scans to the tag's matching close (reusing the balanced open/close depth-tracking already built for nested inline HTML), spanning blank lines, restricted to CommonMark's own block-tag whitelist (details, div, table, section, etc.) so tags that can legitimately start a paragraph (em, a, span, code, kbd) are left untouched. - Dropped the warning-colored tint on raw HTML/footnote blocks (color-mix with --warning read as an error state) in favor of the same neutral surface as existing code blocks — the hover badge alone now signals "this is raw, unrendered text".
…ention edge cases - CommonMark allows up to 3 leading spaces before a block-HTML opening line; the new block tokenizer required column 0, so an indented <details>/<div> still fragmented across blank lines. Fixed by splitting off the leading indent, matching against the rest, and stitching the indent back onto raw. - The open-tag and balanced-close regexes stopped at the first `>`, even inside a quoted attribute value (e.g. data-example="a > b"), producing wrong match lengths and miscounting a same-tag mention inside the quoted value as a real nested tag. Replaced with an attribute-aware pattern that treats a full quoted value (including any interior >) as one unit. - The balanced-tag scan couldn't distinguish real markup from a tag name mentioned inside inline code or a fenced code block. Now masks code regions (same-length filler, positions preserved) before scanning, so a properly-escaped mention (backticks or a fenced example) is never miscounted. A genuinely bare, unescaped mention outside code remains a known, inherent limitation of regex-based tag matching (shared by real HTML parsers given the same ambiguous input) — verified this can never lose data or hang, only reflow to a stable fixpoint on save.
…ce scan - maskCodeRegions's fenced-code regex required fence markers at column 0, so a fence quoted inside a markdown blockquote (each line prefixed with `> `) wasn't recognized, leaving tag mentions inside it visible to the balance scanner. Extended the fence pattern to tolerate an optional blockquote prefix on both the opening and closing fence line. - BLOCK_HTML_TAG_NAMES includes several void elements (link, meta, base, hr, ...) that have no closing tag at all. The block tokenizer only treated an explicit self-closing `/>` as complete, so a void tag without one would scan the rest of the document for a `</meta>` that will never appear, risking a false match on a later same-name mention. Now reuses the existing VOID_TAGS set (already used by the inline tokenizer) to treat these as complete right after the open tag. Also restored `hr` to the whitelist, which was accidentally dropped when transcribing marked's tag list.
7ef46eb to
0ea00f3Comparewaleedlatif1
commented
Jul 6, 2026
waleedlatif1
commented
Jul 6, 2026
@cursor review |
Uh oh!
There was an error while loading. Please reload this page.
…code masking maskCodeRegions's fence pattern handled a blockquoted fence (`> \`\`\``) but still required the fence marker at column 0 otherwise, missing CommonMark's independent up-to-3-space fence indent tolerance this codebase already relies on elsewhere (FENCE_OPEN/FENCE_CLOSE in markdown-parse.ts). An indented fence's tag-name mention could still end a whitelisted block early. Fixed by combining both allowances in one prefix pattern (zero-or-more blockquote levels, each independently followed by up to 3 more spaces of indent).
waleedlatif1
commented
Jul 6, 2026
waleedlatif1
commented
Jul 6, 2026
@cursor review |
Uh oh!
There was an error while loading. Please reload this page.
A tag-name mention inside an HTML comment (e.g. `<!-- see </div> below -->`) inside a whitelisted raw HTML block could still be matched by the balance scan and end the block early, fragmenting it. maskCodeRegions already masked fenced/inline code the same way; extend it to mask comments too.
waleedlatif1
commented
Jul 6, 2026
waleedlatif1
commented
Jul 6, 2026
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit c043d9c. Configure here.
Summary
Follow-up to #5438 (already merged) — two issues found during manual testing after merge:
RawHtmlBlockdelegated to marked's built-in block-HTML tokenizer, which (per CommonMark's HTML-block-type-6 rule) stops at the first blank line. A real<details>with a paragraph inside — the common case — fragmented into a raw chip, an ordinary rendered paragraph, and a second raw chip, stranding real content in between. Fixed with a custom block-level tokenizer that scans to the tag's matching close (reusing the balanced open/close depth-tracking already built for nested inline HTML), spanning blank lines, restricted to CommonMark's own block-tag whitelist (details,div,table,section, etc.) — tags that can legitimately start a paragraph (em,a,span,code,kbd) are left untouched.color-mixwith--warningread as an error/warning state, which isn't the right signal) in favor of the same neutral surface as existing code blocks — the hover badge alone now conveys "this is raw, unrendered text".Type of Change
Testing
Added 8 new tests specifically targeting the fragmentation fix (structural node-count assertions, not just string round-trip): multi-paragraph
<details>, multi-paragraph<div>, nested same-tag blocks across blank lines, a paragraph starting with a non-whitelisted inline tag (regression guard so<em>/<a>still parse as real marks), a stray non-whitelisted tag alone on a line, an unterminated tag (no crash), a comment spanning blank lines, and a table+code-block adjacency check. 236/236 tests passing in the directory, fulltsc --noEmitclean, biome clean.Checklist