@@ -12,6 +12,8 @@
1212-- produce informative error messages if your code contains
1313-- syntax errors.
1414
15+local pipe = pandoc.pipe
16+
1517-- Character escaping
1618local function escape(s, in_attribute)
1719 return s:gsub("[<>&\"']",
@@ -44,19 +46,6 @@ local function attributes(attr)
4446 return table.concat(attr_table)
4547end
4648
47−-- Run cmd on a temporary file containing inp and return result.
48−local function pipe(cmd, inp)
49− local tmp = os.tmpname()
50− local tmph = io.open(tmp, "w")
51− tmph:write(inp)
52− tmph:close()
53− local outh = io.popen(cmd .. " " .. tmp,"r")
54− local result = outh:read("*all")
55− outh:close()
56− os.remove(tmp)
57− return result
58−end
59−
6049-- Table to store footnotes, so they can be included at the end.
6150local notes = {}
6251
@@ -217,7 +206,7 @@ function CodeBlock(s, attr)
217206 -- If code block has class 'dot', pipe the contents through dot
218207 -- and base64, and include the base64-encoded png as a data: URL.
219208 if attr.class and string.match(' ' .. attr.class .. ' ',' dot ') then
220− local png = pipe("base64", pipe("dot -Tpng", s))
209+ local png = pipe("base64", {}, pipe("dot", {"-Tpng"}, s))
221210 return '<img src="data:image/png;base64,' .. png .. '"/>'
222211 -- otherwise treat as code (one could pipe through a highlighter)
223212 else