diff options
author | John MacFarlane <jgm@berkeley.edu> | 2017-09-30 10:50:02 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-30 10:50:02 -0400 |
commit | 9b7d652ab7a0f4cdd86efd92f43f1b20724e8982 (patch) | |
tree | 86ca5048451a0a73409d83ba9a092c870f0e7928 /src/Text/Pandoc/App.hs | |
parent | c363519302e11daab2187445f39a15ce6ef19137 (diff) | |
parent | 53b6ffe9b882fc122e99cda045619411708bf434 (diff) | |
download | pandoc-9b7d652ab7a0f4cdd86efd92f43f1b20724e8982.tar.gz |
Merge pull request #3945 from tarleb/lua-mediabag
Lua mediabag module
Diffstat (limited to 'src/Text/Pandoc/App.hs')
-rw-r--r-- | src/Text/Pandoc/App.hs | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/Text/Pandoc/App.hs b/src/Text/Pandoc/App.hs index 206c47b30..9b3055b35 100644 --- a/src/Text/Pandoc/App.hs +++ b/src/Text/Pandoc/App.hs @@ -511,10 +511,10 @@ convertWithOpts opts = do ( (if isJust (optExtractMedia opts) then fillMediaBag (writerSourceURL writerOptions) else return) - >=> maybe return extractMedia (optExtractMedia opts) >=> return . flip (foldr addMetadata) metadata - >=> applyTransforms transforms >=> applyLuaFilters datadir (optLuaFilters opts) format + >=> maybe return extractMedia (optExtractMedia opts) + >=> applyTransforms transforms >=> applyFilters readerOpts datadir filters' [format] ) media <- getMediaBag @@ -850,16 +850,15 @@ expandFilterPath mbDatadir fp = liftIO $ do else return fp _ -> return fp -applyLuaFilters :: MonadIO m - => Maybe FilePath -> [FilePath] -> String -> Pandoc - -> m Pandoc +applyLuaFilters :: Maybe FilePath -> [FilePath] -> String -> Pandoc + -> PandocIO Pandoc applyLuaFilters mbDatadir filters format d = do expandedFilters <- mapM (expandFilterPath mbDatadir) filters - let go f d' = liftIO $ do - res <- E.try (runLuaFilter mbDatadir f format d') + let go f d' = do + res <- runLuaFilter mbDatadir f format d' case res of - Right x -> return x - Left (LuaException s) -> E.throw (PandocFilterError f s) + Right x -> return x + Left (LuaException s) -> E.throw (PandocFilterError f s) foldrM ($) d $ map go expandedFilters applyFilters :: MonadIO m |