Skip to content

Add --pretty CLI flag and minify HTML and SVG by default - #8371

Merged
laurmaedje merged 1 commit into
mainfrom
pretty
Jun 1, 2026
Merged

laurmaedje merged 1 commit into
mainfrom
pretty

Conversation

@saecki

@saecki saecki commented May 28, 2026

Copy link
Copy Markdown
Member

Based on #8370

This changes the default output to be non-pretty (minimized).

The test suite still produces pretty output, which may be undesirable, we probably want to test a mix of both, but I don't wan to add more special cased test suite options like pdf-standard. Once the format options are settable we can also get rid of that one, and easily test format options in the test suite.

Also interacts with #8294, so either this PR needs to be updated to change PDF output to be pretty or the other one.

@MDLC01

MDLC01 commented May 28, 2026

Copy link
Copy Markdown
Collaborator

I understand how the affects HTML and SVG outputs. But how does it affect PDF output? Does PDF use a text format under the hood?

Also, do you know how much this reduces SVG size when enabled?

Comment thread crates/typst-cli/src/args.rs Resolved
@saecki

saecki commented May 28, 2026 •

Copy link
Copy Markdown
Member Author

I understand how the affects HTML and SVG outputs. But how does it affect PDF output? Does PDF use a text format under the hood?

Yeah PDF is mostly human readable. To make it smaller the content portions of it are flate encoded and in the future with object streams maybe even more. The current version of PDF writer uses extraneous whitespace to make it easier to read. This is nice for development and inspecting PDFs, but arguable a waste of storage space. So we'll opt to produce the smallest documents by default and allow making documents pretty on demand. This is already implemented in pdf-writer and krilla, so just waiting for the bump PR.

Also, do you know how much this reduces SVG size when enabled?

I haven't checked yet :)

@saecki
saecki force-pushed the pretty branch 2 times, most recently from 4e7d30c to e603a19 Compare May 29, 2026 08:59
Base automatically changed from svg-bleed to main May 29, 2026 10:33
@saecki

saecki commented May 29, 2026

Copy link
Copy Markdown
Member Author

Rebased onto main now that #8294 is merged

Comment thread docs/src/main.rs Resolved
Comment thread crates/typst-render/src/lib.rs Resolved
Comment thread crates/typst-html/src/encode.rs Resolved
Comment thread crates/typst-cli/src/compile.rs Resolved
Comment thread crates/typst-cli/src/args.rs Resolved
Comment thread crates/typst-pdf/src/lib.rs Resolved
@laurmaedje laurmaedje added pdf Related to PDF export or PDF embedding. cli About Typst's command line interface. html Related to HTML export svg Anything about the file format for people who like to have fun. waiting-on-author Pull request waits on author labels May 29, 2026
@saecki saecki changed the title Add --pretty CLI flag Add --pretty CLI flag and change default output of HTML, SVG, and PDF Jun 1, 2026
Changes the default SVG and HTML output to be non-pretty (minimized)
@laurmaedje laurmaedje removed the waiting-on-author Pull request waits on author label Jun 1, 2026
@laurmaedje laurmaedje changed the title Add --pretty CLI flag and change default output of HTML, SVG, and PDF Add --pretty CLI flag and minify HTML and SVG by default Jun 1, 2026
@laurmaedje
laurmaedje added this pull request to the merge queue Jun 1, 2026
Merged via the queue into main with commit 0bf7300 Jun 1, 2026
18 checks passed
@saecki
saecki deleted the pretty branch June 1, 2026 11:22
ParaN3xus added a commit to ParaN3xus/typst.ts that referenced this pull request Jun 9, 2026
ParaN3xus added a commit to ParaN3xus/tinymist that referenced this pull request Jun 9, 2026
ParaN3xus added a commit to ParaN3xus/tinymist that referenced this pull request Jun 9, 2026
ParaN3xus added a commit to ParaN3xus/tinymist that referenced this pull request Jun 9, 2026
ParaN3xus added a commit to ParaN3xus/tinymist that referenced this pull request Jun 9, 2026
ParaN3xus added a commit to ParaN3xus/tinymist that referenced this pull request Jun 9, 2026
ParaN3xus added a commit to ParaN3xus/tinymist that referenced this pull request Jun 9, 2026
ParaN3xus added a commit to ParaN3xus/tinymist that referenced this pull request Jun 10, 2026
ParaN3xus added a commit to ParaN3xus/tinymist that referenced this pull request Jun 10, 2026
ParaN3xus added a commit to ParaN3xus/tinymist that referenced this pull request Jun 10, 2026
Myriad-Dreamin pushed a commit to Myriad-Dreamin/tinymist that referenced this pull request Jun 13, 2026
Myriad-Dreamin pushed a commit to Myriad-Dreamin/tinymist that referenced this pull request Jun 13, 2026
Myriad-Dreamin pushed a commit to Myriad-Dreamin/tinymist that referenced this pull request Jun 13, 2026
Myriad-Dreamin pushed a commit to Myriad-Dreamin/tinymist that referenced this pull request Jun 13, 2026
Myriad-Dreamin pushed a commit to Myriad-Dreamin/tinymist that referenced this pull request Jun 13, 2026
Myriad-Dreamin pushed a commit to Myriad-Dreamin/tinymist that referenced this pull request Jun 13, 2026
Myriad-Dreamin pushed a commit to Myriad-Dreamin/tinymist that referenced this pull request Jun 13, 2026
Myriad-Dreamin pushed a commit to Myriad-Dreamin/tinymist that referenced this pull request Jun 13, 2026
Myriad-Dreamin pushed a commit to Myriad-Dreamin/tinymist that referenced this pull request Jun 13, 2026
Myriad-Dreamin added a commit to Myriad-Dreamin/tinymist that referenced this pull request Jun 15, 2026
Part of the Typst 0.15 cleanup stack. This slice covers export option
changes across PNG, SVG, PDF, HTML, CLI rendering, and typlite fixtures.

## Upstream Typst Changes

- [`typst/typst#6357`](typst/typst#6357) changes
page export and render option handling. Tinymist updates PNG/SVG page
export and CLI render option plumbing.
- [`typst/typst#8370`](typst/typst#8370) changes
merged SVG options. Tinymist updates merged SVG export construction.
- [`typst/typst#8371`](typst/typst#8371) changes
generic export options and remaining HTML export paths. Tinymist updates
export computations and HTML export callers to the new option shape.
- [`typst/typst#8294`](typst/typst#8294) changes
PDF standards error handling. Tinymist updates PDF export error
conversion for the new result type.

## Tinymist Changes

- Updates `tinymist-task` PNG, SVG, PDF, and HTML export computations to
the Typst 0.15 option APIs.
- Updates CLI render option forwarding for the new page/export option
surface.
- Updates typlite export tests affected by the Typst 0.15 export option
behavior.

---------

Co-authored-by: paran3xus <[email protected]>
Myriad-Dreamin pushed a commit to Myriad-Dreamin/typst.ts that referenced this pull request Jun 15, 2026
Myriad-Dreamin added a commit to Myriad-Dreamin/tinymist that referenced this pull request Jun 15, 2026
Part of the Typst 0.15 cleanup stack. This slice covers export option
changes across PNG, SVG, PDF, HTML, CLI rendering, and typlite fixtures.

## Upstream Typst Changes

- [`typst/typst#6357`](typst/typst#6357) changes
page export and render option handling. Tinymist updates PNG/SVG page
export and CLI render option plumbing.
- [`typst/typst#8370`](typst/typst#8370) changes
merged SVG options. Tinymist updates merged SVG export construction.
- [`typst/typst#8371`](typst/typst#8371) changes
generic export options and remaining HTML export paths. Tinymist updates
export computations and HTML export callers to the new option shape.
- [`typst/typst#8294`](typst/typst#8294) changes
PDF standards error handling. Tinymist updates PDF export error
conversion for the new result type.

## Tinymist Changes

- Updates `tinymist-task` PNG, SVG, PDF, and HTML export computations to
the Typst 0.15 option APIs.
- Updates CLI render option forwarding for the new page/export option
surface.
- Updates typlite export tests affected by the Typst 0.15 export option
behavior.

---------

Co-authored-by: paran3xus <[email protected]>
Myriad-Dreamin added a commit to Myriad-Dreamin/tinymist that referenced this pull request Jun 15, 2026
Part of the Typst 0.15 cleanup stack. This slice covers export option
changes across PNG, SVG, PDF, HTML, CLI rendering, and typlite fixtures.

## Upstream Typst Changes

- [`typst/typst#6357`](typst/typst#6357) changes
page export and render option handling. Tinymist updates PNG/SVG page
export and CLI render option plumbing.
- [`typst/typst#8370`](typst/typst#8370) changes
merged SVG options. Tinymist updates merged SVG export construction.
- [`typst/typst#8371`](typst/typst#8371) changes
generic export options and remaining HTML export paths. Tinymist updates
export computations and HTML export callers to the new option shape.
- [`typst/typst#8294`](typst/typst#8294) changes
PDF standards error handling. Tinymist updates PDF export error
conversion for the new result type.

## Tinymist Changes

- Updates `tinymist-task` PNG, SVG, PDF, and HTML export computations to
the Typst 0.15 option APIs.
- Updates CLI render option forwarding for the new page/export option
surface.
- Updates typlite export tests affected by the Typst 0.15 export option
behavior.

---------

Co-authored-by: paran3xus <[email protected]>
stochastical added a commit to stochastical/distro that referenced this pull request Jun 16, 2026
@stochastical stochastical mentioned this pull request Jun 16, 2026
1 of 2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli About Typst's command line interface. html Related to HTML export pdf Related to PDF export or PDF embedding. svg Anything about the file format for people who like to have fun.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants