11-- svg.lua
22-- Copyright (C) 2021 by RStudio, PBC
33
4- local mediabag = require ' modules/mediabag'
5-
64local function call_rsvg_convert (path )
75 local stem = pandoc .path .split_extension (path )
86 local output = stem .. ' .pdf'
@@ -75,7 +73,7 @@ function pdfImages()
7573
7674 -- See if the path points to an SVG in the media bag
7775 -- (been generated by a filter, for example)
78- return mediabag .with_mediabag_contents (image .src , function (mime_type , tempPath )
76+ return _quarto . modules . mediabag .with_mediabag_contents (image .src , function (mime_type , tempPath )
7977 if mime_type == ' image/svg+xml' then
8078 local convertedPath = call_rsvg_convert (tempPath )
8179 if convertedPath == nil then
@@ -97,23 +95,7 @@ function pdfImages()
9795 image .src = mbPath
9896 return image
9997 elseif mt == nil then
100- if mediabag .resolved_url_cache [image .src ] then
101- image .src = mediabag .resolved_url_cache [image .src ]
102- return image
103- end
104-
105- local relativePath = image .src :match (" https?://[%w%$%-%_%.%+%!%*%'%(%)%:%%]+/(.+)" ) or
106- image .src :match (" data:image/.+;base64,(.+)" )
107- if not (relativePath or param (" has-resource-path" , false )) then
108- return nil
109- end
110-
111- local filename = mediabag .fetch_and_store_image (image .src )
112- if filename == nil then
113- return nil
114- end
115- image .src = filename
116- return image
98+ return _quarto .modules .mediabag .resolve_image_from_url (image )
11799 end
118100 end )
119101 end
0 commit comments