Skip to content

Commit

Permalink
Use image data hash as name for temporary pdf files
Browse files Browse the repository at this point in the history
Closes: #49
  • Loading branch information
tarleb committed Dec 12, 2024
1 parent d7839c9 commit 023b317
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion _extensions/diagram/diagram.lua
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,10 @@ end

--- Converts a PDF to SVG.
local pdf2svg = function (imgdata)
local pdf_file = os.tmpname() .. '.pdf'
-- Using `os.tmpname()` instead of a hash would be slightly cleaner, but the
-- function causes problems on Windows (and wasm). See, e.g.,
-- https://github.com/pandoc-ext/diagram/issues/49
local pdf_file = 'diagram-' .. pandoc.utils.sha1(imgdata) .. '.pdf'
write_file(pdf_file, imgdata)
local args = {
'--export-type=svg',
Expand Down

1 comment on commit 023b317

@cderv
Copy link

@cderv cderv commented on 023b317 Dec 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks !

Please sign in to comment.