aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <fiddlosopher@gmail.com>2014-04-05 23:43:28 -0700
committerJohn MacFarlane <fiddlosopher@gmail.com>2014-04-05 23:44:57 -0700
commit11120d619bf15fceb1df265cf05b57b86fde0cb5 (patch)
tree6695329f4fae39ec67241ba493989b9536d88a98
parent971e4c43647cf28d1de0dbc109a6ec6f269fa563 (diff)
downloadpandoc-11120d619bf15fceb1df265cf05b57b86fde0cb5.tar.gz
Give more useful error message if '-t pdf' is specified.
Closes #1155.
-rw-r--r--pandoc.hs40
1 files changed, 24 insertions, 16 deletions
diff --git a/pandoc.hs b/pandoc.hs
index 6dd179ef9..d23fa79f3 100644
--- a/pandoc.hs
+++ b/pandoc.hs
@@ -1022,17 +1022,15 @@ main = do
let laTeXOutput = "latex" `isPrefixOf` writerName' ||
"beamer" `isPrefixOf` writerName'
- when pdfOutput $ do
- -- make sure writer is latex or beamer
- unless laTeXOutput $
- err 47 $ "cannot produce pdf output with " ++ writerName' ++ " writer"
- -- check for latex program
- mbLatex <- findExecutable latexEngine
- case mbLatex of
- Nothing -> err 41 $
- latexEngine ++ " not found. " ++
- latexEngine ++ " is needed for pdf output."
- Just _ -> return ()
+ writer <- case getWriter writerName' of
+ Left e -> err 9 $
+ if writerName' == "pdf"
+ then e ++ "\nTo create a pdf with pandoc, use the " ++
+ "latex or beamer writer and specify\n" ++
+ "an output file with .pdf extension " ++
+ "(pandoc -t latex -o filename.pdf)."
+ else e
+ Right w -> return w
reader <- case getReader readerName' of
Right r -> return r
@@ -1179,12 +1177,22 @@ main = do
writerFn "-" = UTF8.putStr
writerFn f = UTF8.writeFile f
- case getWriter writerName' of
- Left e -> err 9 e
- Right (IOStringWriter f) -> f writerOptions doc2 >>= writerFn outputFile
- Right (IOByteStringWriter f) -> f writerOptions doc2 >>= writeBinary
- Right (PureStringWriter f)
+ case writer of
+ IOStringWriter f -> f writerOptions doc2 >>= writerFn outputFile
+ IOByteStringWriter f -> f writerOptions doc2 >>= writeBinary
+ PureStringWriter f
| pdfOutput -> do
+ -- make sure writer is latex or beamer
+ unless laTeXOutput $
+ err 47 $ "cannot produce pdf output with " ++ writerName' ++
+ " writer"
+
+ -- check for latex program
+ mbLatex <- findExecutable latexEngine
+ when (mbLatex == Nothing) $
+ err 41 $ latexEngine ++ " not found. " ++
+ latexEngine ++ " is needed for pdf output."
+
res <- makePDF latexEngine f writerOptions doc2
case res of
Right pdf -> writeBinary pdf