computable-pandoc/scripts/make_jsons.lua

25 lines
593 B
Lua

-- Makes JSON test files
-- Adds local luarocks modules
package.path = "./opt/share/lua/5.4/?.lua;" .. package.path
-- Adds Lua custom extensions
local lua_dog = require("dog")
lua_dog.import()
-- Gets command according to OS
local function getcmd()
if os:isunix() then
return "ls"
else
return "dir"
end
end
-- Makes JSON from markup files
for file in io.popen(getcmd() .. " tests/asts"):lines() do
local json = pandoc.path.join({"tests", "asts", file})
local mark = pandoc.path.join({"tests", pandoc.path.filename(json:stem())})
pandoc.convert(mark, "json", json)
end