Lua: set "arg" instead of "PandocParameters".

This is standard for lua scripts, and I see no reason
to depart from the standard here.

Also, "arg" is now pushed onto the stack before the script
is loaded.  Previously it was not, and thus "PandocParameters"
was not available at the top level.
This commit is contained in:
John MacFarlane 2017-09-26 10:05:56 -07:00
parent 2cdb8fe2e6
commit 3fe4aad5a1

View file

@ -57,6 +57,8 @@ runLuaFilter datadir filterPath args pd = liftIO . Lua.runLua $ do
-- store module in global "pandoc"
pushPandocModule datadir
Lua.setglobal "pandoc"
push args
Lua.setglobal "arg"
top <- Lua.gettop
stat <- Lua.dofile filterPath
if stat /= OK
@ -68,8 +70,6 @@ runLuaFilter datadir filterPath args pd = liftIO . Lua.runLua $ do
-- Use the implicitly defined global filter if nothing was returned
when (newtop - top < 1) pushGlobalFilter
luaFilters <- peek (-1)
push args
Lua.setglobal "PandocParameters"
runAll luaFilters pd
pushGlobalFilter :: Lua ()