Skip to content

fix(parser): ignore slide separators inside HTML comments#2561

Merged
antfu merged 3 commits into
slidevjs:mainfrom
pi-dal:fix/html-comment-slide-separators
May 7, 2026
Merged

fix(parser): ignore slide separators inside HTML comments#2561
antfu merged 3 commits into
slidevjs:mainfrom
pi-dal:fix/html-comment-slide-separators

Conversation

@pi-dal
Copy link
Copy Markdown
Contributor

@pi-dal pi-dal commented Apr 28, 2026

Summary

Test Plan

  • pnpm vitest test/parser.test.ts

@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 28, 2026

Deploy Preview for slidev ready!

Name Link
🔨 Latest commit de9382d
🔍 Latest deploy log https://app.netlify.com/projects/slidev/deploys/69fc3d8ced26cb0008f7f2c9
😎 Deploy Preview https://deploy-preview-2561--slidev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@antfu antfu requested a review from Copilot May 7, 2026 05:13
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 7, 2026

Open in StackBlitz

@slidev/client

npm i https://pkg.pr.new/@slidev/client@2561

create-slidev

npm i https://pkg.pr.new/create-slidev@2561

create-slidev-theme

npm i https://pkg.pr.new/create-slidev-theme@2561

@slidev/parser

npm i https://pkg.pr.new/@slidev/parser@2561

@slidev/cli

npm i https://pkg.pr.new/@slidev/cli@2561

@slidev/types

npm i https://pkg.pr.new/@slidev/types@2561

commit: de9382d

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates Slidev’s markdown parser slicing logic to ignore slide separators/frontmatter boundaries that appear inside multi-line HTML comments, addressing incorrect slide counting (notably in the VS Code slide tree, per #2560).

Changes:

  • Track multi-line HTML comment state during parsing to skip --- boundaries that occur inside <!-- ... -->.
  • Apply the same behavior to both async (parse) and sync (parseSync) parser implementations.
  • Add a regression test to ensure commented src: slide imports don’t create extra slides.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
test/parser.test.ts Adds a regression test ensuring separators inside HTML comments don’t produce extra slides.
packages/parser/src/core.ts Adds HTML-comment state tracking to ignore separators/frontmatter boundaries within multi-line HTML comments.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/parser/src/core.ts Outdated
Comment on lines 283 to 287
inHtmlComment = advanceHtmlCommentState(rawLine, false)
if (inHtmlComment)
continue

if (line.startsWith('---')) {
Comment thread packages/parser/src/core.ts Outdated
Comment on lines 362 to 366
inHtmlComment = advanceHtmlCommentState(rawLine, false)
if (inHtmlComment)
continue

if (line.startsWith('---')) {
Reorders the parser loop so `---`/code-fence detection runs before the
HTML-comment state is advanced. Previously a real separator like
`----<!--` was swallowed by the comment-skip branch, making the slide
boundary disappear. Applies the review suggestion from slidevjs#2561 to both
`parse` and `parseSync`, and adds a regression test.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@antfu antfu merged commit b31e4aa into slidevjs:main May 7, 2026
20 checks passed
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.

3 participants