@@ -81,11 +81,12 @@ changePathSeparators = intercalate "/" . splitDirectories
82makePDF :: String -- ^ pdf creator (pdflatex, lualatex, xelatex,
82makePDF :: String -- ^ pdf creator (pdflatex, lualatex, xelatex,
83 -- wkhtmltopdf, weasyprint, prince, context, pdfroff)
83 -- wkhtmltopdf, weasyprint, prince, context, pdfroff)
84+ -> [String] -- ^ arguments to pass to pdf creator
84 -> (WriterOptions -> Pandoc -> PandocIO Text) -- ^ writer
85 -> (WriterOptions -> Pandoc -> PandocIO Text) -- ^ writer
85 -> WriterOptions -- ^ options
86 -> WriterOptions -- ^ options
86 -> Pandoc -- ^ document
87 -> Pandoc -- ^ document
87 -> PandocIO (Either ByteString ByteString)
88 -> PandocIO (Either ByteString ByteString)
88−makePDF "wkhtmltopdf" writer opts doc@(Pandoc meta _) = do
89+makePDF "wkhtmltopdf" pdfargs writer opts doc@(Pandoc meta _) = do
89 let mathArgs = case writerHTMLMathMethod opts of
90 let mathArgs = case writerHTMLMathMethod opts of
90 -- with MathJax, wait til all math is rendered:
91 -- with MathJax, wait til all math is rendered:
91 MathJax _ -> ["--run-script", "MathJax.Hub.Register.StartupHook('End Typeset', function() { window.status = 'mathjax_loaded' });",
92 MathJax _ -> ["--run-script", "MathJax.Hub.Register.StartupHook('End Typeset', function() { window.status = 'mathjax_loaded' });",
@@ -93,8 +94,7 @@ makePDF "wkhtmltopdf" writer opts doc@(Pandoc meta _) = do
94 meta' <- metaToJSON opts (return . stringify) (return . stringify) meta
95 meta' <- metaToJSON opts (return . stringify) (return . stringify) meta
95 let toArgs (f, mbd) = maybe [] (\d -> ['-':'-':f, d]) mbd
96 let toArgs (f, mbd) = maybe [] (\d -> ['-':'-':f, d]) mbd
96− let args = writerPdfArgs opts ++ mathArgs ++
97− concatMap toArgs
97+ let args = pdfargs ++ mathArgs ++ concatMap toArgs
98 [("page-size", getField "papersize" meta')
98 [("page-size", getField "papersize" meta')
99 ,("title", getField "title" meta')
99 ,("title", getField "title" meta')
100 ,("margin-bottom", fromMaybe (Just "1.2in")
100 ,("margin-bottom", fromMaybe (Just "1.2in")
@@ -109,23 +109,21 @@ makePDF "wkhtmltopdf" writer opts doc@(Pandoc meta _) = do
109 source <- writer opts doc
109 source <- writer opts doc
110 verbosity <- getVerbosity
110 verbosity <- getVerbosity
111 liftIO $ html2pdf verbosity "wkhtmltopdf" args source
111 liftIO $ html2pdf verbosity "wkhtmltopdf" args source
112−makePDF "weasyprint" writer opts doc = do
112+makePDF "weasyprint" pdfargs writer opts doc = do
113− let args = writerPdfArgs opts
114 source <- writer opts doc
113 source <- writer opts doc
115 verbosity <- getVerbosity
114 verbosity <- getVerbosity
116− liftIO $ html2pdf verbosity "weasyprint" args source
115+ liftIO $ html2pdf verbosity "weasyprint" pdfargs source
117−makePDF "prince" writer opts doc = do
116+makePDF "prince" pdfargs writer opts doc = do
118− let args = writerPdfArgs opts
119 source <- writer opts doc
117 source <- writer opts doc
120 verbosity <- getVerbosity
118 verbosity <- getVerbosity
121− liftIO $ html2pdf verbosity "prince" args source
119+ liftIO $ html2pdf verbosity "prince" pdfargs source
122−makePDF "pdfroff" writer opts doc = do
120+makePDF "pdfroff" pdfargs writer opts doc = do
123 source <- writer opts doc
121 source <- writer opts doc
124 let args = ["-ms", "-mpdfmark", "-e", "-t", "-k", "-KUTF-8", "-i",
122 let args = ["-ms", "-mpdfmark", "-e", "-t", "-k", "-KUTF-8", "-i",
125− "--no-toc-relocation"] ++ writerPdfArgs opts
123+ "--no-toc-relocation"] ++ pdfargs
126 verbosity <- getVerbosity
124 verbosity <- getVerbosity
127 liftIO $ ms2pdf verbosity args source
125 liftIO $ ms2pdf verbosity args source
128−makePDF program writer opts doc = do
126+makePDF program pdfargs writer opts doc = do
129 let withTemp = if takeBaseName program == "context"
127 let withTemp = if takeBaseName program == "context"
130 then withTempDirectory "."
128 then withTempDirectory "."
131 else withTempDir
129 else withTempDir
@@ -136,11 +134,10 @@ makePDF program writer opts doc = do
136 putCommonState commonState
134 putCommonState commonState
137 doc' <- handleImages tmpdir doc
135 doc' <- handleImages tmpdir doc
138 writer opts doc'
136 writer opts doc'
139− let args = writerPdfArgs opts
140 case takeBaseName program of
137 case takeBaseName program of
141 "context" -> context2pdf verbosity tmpdir source
138 "context" -> context2pdf verbosity tmpdir source
142 prog | prog `elem` ["pdflatex", "lualatex", "xelatex"]
139 prog | prog `elem` ["pdflatex", "lualatex", "xelatex"]
143− -> tex2pdf' verbosity args tmpdir program source
140+ -> tex2pdf' verbosity pdfargs tmpdir program source
144 _ -> return $ Left $ UTF8.fromStringLazy $ "Unknown program " ++ program
141 _ -> return $ Left $ UTF8.fromStringLazy $ "Unknown program " ++ program
146handleImages :: FilePath -- ^ temp dir to store images
143handleImages :: FilePath -- ^ temp dir to store images