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 | |
| parent | 175b791529a960bf7df8bccb8876783076b3d321 (diff) | |
pandoc-cli: support `-E` flag in pandoc-lua
Diffstat (limited to 'src')
| -rw-r--r-- | src/Text/Pandoc/Lua.hs | 3 | ||||
| -rw-r--r-- | src/Text/Pandoc/Lua/Init.hs | 14 |
2 files changed, 16 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Lua.hs b/src/Text/Pandoc/Lua.hs index 28e807ae9..085526cb7 100644 --- a/src/Text/Pandoc/Lua.hs +++ b/src/Text/Pandoc/Lua.hs @@ -20,11 +20,12 @@ module Text.Pandoc.Lua , Global(..) , setGlobals , runLua + , runLuaNoEnv ) where import Text.Pandoc.Lua.Filter (applyFilter) import Text.Pandoc.Lua.Global (Global (..), setGlobals) -import Text.Pandoc.Lua.Init (runLua) +import Text.Pandoc.Lua.Init (runLua, runLuaNoEnv) import Text.Pandoc.Lua.Reader (readCustom) import Text.Pandoc.Lua.Writer (writeCustom) import Text.Pandoc.Lua.Orphans () 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. -- |
