Skip to content

fix(auto-close): ignore raw-text tags inside code fences - #659

Open
onmax wants to merge 2 commits into
comarkdown:mainfrom
onmax:fix/auto-close-fenced-raw-text
Open

onmax wants to merge 2 commits into
comarkdown:mainfrom
onmax:fix/auto-close-fenced-raw-text

Conversation

@onmax

@onmax onmax commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

What

scanBlocks in packages/comark/src/auto-close.ts now runs the RAW_TEXT_OPEN_RE check only when fenceLen === 0, so lines inside a fenced code block do not enter raw-text mode. I added a test in packages/comark/test/auto-close.test.ts for fenced <script setup> and <style> lines.

Why

When a line inside a code fence starts with <script, <style, <pre, or <textarea and the fence has no matching closing tag, autoCloseMarkdown appends an extra :: to a complete document and parse renders it as a stray paragraph. scanBlocks ran the raw-text check before the fence check and ignored fenceLen, so the scanner switched into raw-text mode and skipped both the closing fence and the ::. A diff of a Vue file inside a component hits this often, since a hunk shows <script setup lang="ts"> without </script>.

Closes #658


Read this PR faster

Summary by CodeRabbit

  • Bug Fixes
    • Corrected auto-closing behavior when fenced code contains raw HTML-like text, so it’s handled as code and surrounding Markdown and component syntax are closed appropriately.

@onmax
onmax requested a review from farnabaz as a code owner December 2, 2026 16:39
…ener

An outdented <script> line that ends a list item's fence still opens raw text, so ::a inside it is not read as a component.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@vercel

vercel Bot commented Dec 2, 2026

Copy link
Copy Markdown

@onmax is attempting to deploy a commit to the NuxtLabs Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The scanner now checks whether a nonblank line is left of a list item containing an open fence before checking for a raw HTML opener. A regression test covers script- and style-like text inside fenced content, including component and list contexts.

Changes: Fenced HTML handling

Layer / File(s) Summary
List-fence reset before raw HTML detection
packages/comark/src/auto-close.ts, packages/comark/test/auto-close.test.ts
When a nonblank line is left of a list item containing an open fence, scanBlocks ends the fence and resets list tracking before raw HTML detection. The regression test checks fenced script/style-like text, preservation of existing closures, and completion of trailing Markdown and component syntax.

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

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: larbish

Merge Risk: Minimal · up to bee08

This change stops script and style text inside fenced code from hiding the closing fence, so a stray component delimiter is no longer appended. No actionable merge risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "fix(auto-close): ignore raw-text tags inside code fences" matches the main change. The objectives say the PR stops raw-text tags such as script and style inside fenced code from making scan…
Linked Issues check Passed [#658] requires that a raw-text opener (<script, <style, <pre, <textarea) inside a code fence not switch scanBlocks into raw-text mode, so that autoCloseMarkdown does not append a stray `:…
Out of Scope Changes check Passed The change to packages/comark/src/auto-close.ts is small, per the summary (+7/-7). It contains the fenceLen === 0 guard for the raw-text check, which implements #658. It also contains the outdent …
Full details: Title check

Explanation

The title "fix(auto-close): ignore raw-text tags inside code fences" matches the main change. The objectives say the PR stops raw-text tags such as script and style inside fenced code from making scanBlocks skip the closing fence and trailing component delimiter. The raw summary confirms the scanner change and the added tests for fenced script and style content. The title names the module, the fix type, and the affected case, so a reviewer scanning history can identify the primary change.

Full details: Linked Issues check

Explanation

[#658] requires that a raw-text opener (&lt;script, &lt;style, &lt;pre, &lt;textarea) inside a code fence not switch scanBlocks into raw-text mode, so that autoCloseMarkdown does not append a stray ::. At head, scanBlocks in packages/comark/src/auto-close.ts runs the raw-text check only when fenceLen === 0 (if (fenceLen === 0 &amp;&amp; c0 === 60)). A line inside an open fence therefore no longer sets raw. The closing fence and the trailing :: are then processed normally. This matches the reported reproduction. The PR also adds a line-left-of-list-item check that closes the fence before the raw-text check. This handles an outdented &lt;script&gt; that ends a list-item fence, so it opens raw text as the follow-up commit describes. The PR adds a test in packages/comark/test/auto-close.test.ts for fenced &lt;script setup&gt; and &lt;style&gt; lines. I could not read the test file diff in this review; the test content is established only from the PR summary. The implementation requirement is met from the code evidence.

Full details: Out of Scope Changes check

Explanation

The change to packages/comark/src/auto-close.ts is small, per the summary (+7/-7). It contains the fenceLen === 0 guard for the raw-text check, which implements #658. It also contains the outdent check that ends a list-item fence before raw-tag detection. That check is the related follow-up case in the PR objectives: a raw-text opener that is outdented past the fence's list item must still open raw text. Both changes concern how fenced content interacts with raw-text detection, so neither is unrelated. The test addition in packages/comark/test/auto-close.test.ts supports the fix. I could not read the test diff directly, so this assessment does not verify the test body.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
Fix failing CI checks

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

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.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: dbb2c590-807c-4fb4-9f1c-a74a61c032f1
Commits

Reviewing files that changed from the base of the PR and between 2418413 and bee0870.

Files selected for processing: 2

  • packages/comark/src/auto-close.ts
  • packages/comark/test/auto-close.test.ts

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

@coldtea-pr-lens

coldtea-pr-lens Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Architecture

Walkthrough of Ignore raw text HTML blocks inside open code fences, in three steps

Read this PR faster


Data flow

No data-flow sequence changed in this PR.


Review

✨ Nothing flagged · reviewed bee0870


Tip

Open a diagram on the canvas, then press W or click play to walk through the change one step at a time

🪧 More tips
  • Run npx skills add coldteadotai/pr-lens, then tell your coding agent: "Diagram the change you just made with PR Lens and attach it to the pull request."
  • Run npx @coldtea/pr-lens-cli analyze --base origin/main on a branch, then npx @coldtea/pr-lens-cli render .pr-lens/graph.json. Same lenses, your own model key, before the pull request exists
  • Click the link under each diagram to open it on a canvas you can zoom, pan and step through
  • The diagrams are links. Click one to open it on the canvas, then press W or click play to walk through the change
  • The CLI's render reads .github/pr-lens.yml and applies your renames, exclusions and lane pins at draw time
  • Set github.comment.collapsed: true in .github/pr-lens.yml to fold the comment behind one View architecture… row. Drawing still runs as before
  • Set github.draw: on-demand in .github/pr-lens.yml and PR Lens stops drawing pull requests on its own. Comment @pr-lens draw on a pull request when you want that one drawn
  • Add .github/workflows/pr-lens.yml with coldteadotai/pr-lens/packages/action@v0 and your model provider's key as its api-key to run PR Lens from your own CI. Any /chat/completions endpoint works
  • After a push, tick Redraw to draw the latest commit
  • Switch GitHub to dark mode and the diagrams follow. The moving dots are this pull request's data in motion
  • Set github.description: false in .github/pr-lens.yml to stop PR Lens adding buttons to your PR descriptions

Thanks for using PR Lens! It's free for OSS. If it helped, a star helps other teams find it.  Star PR Lens on GitHub

@codspeed

codspeed Bot commented Dec 2, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

1 warning

⚠️ 3 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

✅ 48 untouched benchmarks


Comparing onmax:fix/auto-close-fenced-raw-text (bee0870) with main (2418413)

Open in CodSpeed

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

autoClose adds a stray :: when a fence holds an unclosed <script line

1 participant