diff options
author | John MacFarlane <jgm@berkeley.edu> | 2016-12-10 12:21:18 +0100 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2017-01-25 17:07:41 +0100 |
commit | 753c14cb63fb17d6a19f4e20a31c2a1f5474bc43 (patch) | |
tree | 19d252ae2346aaf97b01d9e100d191b72b31e198 /src/Text/Pandoc | |
parent | 4b4670ef6d1a3cf01e505813205d8c16734337e3 (diff) | |
download | pandoc-753c14cb63fb17d6a19f4e20a31c2a1f5474bc43.tar.gz |
PDF: put makePDF in MonadIO.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r-- | src/Text/Pandoc/PDF.hs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/Text/Pandoc/PDF.hs b/src/Text/Pandoc/PDF.hs index d1d1c803c..348f6a2fe 100644 --- a/src/Text/Pandoc/PDF.hs +++ b/src/Text/Pandoc/PDF.hs @@ -55,6 +55,7 @@ import Text.Pandoc.Writers.Shared (getField, metaToJSON) import Text.Pandoc.Options (WriterOptions(..), HTMLMathMethod(..)) import Text.Pandoc.MIME (extensionFromMimeType, getMimeType) import Text.Pandoc.Process (pipeProcess) +import Control.Monad.Trans (MonadIO(..)) import qualified Data.ByteString.Lazy as BL import qualified Codec.Picture as JP #ifdef _WINDOWS @@ -67,13 +68,14 @@ changePathSeparators :: FilePath -> FilePath changePathSeparators = intercalate "/" . splitDirectories #endif -makePDF :: String -- ^ pdf creator (pdflatex, lualatex, +makePDF :: MonadIO m + => String -- ^ pdf creator (pdflatex, lualatex, -- xelatex, context, wkhtmltopdf) -> (WriterOptions -> Pandoc -> PandocIO String) -- ^ writer -> WriterOptions -- ^ options -> Pandoc -- ^ document - -> IO (Either ByteString ByteString) -makePDF "wkhtmltopdf" writer opts doc@(Pandoc meta _) = do + -> m (Either ByteString ByteString) +makePDF "wkhtmltopdf" writer opts doc@(Pandoc meta _) = liftIO $ do let mathArgs = case writerHTMLMathMethod opts of -- with MathJax, wait til all math is rendered: MathJax _ -> ["--run-script", "MathJax.Hub.Register.StartupHook('End Typeset', function() { window.status = 'mathjax_loaded' });", @@ -96,7 +98,7 @@ makePDF "wkhtmltopdf" writer opts doc@(Pandoc meta _) = do ] source <- runIOorExplode $ writer opts doc html2pdf (writerVerbose opts) args source -makePDF program writer opts doc = withTempDir "tex2pdf." $ \tmpdir -> do +makePDF program writer opts doc = liftIO $ withTempDir "tex2pdf." $ \tmpdir -> do doc' <- handleImages opts tmpdir doc source <- runIOorExplode $ writer opts doc' let args = writerLaTeXArgs opts |