Open gordonwoodhull opened 1 week ago
quarto/quarto-web#1162 contains a script tools/snapshot-typst.ts
that renders Typst to PDF and then trims the whitespace and converts to PNG using ImageMagick.
It works well as long as any extra content can be suppressed, some of which can be done with command-line flags like -M echo:false
, some of which needs to go into the document.
I ran into infinite recursion problems when installing snapshot-typst.ts
as a pre-render script in quarto-web, because it invokes quarto render
, but I solved them with a QUARTO_IN_SHAPSHOT_TYPST
environment variable.
Unfortunately it is a pre-render script for the whole project, and seems to get invoked for every target, but it doesn't run if the snapshot exists, so hopefully it won't be a perf problem.
I'm sure it could be made more robust and general, but we have "pure" generated Typst snapshots for the Typst CSS section of the Typst authoring docs.
Please let me know if the pre-render script gives you any trouble after quarto/quarto-web#1162 is merged.
I got this to work well enough for today's demo, but now I think the pre-render script is the wrong approach and we want to check in snapshots and have another workflow that updates them.
Next steps:
quarto-web/tools/generate-snapshots.ts
that takes a yaml config list of qmds and target shapshot filenames. By default it only generates the snapshots that don't exist, but also allows -f
/ --force
generate-snapshots.ts
weekly with —force
and itself open PRs with any changed shapshots. The new workflow needs to have Jupyter, R and Python table packages, and magick
The draft text is mostly ready in https://github.com/quarto-dev/quarto-web/pull/1162
And the examples build in place. But the snapshots for the examples should be automatically processed e.g with ImageMagick.