aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Lua/Init.hs8
-rw-r--r--src/Text/Pandoc/Lua/PandocModule.hs11
2 files changed, 8 insertions, 11 deletions
diff --git a/src/Text/Pandoc/Lua/Init.hs b/src/Text/Pandoc/Lua/Init.hs
index a2bfa3801..9b107e945 100644
--- a/src/Text/Pandoc/Lua/Init.hs
+++ b/src/Text/Pandoc/Lua/Init.hs
@@ -50,8 +50,7 @@ import qualified Foreign.Lua.Module.Text as Lua
-- initalization.
runPandocLua :: Lua a -> PandocIO (Either LuaException a)
runPandocLua luaOp = do
- datadir <- getUserDataDir
- luaPkgParams <- luaPackageParams datadir
+ luaPkgParams <- luaPackageParams
enc <- liftIO $ getForeignEncoding <* setForeignEncoding utf8
res <- liftIO $ Lua.runLuaEither (initLuaState luaPkgParams *> luaOp)
liftIO $ setForeignEncoding enc
@@ -60,9 +59,10 @@ runPandocLua luaOp = do
return res
-- | Generate parameters required to setup pandoc's lua environment.
-luaPackageParams :: Maybe FilePath -> PandocIO LuaPackageParams
-luaPackageParams datadir = do
+luaPackageParams :: PandocIO LuaPackageParams
+luaPackageParams = do
commonState <- getCommonState
+ datadir <- getUserDataDir
mbRef <- liftIO . newIORef =<< getMediaBag
return LuaPackageParams
{ luaPkgCommonState = commonState
diff --git a/src/Text/Pandoc/Lua/PandocModule.hs b/src/Text/Pandoc/Lua/PandocModule.hs
index 75f884c46..6bc2618fd 100644
--- a/src/Text/Pandoc/Lua/PandocModule.hs
+++ b/src/Text/Pandoc/Lua/PandocModule.hs
@@ -71,16 +71,13 @@ pushPandocModule datadir = do
return 1
walkElement :: (ToLuaStack a, Walkable [Inline] a, Walkable [Block] a)
- => a -> LuaFilter -> Lua NumResults
-walkElement x f = do
- x' <- walkInlines f x >>= walkBlocks f
- Lua.push x'
- return 1
+ => a -> LuaFilter -> Lua a
+walkElement x f = walkInlines f x >>= walkBlocks f
-walkInline :: Inline -> LuaFilter -> Lua NumResults
+walkInline :: Inline -> LuaFilter -> Lua Inline
walkInline = walkElement
-walkBlock :: Block -> LuaFilter -> Lua NumResults
+walkBlock :: Block -> LuaFilter -> Lua Block
walkBlock = walkElement
readDoc :: String -> String -> Lua NumResults