Fix {{< placeholder >}} shortcode failing on non-SVG output#14724
Merged
Conversation
Collaborator
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Member
Author
|
This is passing ! Failing test is playwright trensient. I'll merge. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When rendering
{{< placeholder >}}to any non-SVG format (html, pdf, docx, …), the shortcode fails. It relied on thesvg2png.deno.devservice to rasterize its generated SVG to PNG, and that service was permanently retired (Deno Deploy Classic sunset) — it now returns a 404. On html this leaks a broken<img src="Error rendering placeholder.png">; on pdf it aborts the render with a LaTeX file-not-found.Root Cause
The non-SVG branch fetched a PNG from
https://svg2png.deno.dev/<svg-data-uri>(the graceful error handling around that fetch was added in #11111). With the service gone the fetch always fails.error()in Quarto's Lua filters is a logging helper that writes to stderr and returns — it does not raise — so the failure branch logged two lines and then substituted the literal stringError rendering placeholderas the image content, which is what surfaced as the broken image / missing file.Fix
Rasterize locally with the already-bundled Typst binary — no network, no new bundled assets. The shortcode writes its SVG plus a one-line Typst wrapper to a temp dir, runs
typst compile --format png --ppi 96 --ignore-system-fonts, and returns adata:image/png;base64,…URI. Typst is located via the existingquarto.paths.typst()Lua API and invoked withpandoc.pipe, mirroring howsrc/resources/filters/quarto-post/pdf-images.luashells torsvg-convert.--ignore-system-fontsstill renders the dimension label because Typst embeds portable fonts.On failure the shortcode now aborts with
fatal()instead of substituting text — local, offline rasterization is deterministic, so a failure is a real bug rather than the transient the old text-substitution masked.The
format=svgand Typst-output paths are unchanged (inline SVG, no rasterization).Related
Typst rasterizes SVG→PNG and SVG→PDF locally with portable fonts — the same capability requested for the general SVG-figure conversion pipeline in #13696 and #1144. This PR wires only the placeholder shortcode; extending Typst to the
pdf-images.luafigure path is separate follow-up.Fixes #14722