diff options
Diffstat (limited to 'src/Text/Pandoc/Lua/Util.hs')
-rw-r--r-- | src/Text/Pandoc/Lua/Util.hs | 17 |
1 files changed, 3 insertions, 14 deletions
diff --git a/src/Text/Pandoc/Lua/Util.hs b/src/Text/Pandoc/Lua/Util.hs index 66bba5a34..c6639e94c 100644 --- a/src/Text/Pandoc/Lua/Util.hs +++ b/src/Text/Pandoc/Lua/Util.hs @@ -19,7 +19,6 @@ module Text.Pandoc.Lua.Util , addFunction , addValue , pushViaConstructor - , loadScriptFromDataDir , defineHowTo , throwTopMessageAsError' , callWithTraceback @@ -27,13 +26,11 @@ module Text.Pandoc.Lua.Util ) where import Control.Monad (unless, when) +import Data.Text (Text) import Foreign.Lua ( Lua, NumArgs, NumResults, Peekable, Pushable, StackIndex , Status, ToHaskellFunction ) -import Text.Pandoc.Class.PandocIO (runIOorExplode) -import Text.Pandoc.Class.PandocMonad (readDataFile, setUserDataDir) import qualified Foreign.Lua as Lua import qualified Text.Pandoc.UTF8 as UTF8 -import Data.Text (Text) -- | Get value behind key from table at given index. rawField :: Peekable a => StackIndex -> String -> Lua a @@ -87,15 +84,6 @@ pushViaCall fn = pushViaCall' fn (return ()) 0 pushViaConstructor :: PushViaCall a => String -> a pushViaConstructor pandocFn = pushViaCall ("pandoc." ++ pandocFn) --- | Load a file from pandoc's data directory. -loadScriptFromDataDir :: Maybe FilePath -> FilePath -> Lua () -loadScriptFromDataDir datadir scriptFile = do - script <- Lua.liftIO . runIOorExplode $ - setUserDataDir datadir >> readDataFile scriptFile - status <- Lua.dostring script - when (status /= Lua.OK) $ - throwTopMessageAsError' (("Couldn't load '" ++ scriptFile ++ "'.\n") ++) - -- | Get the tag of a value. This is an optimized and specialized version of -- @Lua.getfield idx "tag"@. It only checks for the field on the table at index -- @idx@ and on its metatable, also ignoring any @__index@ value on the @@ -144,7 +132,8 @@ pcallWithTraceback nargs nresults = do callWithTraceback :: NumArgs -> NumResults -> Lua () callWithTraceback nargs nresults = do result <- pcallWithTraceback nargs nresults - when (result /= Lua.OK) Lua.throwTopMessage + when (result /= Lua.OK) + Lua.throwTopMessage -- | Run the given string as a Lua program, while also adding a traceback to the -- error message if an error occurs. |