slidev
slidev copied to clipboard
fix: export respect page range
Summary
This PR fixes a bug in the export functionality where the --range parameter was not properly respected during slide export. Previously, when users specified a page range for export (e.g., --range 1-5), the export process would iterate through all slides but only filter the range when determining which pages to export. This resulted in incorrect progress tracking and unnecessary processing of slides outside the specified range.
The fix ensures that only slides within the specified page range are processed and exported, improving both performance and accuracy of the export functionality.
Fix related issue: https://github.com/slidevjs/slidev/issues/2227
Key Changes
- PNG/Screenshot Export: Modified the screenshot capture loop in
exportSlidesto skip slides outside the specified range before processing, preventing unnecessary screenshot operations (packages/slidev/node/commands/export.ts:428-430) - Progress Tracking: Updated progress counter to accurately reflect the number of slides being processed (based on filtered results) rather than total slide count (
packages/slidev/node/commands/export.ts:432) - Markdown Export: Added filtering in
genPageMd()to only include slides within the specified page range when generating markdown output (packages/slidev/node/commands/export.ts:486)
Type of Change
- [x] ๐ Bug fix (non-breaking change which fixes an issue)
- [ ] โจ New feature (non-breaking change which adds functionality)
- [ ] ๐ฅ Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] ๐ Documentation update
- [ ] โป๏ธ Refactoring (no functional changes)
- [ ] ๐จ Style/formatting changes
- [ ] ๐งช Test improvements
- [ ] ๐ง Configuration changes
Test Plan
Manual Testing
- Export slides with a specific page range (e.g.,
slidev export --range 1-3) and verify that only slides 1-3 are included in the output - Export slides to PNG format with range parameter and confirm that only the specified slides generate PNG files
- Export slides to markdown format with range parameter and verify the markdown output only contains the specified slides
- Test edge cases: single slide range (
--range 5), non-contiguous ranges (--range 1-3,7-9), and full range to ensure backward compatibility
Breaking Changes
None
Checklist
- [x] ๐ Code follows the style guidelines
- [x] ๐ Self-review has been performed
- [ ] ๐งช Tests have been added/updated
- [ ] ๐ Documentation has been updated
Deploy Preview for slidev ready!
| Name | Link |
|---|---|
| Latest commit | f0bdfe6beff0a22fccfcf7210efa4fb2568b27b3 |
| Latest deploy log | https://app.netlify.com/projects/slidev/deploys/6905b65b0e24530008e8f502 |
| Deploy Preview | https://deploy-preview-2323--slidev.netlify.app |
| Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify project configuration.
@slidev/client
npm i https://pkg.pr.new/slidevjs/slidev/@slidev/client@2323
create-slidev
npm i https://pkg.pr.new/slidevjs/slidev/create-slidev@2323
create-slidev-theme
npm i https://pkg.pr.new/slidevjs/slidev/create-slidev-theme@2323
@slidev/parser
npm i https://pkg.pr.new/slidevjs/slidev/@slidev/parser@2323
@slidev/cli
npm i https://pkg.pr.new/slidevjs/slidev/@slidev/cli@2323
@slidev/types
npm i https://pkg.pr.new/slidevjs/slidev/@slidev/types@2323
commit: f0bdfe6