Prequery API
This is the fundamental function for building prequeries. It adds metadata for preprocessing to the document and conditionally shows some fallback content when fallback mode is enabled.
The body may be given as a function, so that errors from the body don’t let compilation fail when in fallback mode.
Parameters:
A prequery for images. Apart from the url parameter, the image file name is also mandatory; it is part of args for technical reasons. Outside fallback mode, rendering this fails when the referenced image is missing; images need to be downloaded in a preprocessing step.
This function provides a dictionary with url and path as metadata under the label <web-resource>. This metadata can be queried like this:
typst query --input prequery-fallback=true --field value ... '<web-resource>'
Fallback: renders the Unicode character “Frame with Picture” (U+1F5BC).
Parameters:
A boolean state indicating whether the document should display fallback content for elements requiring results from preprocessing. For example, when using prequery images, compiling the document before download the files during preprocessing will fail. If all prequeries used in the document work even before preprocessing, it is not necessary to turn fallback mode on.
When editing the document and adding images (or other preprocessed content), it is convenient to temporarily add a line at the top to switch fallback mode on:
#fallback.update(true)
When querying the document for preprocessing, this can be activated using --input:
typst query --input prequery-fallback=true ...