Skip to content

Commit d7ee29b

Browse files
committed
Place files that are converted from SVG in mediabag
Previously we were converting them in place and then leaving them on disk, which would leave a bunch of crufty PDF files around.
1 parent e06767d commit d7ee29b

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/resources/filters/quarto-post/pdf-images.lua

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,16 @@ function pdfImages()
3333
-- If the src is pointing to a local file that is an svg, process it
3434
local ext = select(2, pandoc.path.split_extension(image.src))
3535
if ext == '.svg' then
36-
local converted = convert_svg(image.src)
37-
if converted then
38-
image.src = converted
36+
local convertedPath = convert_svg(image.src)
37+
if convertedPath then
38+
local contents = _quarto.file.read(convertedPath)
39+
local relativePath = pandoc.path.make_relative(convertedPath, '.')
40+
41+
-- add to media bag and remove the converted file
42+
pandoc.mediabag.insert(relativePath, 'application/pdf', contents)
43+
_quarto.file.remove(relativePath)
44+
45+
image.src = relativePath
3946
return image
4047
end
4148
end

0 commit comments

Comments
 (0)