computable-pandoc/scripts/make_jsons.lua

25 lines
593 B
Lua
Raw Permalink Normal View History

2023-03-23 19:53:36 -06:00
-- Makes JSON test files
-- Adds local luarocks modules
package.path = "./opt/share/lua/5.4/?.lua;" .. package.path
2023-03-23 19:53:36 -06:00
-- Adds Lua custom extensions
2023-06-16 20:58:43 -06:00
local lua_dog = require("dog")
lua_dog.import()
2023-03-23 19:53:36 -06:00
-- Gets command according to OS
2023-06-16 12:03:16 -06:00
local function getcmd()
2023-03-23 19:53:36 -06:00
if os:isunix() then
return "ls"
else
return "dir"
end
end
-- Makes JSON from markup files
2023-06-16 12:03:16 -06:00
for file in io.popen(getcmd() .. " tests/asts"):lines() do
2023-03-23 19:53:36 -06:00
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