Running the preprocessor
The goal of Prequery is to avoid manual preparation of external resources before compiling your Typst document. The Prequery package alone can't achieve that, since it sits inside Typst's sandbox. This is where Prequery's preprocessor enters the picture.
In the previous section, we have prepared our document to provide the necessary information, now we need to configure the preprocessor to use it. This is done inside the document's typst.toml
typst.toml
file:
The [package]
[package]
part of that file is not used by the preprocessor, but is required by Typst. Unless your document is part of a package, you can simply copy this part exactly as written, with ...
...
and all. This requirement will hopefully be lifted in the future.
The [[tool.prequery.jobs]]
[[tool.prequery.jobs]]
part can appear multiple times; each one adds one job to the preprocessor, which is executed when running the prequery
prequery
command. In this case, we're running a web-resource
web-resource
job, which downloads files from the web. The files to download are the ones that were specified in the previous section, by using the image()
image()
function. We also give it a name, which is shown in the output for tracking the job's progress.
Let's now actually run the preprocessor:
If everything is in place, you should see some output like this:
… and that's it! The image required by your document is now present, and you can compile it:
If you later add images, simply run the prequery
prequery
command again.
You have now seen how to automate the preparation of you document's resources using Prequery:
- Use the Prequery package to embed information about the required resources into your document.
- Configure the
prequery
prequery
command line tool intypst.toml
typst.toml
to tell it what kind of resources/processing is required. - Run the
prequery
prequery
command whenever your resources have changed.
You can take a look at the web-resource
web-resource
preprocessor's documentation to see its more advanced features. For other use cases, the shell
shell
preprocessor offers early support for running arbitrary commands. If you need to do something and are not sure if it can be done with Prequery, let us know in an issue on the package or the CLI tool.