File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
src/resources/filters/quarto-post Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change 2424-- keyed by {url: mediabagpath}
2525local resolvedUrls = {}
2626
27+ -- replace invalid tex characters with underscores
28+ local tex_safe_filename = function (filename )
29+ -- return filename
30+ return filename :gsub (' [^%w%.%-]' , ' -' )
31+ end
32+
2733function pdfImages ()
2834 return {
2935 -- convert SVG images to PDF when rendering PDFS
@@ -88,14 +94,15 @@ function pdfImages()
8894 local relativePath = image .src :match (' http[s]://[%w%.%:]+/(.+)' )
8995 if relativePath then
9096 local imgMt , imgContents = pandoc .mediabag .fetch (image .src )
91- local filename = pandoc .path .filename (relativePath )
97+ local filename = tex_safe_filename ( pandoc .path .filename (relativePath ) )
9298 if imgMt ~= nil then
9399 local existingMt = pandoc .mediabag .lookup (filename )
94100 local counter = 1
95101 while (existingMt ) do
96102 local stem , ext = pandoc .path .split_extension (filename )
97103 filename = stem .. counter .. ext
98104 existingMt = pandoc .mediabag .lookup (filename )
105+ counter = counter + 1
99106 end
100107 resolvedUrls [image .src ] = filename
101108 pandoc .mediabag .insert (filename , imgMt , imgContents )
You can’t perform that action at this time.
0 commit comments