aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Text/Pandoc/MediaBag.hs10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/Text/Pandoc/MediaBag.hs b/src/Text/Pandoc/MediaBag.hs
index eea25fadf..fe99be5fe 100644
--- a/src/Text/Pandoc/MediaBag.hs
+++ b/src/Text/Pandoc/MediaBag.hs
@@ -42,6 +42,7 @@ import System.Directory (createDirectoryIfMissing)
import qualified Data.Map as M
import qualified Data.ByteString.Lazy as BL
import Control.Monad (when)
+import Control.Monad.Trans (MonadIO(..))
import Text.Pandoc.MIME (MimeType, getMimeTypeDef)
import qualified Text.Pandoc.UTF8 as UTF8
import Data.Maybe (fromMaybe)
@@ -88,11 +89,14 @@ mediaDirectory (MediaBag mediamap) =
-- | Extract contents of MediaBag to a given directory. Print informational
-- messages if 'verbose' is true.
-extractMediaBag :: Bool
+-- TODO: eventually we may want to put this into PandocMonad
+-- In PandocPure, it could write to the fake file system...
+extractMediaBag :: MonadIO m
+ => Bool
-> FilePath
-> MediaBag
- -> IO ()
-extractMediaBag verbose dir (MediaBag mediamap) = do
+ -> m ()
+extractMediaBag verbose dir (MediaBag mediamap) = liftIO $ do
sequence_ $ M.foldWithKey
(\fp (_ ,contents) ->
((writeMedia verbose dir (Posix.joinPath fp, contents)):)) [] mediamap