aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc
diff options
context:
space:
mode:
authorAlbert Krewinkel <albert+github@zeitkraut.de>2017-11-18 22:24:06 +0100
committerJohn MacFarlane <jgm@berkeley.edu>2017-11-18 13:24:06 -0800
commit53aafd66434d97f5e0e9209650581177e2c79a91 (patch)
treeaa703574e2b659a13c608f67cc35b93376da4fa2 /src/Text/Pandoc
parent6018a2324d4eddc3844aa4c00b17294e85003750 (diff)
downloadpandoc-53aafd66434d97f5e0e9209650581177e2c79a91.tar.gz
Lua filters: preload text module (#4077)
The `text` module is preloaded in lua. The module contains some UTF-8 aware string functions, implemented in Haskell. The module is loaded on request only, e.g.: text = require 'text' function Str (s) s.text = text.upper(s.text) return s end
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r--src/Text/Pandoc/Lua.hs2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/Text/Pandoc/Lua.hs b/src/Text/Pandoc/Lua.hs
index 355a5baf1..148e7a23d 100644
--- a/src/Text/Pandoc/Lua.hs
+++ b/src/Text/Pandoc/Lua.hs
@@ -46,6 +46,7 @@ import Text.Pandoc.Lua.PandocModule (pushMediaBagModule, pushPandocModule)
import Text.Pandoc.Lua.Filter (LuaFilter, walkMWithLuaFilter)
import Text.Pandoc.MediaBag (MediaBag)
import qualified Foreign.Lua as Lua
+import qualified Foreign.Lua.Module.Text as Lua
runLuaFilter :: Maybe FilePath -> FilePath -> String
-> Pandoc -> PandocIO (Either LuaException Pandoc)
@@ -64,6 +65,7 @@ runLuaFilter' :: CommonState
-> Pandoc -> Lua Pandoc
runLuaFilter' commonState datadir filterPath format mbRef pd = do
Lua.openlibs
+ Lua.preloadTextModule "text"
-- store module in global "pandoc"
pushPandocModule datadir
Lua.setglobal "pandoc"