-
-
Notifications
You must be signed in to change notification settings - Fork 800
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 ability to produce minified JSON (and perhaps YAML) output by typst query
#4157
Comments
Yaml is a superset of JSON, so minified yaml could probably just be minified json |
This is true only for YAML 1.2: https://yaml.org/spec/1.2.0/. So if the target YAML parser supports v1.2, then you might as well just choose the JSON output instead of YAML. But this means that for v1.0 and v1.1 this is not true and that YAML minification can have its place in some niche cases (I don't know how widespread each YAML version is). |
It turns out, |
I don't see why this is useful in any real case other than "I think it's very verbose". For passing json around using pipes, json parsers will skip all white space characters as if they are not exist. It there an example that makes a json file faster to process after minifying it? IIRC people will typically do this when serving them. But i think they already have a good packer to do such thing, |
I already mentioned an overlooked problem — waste of resources (size of the output). Now that I think about it, performance can be affected too because you can't prettify an output without wasting more time. For tiny output like that this will be negligible, but when it gets big enough I'm sure the difference is measurable. Documents with hundreds of pages do exist and if you query something big in size and/or frequent, then this is how you get big JSON data. |
Description
I want to be able to write
typst query --field value --minified file.typ metadata
and get:instead of:
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
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.The text was updated successfully, but these errors were encountered: