git.iko.soy/typeable/pandoc
on master help sign in
T.P.Lua: rename `runPandocLua` to `runLua` (API change)
commit6f29e1c9c1fc4c655c5ca4fad9e9256f8313d7bd authorAlbert Krewinkel <albert@zeitkraut.de> dateFri 26 Oct 2018, 23:29 (8 years ago) parent7f54f76
5 files changed+19−19
src/Text/Pandoc/Filter/Lua.hs+2−2 src/Text/Pandoc/Lua.hs+2−2 src/Text/Pandoc/Lua/Init.hs+3−3 src/Text/Pandoc/Writers/Custom.hs+2−2 test/Tests/Lua.hs+10−10
src/Text/Pandoc/Filter/Lua.hs+2−2
@@ -38,7 +38,7 @@ import Text.Pandoc.Class (PandocIO)
3838import Text.Pandoc.Definition (Pandoc)
3939import Text.Pandoc.Error (PandocError (PandocFilterError))
4040import Text.Pandoc.Filter.Path (expandFilterPath)
41−import Text.Pandoc.Lua (LuaException (..), runPandocLua)
41+import Text.Pandoc.Lua (LuaException (..), runLua)
4242import Text.Pandoc.Lua.Filter (LuaFilter, walkMWithLuaFilter)
4343import Text.Pandoc.Lua.Global (Global (..), setGlobals)
4444import Text.Pandoc.Lua.Util (dofileWithTraceback)
@@ -59,7 +59,7 @@ apply ropts args f doc = do
5959 let format = case args of
6060 (x:_) -> x
6161 _ -> error "Format not supplied for Lua filter"
62− runPandocLua >=> forceResult filterPath $ do
62+ runLua >=> forceResult filterPath $ do
6363 setGlobals [ FORMAT format
6464 , PANDOC_READER_OPTIONS ropts
6565 , PANDOC_SCRIPT_FILE filterPath
src/Text/Pandoc/Lua.hs+2−2
@@ -28,8 +28,8 @@ Running pandoc Lua filters.
2828-}
2929module Text.Pandoc.Lua
3030 ( LuaException (..)
31− , runPandocLua
31+ , runLua
3232 ) where
3333
34−import Text.Pandoc.Lua.Init (LuaException (..), runPandocLua)
34+import Text.Pandoc.Lua.Init (LuaException (..), runLua)
3535
src/Text/Pandoc/Lua/Init.hs+3−3
@@ -29,7 +29,7 @@ Functions to initialize the Lua interpreter.
2929module Text.Pandoc.Lua.Init
3030 ( LuaException (..)
3131 , LuaPackageParams (..)
32− , runPandocLua
32+ , runLua
3333 , initLuaState
3434 , luaPackageParams
3535 ) where
@@ -56,8 +56,8 @@ newtype LuaException = LuaException String deriving (Show)
5656
5757-- | Run the lua interpreter, using pandoc's default way of environment
5858-- initialization.
59−runPandocLua :: Lua a -> PandocIO (Either LuaException a)
60−runPandocLua luaOp = do
59+runLua :: Lua a -> PandocIO (Either LuaException a)
60+runLua luaOp = do
6161 luaPkgParams <- luaPackageParams
6262 globals <- defaultGlobals
6363 enc <- liftIO $ getForeignEncoding <* setForeignEncoding utf8
src/Text/Pandoc/Writers/Custom.hs+2−2
@@ -44,7 +44,7 @@ import Text.Pandoc.Class (PandocIO)
4444import Text.Pandoc.Definition
4545import Text.Pandoc.Error
4646import Text.Pandoc.Lua.Global (Global (..), setGlobals)
47−import Text.Pandoc.Lua.Init (LuaException (LuaException), runPandocLua)
47+import Text.Pandoc.Lua.Init (LuaException (LuaException), runLua)
4848import Text.Pandoc.Lua.StackInstances ()
4949import Text.Pandoc.Lua.Util (addField, dofileWithTraceback)
5050import Text.Pandoc.Options
@@ -111,7 +111,7 @@ writeCustom luaFile opts doc@(Pandoc meta _) = do
111111 let globals = [ PANDOC_DOCUMENT doc
112112 , PANDOC_SCRIPT_FILE luaFile
113113 ]
114− res <- runPandocLua $ do
114+ res <- runLua $ do
115115 setGlobals globals
116116 stat <- dofileWithTraceback luaFile
117117 -- check for error in lua script (later we'll change the return type
test/Tests/Lua.hs+10−10
@@ -18,7 +18,7 @@ import Text.Pandoc.Class (runIOorExplode, setUserDataDir)
1818import Text.Pandoc.Definition (Block (BlockQuote, Div, Para), Inline (Emph, Str),
1919 Attr, Meta, Pandoc, pandocTypesVersion)
2020import Text.Pandoc.Filter (Filter (LuaFilter), applyFilters)
21−import Text.Pandoc.Lua (runPandocLua)
21+import Text.Pandoc.Lua (runLua)
2222import Text.Pandoc.Options (def)
2323import Text.Pandoc.Shared (pandocVersion)
2424
@@ -128,7 +128,7 @@ tests = map (localOption (QuickCheckTests 20))
128128 (doc $ para "ignored")
129129 (doc $ para (str $ "lua" </> "script-name.lua"))
130130
131− , testCase "Pandoc version is set" . runPandocLua' $ do
131+ , testCase "Pandoc version is set" . runLua' $ do
132132 Lua.getglobal' "table.concat"
133133 Lua.getglobal "PANDOC_VERSION"
134134 Lua.push ("." :: String) -- separator
@@ -136,13 +136,13 @@ tests = map (localOption (QuickCheckTests 20))
136136 Lua.liftIO . assertEqual "pandoc version is wrong" pandocVersion
137137 =<< Lua.peek Lua.stackTop
138138
139− , testCase "Pandoc types version is set" . runPandocLua' $ do
139+ , testCase "Pandoc types version is set" . runLua' $ do
140140 let versionNums = versionBranch pandocTypesVersion
141141 Lua.getglobal "PANDOC_API_VERSION"
142142 Lua.liftIO . assertEqual "pandoc-types version is wrong" versionNums
143143 =<< Lua.peek Lua.stackTop
144144
145− , testCase "Allow singleton inline in constructors" . runPandocLua' $ do
145+ , testCase "Allow singleton inline in constructors" . runLua' $ do
146146 Lua.liftIO . assertEqual "Not the exptected Emph" (Emph [Str "test"])
147147 =<< Lua.callFunc "pandoc.Emph" (Str "test")
148148 Lua.liftIO . assertEqual "Unexpected element" (Para [Str "test"])
@@ -156,14 +156,14 @@ tests = map (localOption (QuickCheckTests 20))
156156 Lua.peek Lua.stackTop
157157 )
158158
159− , testCase "Elements with Attr have `attr` accessor" . runPandocLua' $ do
159+ , testCase "Elements with Attr have `attr` accessor" . runLua' $ do
160160 Lua.push (Div ("hi", ["moin"], [])
161161 [Para [Str "ignored"]])
162162 Lua.getfield Lua.stackTop "attr"
163163 Lua.liftIO . assertEqual "no accessor" (("hi", ["moin"], []) :: Attr)
164164 =<< Lua.peek Lua.stackTop
165165
166− , testCase "informative error messages" . runPandocLua' $ do
166+ , testCase "informative error messages" . runLua' $ do
167167 Lua.pushboolean True
168168 err <- Lua.peekEither Lua.stackTop
169169 case (err :: Either String Pandoc) of
@@ -185,7 +185,7 @@ roundtripEqual :: (Eq a, Lua.Peekable a, Lua.Pushable a) => a -> IO Bool
185185roundtripEqual x = (x ==) <$> roundtripped
186186 where
187187 roundtripped :: (Lua.Peekable a, Lua.Pushable a) => IO a
188− roundtripped = runPandocLua' $ do
188+ roundtripped = runLua' $ do
189189 oldSize <- Lua.gettop
190190 Lua.push x
191191 size <- Lua.gettop
@@ -196,10 +196,10 @@ roundtripEqual x = (x ==) <$> roundtripped
196196 Left e -> error (show e)
197197 Right y -> return y
198198
199−runPandocLua' :: Lua.Lua a -> IO a
200−runPandocLua' op = runIOorExplode $ do
199+runLua' :: Lua.Lua a -> IO a
200+runLua' op = runIOorExplode $ do
201201 setUserDataDir (Just "../data")
202− res <- runPandocLua op
202+ res <- runLua op
203203 case res of
204204 Left e -> error (show e)
205205 Right x -> return x