diff options
| author | Albert Krewinkel <albert@zeitkraut.de> | 2022-09-27 13:09:55 +0200 |
|---|---|---|
| committer | John MacFarlane <jgm@berkeley.edu> | 2022-09-27 08:42:27 -0700 |
| commit | efecff1f2f035ee3a0825e969d048d6c5ffacd26 (patch) | |
| tree | e73fa73d741472d1dc2ac00d77e76d6591c6e9a8 /src/Text/Pandoc/Lua/Init.hs | |
| parent | 175b791529a960bf7df8bccb8876783076b3d321 (diff) | |
pandoc-cli: support `-E` flag in pandoc-lua
Diffstat (limited to 'src/Text/Pandoc/Lua/Init.hs')
| -rw-r--r-- | src/Text/Pandoc/Lua/Init.hs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/Text/Pandoc/Lua/Init.hs b/src/Text/Pandoc/Lua/Init.hs index 966f0a581..04f007e0e 100644 --- a/src/Text/Pandoc/Lua/Init.hs +++ b/src/Text/Pandoc/Lua/Init.hs @@ -12,6 +12,7 @@ Functions to initialize the Lua interpreter. -} module Text.Pandoc.Lua.Init ( runLua + , runLuaNoEnv ) where import Control.Monad (forM, forM_, when) @@ -46,6 +47,19 @@ runLua action = initLuaState liftPandocLua action +-- | Like 'runLua', but ignores all environment variables like @LUA_PATH@. +runLuaNoEnv :: (PandocMonad m, MonadIO m) + => LuaE PandocError a -> m (Either PandocError a) +runLuaNoEnv action = + runPandocLua . try $ do + liftPandocLua $ do + -- This is undocumented, but works -- the code is adapted from the + -- `lua.c` sources for the default interpreter. + Lua.pushboolean True + Lua.setfield Lua.registryindex "LUA_NOENV" + initLuaState + liftPandocLua action + -- | Modules that are loaded at startup and assigned to fields in the -- pandoc module. -- |
