quarto-dev / quarto-cli

Open-source scientific and technical publishing system built on Pandoc.
https://quarto.org
Other
3.56k stars 293 forks source link

automate snapshotting of typst css table examples #10118

Open gordonwoodhull opened 1 week ago

gordonwoodhull commented 1 week ago

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.

gordonwoodhull commented 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.

gordonwoodhull commented 1 week ago

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.

gordonwoodhull commented 5 days ago

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: