Lua: do not reset foreign encoding before running Lua
This was a leftover from previous hslua versions that relied heavily on `Foreign.C.withCString` and the like. However, hslua 2 and later use bytestring functions to retrieve string values, so this is no longer needed.
This commit is contained in:
parent
0f573a5368
commit
f39eeba35f
1 changed files with 3 additions and 7 deletions
|
@ -19,7 +19,6 @@ import Control.Monad.Catch (throwM, try)
|
||||||
import Control.Monad.Trans (MonadIO (..))
|
import Control.Monad.Trans (MonadIO (..))
|
||||||
import Data.Maybe (catMaybes)
|
import Data.Maybe (catMaybes)
|
||||||
import HsLua as Lua hiding (status, try)
|
import HsLua as Lua hiding (status, try)
|
||||||
import GHC.IO.Encoding (getForeignEncoding, setForeignEncoding, utf8)
|
|
||||||
import Text.Pandoc.Class.PandocMonad (PandocMonad, readDataFile)
|
import Text.Pandoc.Class.PandocMonad (PandocMonad, readDataFile)
|
||||||
import Text.Pandoc.Error (PandocError (PandocLuaError))
|
import Text.Pandoc.Error (PandocError (PandocLuaError))
|
||||||
import Text.Pandoc.Lua.Marshal.List (pushListModule)
|
import Text.Pandoc.Lua.Marshal.List (pushListModule)
|
||||||
|
@ -41,13 +40,10 @@ import qualified Text.Pandoc.Lua.Module.Utils as Pandoc.Utils
|
||||||
-- initialization.
|
-- initialization.
|
||||||
runLua :: (PandocMonad m, MonadIO m)
|
runLua :: (PandocMonad m, MonadIO m)
|
||||||
=> LuaE PandocError a -> m (Either PandocError a)
|
=> LuaE PandocError a -> m (Either PandocError a)
|
||||||
runLua luaOp = do
|
runLua action =
|
||||||
enc <- liftIO $ getForeignEncoding <* setForeignEncoding utf8
|
runPandocLua . try $ do
|
||||||
res <- runPandocLua . try $ do
|
|
||||||
initLuaState
|
initLuaState
|
||||||
liftPandocLua luaOp
|
liftPandocLua action
|
||||||
liftIO $ setForeignEncoding enc
|
|
||||||
return res
|
|
||||||
|
|
||||||
-- | Modules that are loaded at startup and assigned to fields in the
|
-- | Modules that are loaded at startup and assigned to fields in the
|
||||||
-- pandoc module.
|
-- pandoc module.
|
||||||
|
|
Loading…
Reference in a new issue