diff options
-rw-r--r-- | src/Text/Pandoc/Filter/Lua.hs | 4 | ||||
-rw-r--r-- | src/Text/Pandoc/Lua.hs | 4 | ||||
-rw-r--r-- | src/Text/Pandoc/Lua/Init.hs | 6 | ||||
-rw-r--r-- | src/Text/Pandoc/Writers/Custom.hs | 4 | ||||
-rw-r--r-- | test/Tests/Lua.hs | 20 |
5 files changed, 19 insertions, 19 deletions
diff --git a/src/Text/Pandoc/Filter/Lua.hs b/src/Text/Pandoc/Filter/Lua.hs index 6c78bef06..48aa66834 100644 --- a/src/Text/Pandoc/Filter/Lua.hs +++ b/src/Text/Pandoc/Filter/Lua.hs @@ -38,7 +38,7 @@ import Text.Pandoc.Class (PandocIO) import Text.Pandoc.Definition (Pandoc) import Text.Pandoc.Error (PandocError (PandocFilterError)) import Text.Pandoc.Filter.Path (expandFilterPath) -import Text.Pandoc.Lua (LuaException (..), runPandocLua) +import Text.Pandoc.Lua (LuaException (..), runLua) import Text.Pandoc.Lua.Filter (LuaFilter, walkMWithLuaFilter) import Text.Pandoc.Lua.Global (Global (..), setGlobals) import Text.Pandoc.Lua.Util (dofileWithTraceback) @@ -59,7 +59,7 @@ apply ropts args f doc = do let format = case args of (x:_) -> x _ -> error "Format not supplied for Lua filter" - runPandocLua >=> forceResult filterPath $ do + runLua >=> forceResult filterPath $ do setGlobals [ FORMAT format , PANDOC_READER_OPTIONS ropts , PANDOC_SCRIPT_FILE filterPath diff --git a/src/Text/Pandoc/Lua.hs b/src/Text/Pandoc/Lua.hs index 72e66808c..3f4d2df07 100644 --- a/src/Text/Pandoc/Lua.hs +++ b/src/Text/Pandoc/Lua.hs @@ -28,8 +28,8 @@ Running pandoc Lua filters. -} module Text.Pandoc.Lua ( LuaException (..) - , runPandocLua + , runLua ) where -import Text.Pandoc.Lua.Init (LuaException (..), runPandocLua) +import Text.Pandoc.Lua.Init (LuaException (..), runLua) diff --git a/src/Text/Pandoc/Lua/Init.hs b/src/Text/Pandoc/Lua/Init.hs index c9ee7267a..e922e3d93 100644 --- a/src/Text/Pandoc/Lua/Init.hs +++ b/src/Text/Pandoc/Lua/Init.hs @@ -29,7 +29,7 @@ Functions to initialize the Lua interpreter. module Text.Pandoc.Lua.Init ( LuaException (..) , LuaPackageParams (..) - , runPandocLua + , runLua , initLuaState , luaPackageParams ) where @@ -56,8 +56,8 @@ newtype LuaException = LuaException String deriving (Show) -- | Run the lua interpreter, using pandoc's default way of environment -- initialization. -runPandocLua :: Lua a -> PandocIO (Either LuaException a) -runPandocLua luaOp = do +runLua :: Lua a -> PandocIO (Either LuaException a) +runLua luaOp = do luaPkgParams <- luaPackageParams globals <- defaultGlobals enc <- liftIO $ getForeignEncoding <* setForeignEncoding utf8 diff --git a/src/Text/Pandoc/Writers/Custom.hs b/src/Text/Pandoc/Writers/Custom.hs index 7eb982f4b..acf18fba9 100644 --- a/src/Text/Pandoc/Writers/Custom.hs +++ b/src/Text/Pandoc/Writers/Custom.hs @@ -44,7 +44,7 @@ import Text.Pandoc.Class (PandocIO) import Text.Pandoc.Definition import Text.Pandoc.Error import Text.Pandoc.Lua.Global (Global (..), setGlobals) -import Text.Pandoc.Lua.Init (LuaException (LuaException), runPandocLua) +import Text.Pandoc.Lua.Init (LuaException (LuaException), runLua) import Text.Pandoc.Lua.StackInstances () import Text.Pandoc.Lua.Util (addField, dofileWithTraceback) import Text.Pandoc.Options @@ -111,7 +111,7 @@ writeCustom luaFile opts doc@(Pandoc meta _) = do let globals = [ PANDOC_DOCUMENT doc , PANDOC_SCRIPT_FILE luaFile ] - res <- runPandocLua $ do + res <- runLua $ do setGlobals globals stat <- dofileWithTraceback luaFile -- check for error in lua script (later we'll change the return type diff --git a/test/Tests/Lua.hs b/test/Tests/Lua.hs index 1d07829f5..4bc949ddb 100644 --- a/test/Tests/Lua.hs +++ b/test/Tests/Lua.hs @@ -18,7 +18,7 @@ import Text.Pandoc.Class (runIOorExplode, setUserDataDir) import Text.Pandoc.Definition (Block (BlockQuote, Div, Para), Inline (Emph, Str), Attr, Meta, Pandoc, pandocTypesVersion) import Text.Pandoc.Filter (Filter (LuaFilter), applyFilters) -import Text.Pandoc.Lua (runPandocLua) +import Text.Pandoc.Lua (runLua) import Text.Pandoc.Options (def) import Text.Pandoc.Shared (pandocVersion) @@ -128,7 +128,7 @@ tests = map (localOption (QuickCheckTests 20)) (doc $ para "ignored") (doc $ para (str $ "lua" </> "script-name.lua")) - , testCase "Pandoc version is set" . runPandocLua' $ do + , testCase "Pandoc version is set" . runLua' $ do Lua.getglobal' "table.concat" Lua.getglobal "PANDOC_VERSION" Lua.push ("." :: String) -- separator @@ -136,13 +136,13 @@ tests = map (localOption (QuickCheckTests 20)) Lua.liftIO . assertEqual "pandoc version is wrong" pandocVersion =<< Lua.peek Lua.stackTop - , testCase "Pandoc types version is set" . runPandocLua' $ do + , testCase "Pandoc types version is set" . runLua' $ do let versionNums = versionBranch pandocTypesVersion Lua.getglobal "PANDOC_API_VERSION" Lua.liftIO . assertEqual "pandoc-types version is wrong" versionNums =<< Lua.peek Lua.stackTop - , testCase "Allow singleton inline in constructors" . runPandocLua' $ do + , testCase "Allow singleton inline in constructors" . runLua' $ do Lua.liftIO . assertEqual "Not the exptected Emph" (Emph [Str "test"]) =<< Lua.callFunc "pandoc.Emph" (Str "test") Lua.liftIO . assertEqual "Unexpected element" (Para [Str "test"]) @@ -156,14 +156,14 @@ tests = map (localOption (QuickCheckTests 20)) Lua.peek Lua.stackTop ) - , testCase "Elements with Attr have `attr` accessor" . runPandocLua' $ do + , testCase "Elements with Attr have `attr` accessor" . runLua' $ do Lua.push (Div ("hi", ["moin"], []) [Para [Str "ignored"]]) Lua.getfield Lua.stackTop "attr" Lua.liftIO . assertEqual "no accessor" (("hi", ["moin"], []) :: Attr) =<< Lua.peek Lua.stackTop - , testCase "informative error messages" . runPandocLua' $ do + , testCase "informative error messages" . runLua' $ do Lua.pushboolean True err <- Lua.peekEither Lua.stackTop case (err :: Either String Pandoc) of @@ -185,7 +185,7 @@ roundtripEqual :: (Eq a, Lua.Peekable a, Lua.Pushable a) => a -> IO Bool roundtripEqual x = (x ==) <$> roundtripped where roundtripped :: (Lua.Peekable a, Lua.Pushable a) => IO a - roundtripped = runPandocLua' $ do + roundtripped = runLua' $ do oldSize <- Lua.gettop Lua.push x size <- Lua.gettop @@ -196,10 +196,10 @@ roundtripEqual x = (x ==) <$> roundtripped Left e -> error (show e) Right y -> return y -runPandocLua' :: Lua.Lua a -> IO a -runPandocLua' op = runIOorExplode $ do +runLua' :: Lua.Lua a -> IO a +runLua' op = runIOorExplode $ do setUserDataDir (Just "../data") - res <- runPandocLua op + res <- runLua op case res of Left e -> error (show e) Right x -> return x |