Skip to content

Add ability to produce minified JSON (and perhaps YAML) output by typst query #4157

@Andrew15-5

Description

@Andrew15-5

Description

I want to be able to write typst query --field value --minified file.typ metadata and get:

[false,true]

instead of:

[
  false,
  true
]

which is very verbose IMO (7 bytes more). Maybe even print minified version by default (this command is probably only ever used in scripts anyway) and instead add --prittify for the verbose version.

Same can be done for the YAML version: from

- false
- true

to

[false,true]

(https://yaml.org/spec/1.0/, paragraph 2.1, example 2.5)

I personally haven't heard about YAML minification, but in some cases it is indeed possible (2 bytes saved), so if possible, why not affect both formats?

Use Case

The minified version outputs a smaller result, which if saved as a file, can reduce the size of that file (or reduce the size of piped data if used in a POSIX-compliant shell). If typst query outputs a lot of data, then the size difference becomes more noticeable. And just in general, it's better to not waste any resources if it is possible. Also, since the command is mainly used in scripts, the output doesn't have to be readable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    cliAbout Typst's command line interface.feature requestNew feature or requestintrospectionRelated to the introspection category

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions