git.iko.soy/typeable/pandoc
on master help sign in
pandoc: Check for latex program earlier.
commita75a0762afc830772354ca56a370d06873af7dab authorJohn MacFarlane <fiddlosopher@gmail.com> dateSat 21 Jan 2012, 09:34 (15 years ago) parent58f9b3b
1 file changed+13−10
src/pandoc.hs+13−10
src/pandoc.hs+13−10
@@ -813,6 +813,15 @@ main = do
813813 then defaultWriterName outputFile
814814 else writerName
815815
816+ when (writerName' == "pdf") $ do
817+ -- check for latex program
818+ mbLatex <- findExecutable latexProgram
819+ case mbLatex of
820+ Nothing -> err 41 $
821+ latexProgram ++ " not found. " ++
822+ latexProgram ++ " is needed for pdf output."
823+ Just _ -> return ()
824+
816825 reader <- case (lookup readerName' readers) of
817826 Just r -> return r
818827 Nothing -> err 7 ("Unknown reader: " ++ readerName')
@@ -976,16 +985,10 @@ main = do
976985 | writerName' == "docx" ->
977986 writeDocx referenceDocx writerOptions doc2 >>= writeBinary
978987 | writerName' == "pdf" ->
979− do -- first check to make sure we have latex
980− mbLatex <- findExecutable latexProgram
981− case mbLatex of
982− Nothing -> err 41 $
983− latexProgram ++ " not found" -- TODO improve
984− Just pgm -> do
985− res <- tex2pdf pgm $ writeLaTeX writerOptions doc2
986− case res of
987− Right pdf -> writeBinary pdf
988− Left err' -> err 43 $ toString err'
988+ do res <- tex2pdf latexProgram $ writeLaTeX writerOptions doc2
989+ case res of
990+ Right pdf -> writeBinary pdf
991+ Left err' -> err 43 $ toString err'
989992 | otherwise -> err 9 ("Unknown writer: " ++ writerName')
990993 where writeBinary = B.writeFile (encodeString outputFile)
991994 Just r -> writerFn outputFile =<< postProcess result