Add parameter to select pages to be exported by CLI#4039
Add parameter to select pages to be exported by CLI#4039laurmaedje merged 23 commits intotypst:mainfrom
Conversation
- For now, just simple numbers
laurmaedje
left a comment
There was a problem hiding this comment.
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
--pagesparameter totypst compileandtypst watchwhich 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.pdfto export a PDF with just pages 5, 6, 11.typst watch --pages 11-13,15- a.typ a-{n}.pngto export pages 11 to 13 (inclusive), as well as any pages after page 15.Implementation:
typst-pdfin several places to consider non-exported pages. Changedctx.pagestoVec<Option<EncodedPage>>to preserve the relation between indices and real page numbers.Decisions:
xmp.num_pagesmetadata 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,7you'd getname-5.png,name-6.pngandname-7.pnginstead ofname-1.png,name-2.pngandname-3.png) I've assumed so for now as well, as I'd say this would be expected.TODO:
--pages