aboutsummaryrefslogtreecommitdiff
path: root/data/sample.lua
diff options
context:
space:
mode:
authorAlbert Krewinkel <albert@zeitkraut.de>2018-10-13 20:19:08 +0200
committerAlbert Krewinkel <albert@zeitkraut.de>2018-10-13 20:54:47 +0200
commit273d4dfcfaae672ce99033beeee25113ff3af3b3 (patch)
treeb25b8a3e7326e09a1fc9560b23f822a0ae0247d9 /data/sample.lua
parent78871c9b966b55d85f3c20966e0852f14016a00a (diff)
downloadpandoc-273d4dfcfaae672ce99033beeee25113ff3af3b3.tar.gz
data/sample.lua: replace custom pipe function with pandoc.utils.pipe
Diffstat (limited to 'data/sample.lua')
-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