Skip to content

Commit 61b2b87

Browse files
authored
Merge pull request #11111 from quarto-dev/bugfix/placeholder-errors
handle svg2png rendering error more gracefully
2 parents 9d866bd + adeca93 commit 61b2b87

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/resources/extensions/quarto/placeholder/placeholder.lua

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,24 @@ return {
1313
local svg64 = "data:image/svg+xml;base64," .. quarto.base64.encode(svg)
1414
local result
1515

16-
if kwargs["format"] == "svg" then
16+
local output_format = pandoc.utils.stringify(kwargs["format"])
17+
if output_format == "" then
18+
if quarto.format.is_typst_output() then
19+
output_format = "svg"
20+
else
21+
output_format = "png"
22+
end
23+
end
24+
25+
if output_format == "svg" then
1726
result = svg64
1827
else
1928
local mt, contents = pandoc.mediabag.fetch("https://svg2png.deno.dev/" .. svg64)
29+
if mt ~= "image/png" then
30+
error("Expected image/png but got " .. mt)
31+
error(contents)
32+
return pandoc.Str("Error rendering placeholder")
33+
end
2034
result = "data:" .. mt .. ";base64," .. quarto.base64.encode(contents)
2135
end
2236

0 commit comments

Comments
 (0)