Skip to content

Fix {{< placeholder >}} shortcode failing on non-SVG output#14724

Merged
cderv merged 3 commits into
mainfrom
fix/issue-14722
Jul 23, 2026
Merged

Fix {{< placeholder >}} shortcode failing on non-SVG output#14724
cderv merged 3 commits into
mainfrom
fix/issue-14722

Conversation

@cderv

@cderv cderv commented Jul 23, 2026

Copy link
Copy Markdown
Member

When rendering {{< placeholder >}} to any non-SVG format (html, pdf, docx, …), the shortcode fails. It relied on the svg2png.deno.dev service 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 string Error rendering placeholder as 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 a data:image/png;base64,… URI. Typst is located via the existing quarto.paths.typst() Lua API and invoked with pandoc.pipe, mirroring how src/resources/filters/quarto-post/pdf-images.lua shells to rsvg-convert. --ignore-system-fonts still 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=svg and 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.lua figure path is separate follow-up.

Fixes #14722

@posit-snyk-bot

posit-snyk-bot commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@cderv

cderv commented Jul 23, 2026

Copy link
Copy Markdown
Member Author

This is passing ! Failing test is playwright trensient. I'll merge.

@cderv
cderv merged commit bc2d42e into main Jul 23, 2026
50 of 51 checks passed
@cderv
cderv deleted the fix/issue-14722 branch July 23, 2026 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

placeholder shortcode fails on all non-SVG output: svg2png.deno.dev sunset (404)

2 participants