aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <fiddlosopher@gmail.com>2012-01-21 09:34:47 -0800
committerJohn MacFarlane <fiddlosopher@gmail.com>2012-01-21 09:34:47 -0800
commita75a0762afc830772354ca56a370d06873af7dab (patch)
tree5217ebbf4fe0969785dcb3090e345b39f5235433
parent58f9b3bc38df1e2f07e9317388988107858aa53c (diff)
downloadpandoc-a75a0762afc830772354ca56a370d06873af7dab.tar.gz
pandoc: Check for latex program earlier.
-rw-r--r--src/pandoc.hs23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/pandoc.hs b/src/pandoc.hs
index b986c6528..a9a35ac57 100644
--- a/src/pandoc.hs
+++ b/src/pandoc.hs
@@ -813,6 +813,15 @@ main = do
then defaultWriterName outputFile
else writerName
+ when (writerName' == "pdf") $ do
+ -- check for latex program
+ mbLatex <- findExecutable latexProgram
+ case mbLatex of
+ Nothing -> err 41 $
+ latexProgram ++ " not found. " ++
+ latexProgram ++ " is needed for pdf output."
+ Just _ -> return ()
+
reader <- case (lookup readerName' readers) of
Just r -> return r
Nothing -> err 7 ("Unknown reader: " ++ readerName')
@@ -976,16 +985,10 @@ main = do
| writerName' == "docx" ->
writeDocx referenceDocx writerOptions doc2 >>= writeBinary
| writerName' == "pdf" ->
- do -- first check to make sure we have latex
- mbLatex <- findExecutable latexProgram
- case mbLatex of
- Nothing -> err 41 $
- latexProgram ++ " not found" -- TODO improve
- Just pgm -> do
- res <- tex2pdf pgm $ writeLaTeX writerOptions doc2
- case res of
- Right pdf -> writeBinary pdf
- Left err' -> err 43 $ toString err'
+ do res <- tex2pdf latexProgram $ writeLaTeX writerOptions doc2
+ case res of
+ Right pdf -> writeBinary pdf
+ Left err' -> err 43 $ toString err'
| otherwise -> err 9 ("Unknown writer: " ++ writerName')
where writeBinary = B.writeFile (encodeString outputFile)
Just r -> writerFn outputFile =<< postProcess result