New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add parameter to select pages to be exported by CLI #4039
Conversation
- For now, just simple numbers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Syntax looks good. It should be the same as in the web app.
When using exported-name-{n}.png (for example), should {n} correspond to the real page number in the original typst document? (i.e. with --pages 5,6,7 you'd get name-5.png, name-6.png and name-7.png instead of name-1.png, name-2.png and name-3.png) I've assumed so for now as well, as I'd say this would be expected.
I agree that it should be name-5.png
etc.
- Leads to better clap messages
That might make sense indeed, especially since it already happens if a numbering is specified. |
Alright, I've implemented this, though there are two important notes (and thus potential design decisions):
|
Your choices sound fine. Thank you! |
Closes #3095
Adds the
--pages
parameter totypst compile
andtypst watch
which allows selecting which pages should be exported by the CLI. Supports all export formats (PDF, PNG, SVG).Syntax:
typst compile --pages 5,6,11 a.typ a.pdf
to export a PDF with just pages 5, 6, 11.typst watch --pages 11-13,15- a.typ a-{n}.png
to export pages 11 to 13 (inclusive), as well as any pages after page 15.Implementation:
typst-pdf
in several places to consider non-exported pages. Changedctx.pages
toVec<Option<EncodedPage>>
to preserve the relation between indices and real page numbers.Decisions:
xmp.num_pages
metadata should only contain the amount of exported pages (and should thus always correspond to the number of pages in the actual PDF, not necessarily in the original Typst document), correct? (I have assumed so for now)exported-name-{n}.png
(for example), should{n}
correspond to the real page number in the original typst document? (i.e. with--pages 5,6,7
you'd getname-5.png
,name-6.png
andname-7.png
instead ofname-1.png
,name-2.png
andname-3.png
) I've assumed so for now as well, as I'd say this would be expected.TODO:
--pages