summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlbert Krewinkel <albert@zeitkraut.de>2022-06-09 08:54:06 +0200
committerAlbert Krewinkel <albert@zeitkraut.de>2022-06-09 08:54:06 +0200
commit7e6ccda6d99c4bc11e1847a669f2fd8c76816a66 (patch)
treedf91f7ce0793fab2a2f47bfd435c0ac800664766 /src
parentb3cee8bdb03abf85eb480506291feb16a00b2445 (diff)
Lua: use only old ByteString functions.
The function `takeWhileEnd` was added with bytestring-0.11.3.0, but older versions should be supported as well. Fixes the previous commit.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Lua/Init.hs9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/Text/Pandoc/Lua/Init.hs b/src/Text/Pandoc/Lua/Init.hs
index 44769bdba..78ba02713 100644
--- a/src/Text/Pandoc/Lua/Init.hs
+++ b/src/Text/Pandoc/Lua/Init.hs
@@ -24,7 +24,7 @@ import Text.Pandoc.Class.PandocMonad (PandocMonad, readDataFile)
import Text.Pandoc.Error (PandocError (PandocLuaError))
import Text.Pandoc.Lua.Marshal.List (pushListModule)
import Text.Pandoc.Lua.PandocLua (PandocLua, liftPandocLua, runPandocLua)
-import qualified Data.ByteString as B
+import qualified Data.ByteString.Char8 as Char8
import qualified Data.Text as T
import qualified Lua.LPeg as LPeg
import qualified HsLua.Module.DocLayout as Module.Layout
@@ -82,9 +82,10 @@ initLuaState = do
-- load modules and add them to the `pandoc` module table.
forM_ loadedModules $ \mdl -> do
registerModule mdl
- let isNotAsciiDot = (/= 46)
- let fieldname = B.takeWhileEnd isNotAsciiDot (fromName $ moduleName mdl)
- Lua.setfield (nth 2) (Name fieldname)
+ let fieldname (Name mdlname) = Name .
+ maybe mdlname snd . Char8.uncons . snd $
+ Char8.break (== '.') mdlname
+ Lua.setfield (nth 2) (fieldname $ moduleName mdl)
-- pandoc.List is low-level and must be opened differently.
requirehs "pandoc.List" (const pushListModule)
setfield (nth 2) "List"