summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2017-05-20 22:42:30 +0200
committerJohn MacFarlane <jgm@berkeley.edu>2017-05-20 22:42:50 +0200
commit5c44fd554fbebc2e01a0aa9f569468789f353bf4 (patch)
treedad910edc123c6125c0d9d7f4b4bb397c59675e6
parentfd6e65b00ffc628488c27171f7dd9ab833c436c6 (diff)
PDF: Refactoring, makePDF is now in PandocIO [API change].
-rw-r--r--src/Text/Pandoc/PDF.hs21
1 files changed, 8 insertions, 13 deletions
diff --git a/src/Text/Pandoc/PDF.hs b/src/Text/Pandoc/PDF.hs
index cc9b38f7f..822067e78 100644
--- a/src/Text/Pandoc/PDF.hs
+++ b/src/Text/Pandoc/PDF.hs
@@ -72,16 +72,15 @@ changePathSeparators :: FilePath -> FilePath
changePathSeparators = intercalate "/" . splitDirectories
#endif
-makePDF :: MonadIO m
- => String -- ^ pdf creator (pdflatex, lualatex,
+makePDF :: String -- ^ pdf creator (pdflatex, lualatex,
-- xelatex, context, wkhtmltopdf, pdfroff)
-> (WriterOptions -> Pandoc -> PandocIO String) -- ^ writer
-> WriterOptions -- ^ options
-> Verbosity -- ^ verbosity level
-> MediaBag -- ^ media
-> Pandoc -- ^ document
- -> m (Either ByteString ByteString)
-makePDF "wkhtmltopdf" writer opts verbosity _ doc@(Pandoc meta _) = liftIO $ do
+ -> PandocIO (Either ByteString ByteString)
+makePDF "wkhtmltopdf" writer opts verbosity _ doc@(Pandoc meta _) = 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' });",
@@ -102,17 +101,13 @@ makePDF "wkhtmltopdf" writer opts verbosity _ doc@(Pandoc meta _) = liftIO $ do
,("margin-left", fromMaybe (Just "1.25in")
(getField "margin-left" meta'))
]
- source <- runIOorExplode $ do
- setVerbosity verbosity
- writer opts doc
- html2pdf verbosity args source
-makePDF "pdfroff" writer opts verbosity _mediabag doc = liftIO $ do
- source <- runIOorExplode $ do
- setVerbosity verbosity
- writer opts doc
+ source <- writer opts doc
+ liftIO $ html2pdf verbosity args source
+makePDF "pdfroff" writer opts verbosity _mediabag doc = do
+ source <- writer opts doc
let args = ["-ms", "-mpdfmark", "-e", "-t", "-k", "-KUTF-8", "-i",
"--no-toc-relocation"]
- ms2pdf verbosity args source
+ liftIO $ ms2pdf verbosity args source
makePDF program writer opts verbosity mediabag doc = do
let withTemp = if takeBaseName program == "context"
then withTempDirectory "."