aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2017-09-26 20:20:09 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2017-09-26 20:20:09 -0700
commit9a47c7863b7c9d23928e51fd23b8ebc7ac684d16 (patch)
treeddb6daaed76ffca1442e989bcd1c60ede60b9674 /src
parent3fe4aad5a16545a92088510a00d2109a04fd25b8 (diff)
downloadpandoc-9a47c7863b7c9d23928e51fd23b8ebc7ac684d16.tar.gz
Lua filters: set global FORMAT instead of args.
This changes the type of runLuaFilter.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/App.hs8
-rw-r--r--src/Text/Pandoc/Lua.hs8
2 files changed, 8 insertions, 8 deletions
diff --git a/src/Text/Pandoc/App.hs b/src/Text/Pandoc/App.hs
index 89a804176..c26b8e768 100644
--- a/src/Text/Pandoc/App.hs
+++ b/src/Text/Pandoc/App.hs
@@ -514,7 +514,7 @@ convertWithOpts opts = do
>=> maybe return extractMedia (optExtractMedia opts)
>=> return . flip (foldr addMetadata) metadata
>=> applyTransforms transforms
- >=> applyLuaFilters datadir (optLuaFilters opts) [format]
+ >=> applyLuaFilters datadir (optLuaFilters opts) format
>=> applyFilters readerOpts datadir filters' [format]
)
media <- getMediaBag
@@ -850,12 +850,12 @@ expandFilterPath mbDatadir fp = liftIO $ do
_ -> return fp
applyLuaFilters :: MonadIO m
- => Maybe FilePath -> [FilePath] -> [String] -> Pandoc
+ => Maybe FilePath -> [FilePath] -> String -> Pandoc
-> m Pandoc
-applyLuaFilters mbDatadir filters args d = do
+applyLuaFilters mbDatadir filters format d = do
expandedFilters <- mapM (expandFilterPath mbDatadir) filters
let go f d' = liftIO $ do
- res <- E.try (runLuaFilter mbDatadir f args d')
+ res <- E.try (runLuaFilter mbDatadir f format d')
case res of
Right x -> return x
Left (LuaException s) -> E.throw (PandocFilterError f s)
diff --git a/src/Text/Pandoc/Lua.hs b/src/Text/Pandoc/Lua.hs
index 2860b84df..ab3b5f4ca 100644
--- a/src/Text/Pandoc/Lua.hs
+++ b/src/Text/Pandoc/Lua.hs
@@ -51,14 +51,14 @@ import qualified Data.Map as Map
import qualified Foreign.Lua as Lua
runLuaFilter :: (MonadIO m)
- => Maybe FilePath -> FilePath -> [String] -> Pandoc -> m Pandoc
-runLuaFilter datadir filterPath args pd = liftIO . Lua.runLua $ do
+ => Maybe FilePath -> FilePath -> String -> Pandoc -> m Pandoc
+runLuaFilter datadir filterPath format pd = liftIO . Lua.runLua $ do
Lua.openlibs
-- store module in global "pandoc"
pushPandocModule datadir
Lua.setglobal "pandoc"
- push args
- Lua.setglobal "arg"
+ push format
+ Lua.setglobal "FORMAT"
top <- Lua.gettop
stat <- Lua.dofile filterPath
if stat /= OK