fix(parser): ignore slide separators inside HTML comments#2561
Merged
Conversation
✅ Deploy Preview for slidev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
@slidev/client
create-slidev
create-slidev-theme
@slidev/parser
@slidev/cli
@slidev/types
commit: |
Contributor
There was a problem hiding this comment.
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 on lines
283
to
287
| inHtmlComment = advanceHtmlCommentState(rawLine, false) | ||
| if (inHtmlComment) | ||
| continue | ||
|
|
||
| if (line.startsWith('---')) { |
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
src:slide importsTest Plan
pnpm vitest test/parser.test.ts