aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/sample.lua17
1 files changed, 3 insertions, 14 deletions
diff --git a/data/sample.lua b/data/sample.lua
index 6c09442b5..e25bf59cb 100644
--- a/data/sample.lua
+++ b/data/sample.lua
@@ -12,6 +12,8 @@
-- produce informative error messages if your code contains
-- syntax errors.
+local pipe = pandoc.pipe
+
-- Character escaping
local function escape(s, in_attribute)
return s:gsub("[<>&\"']",
@@ -44,19 +46,6 @@ local function attributes(attr)
return table.concat(attr_table)
end
--- Run cmd on a temporary file containing inp and return result.
-local function pipe(cmd, inp)
- local tmp = os.tmpname()
- local tmph = io.open(tmp, "w")
- tmph:write(inp)
- tmph:close()
- local outh = io.popen(cmd .. " " .. tmp,"r")
- local result = outh:read("*all")
- outh:close()
- os.remove(tmp)
- return result
-end
-
-- Table to store footnotes, so they can be included at the end.
local notes = {}
@@ -217,7 +206,7 @@ function CodeBlock(s, attr)
-- If code block has class 'dot', pipe the contents through dot
-- and base64, and include the base64-encoded png as a data: URL.
if attr.class and string.match(' ' .. attr.class .. ' ',' dot ') then
- local png = pipe("base64", pipe("dot -Tpng", s))
+ local png = pipe("base64", {}, pipe("dot", {"-Tpng"}, s))
return '<img src="data:image/png;base64,' .. png .. '"/>'
-- otherwise treat as code (one could pipe through a highlighter)
else