aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMauro Bieg <mb21@users.noreply.github.com>2018-08-03 21:04:38 +0200
committerJohn MacFarlane <jgm@berkeley.edu>2018-08-03 12:04:38 -0700
commitf83bdb1ac50064714cb80502a4b7ad895a897c14 (patch)
treeb0495953c07be7f3f728b08f76870a5e5f3828c1 /src
parent2661658a696ebaab14b2792b7bbd38ef2b5904e4 (diff)
downloadpandoc-f83bdb1ac50064714cb80502a4b7ad895a897c14.tar.gz
Better error message on `-t pdf -o out.pdf` (#4815)
closes #1155 (again)
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/App.hs14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/Text/Pandoc/App.hs b/src/Text/Pandoc/App.hs
index f4b7f1904..44bb30223 100644
--- a/src/Text/Pandoc/App.hs
+++ b/src/Text/Pandoc/App.hs
@@ -142,6 +142,13 @@ engines = map ("html",) htmlEngines ++
pdfEngines :: [String]
pdfEngines = ordNub $ map snd engines
+pdfIsNoWriterErrorMsg :: String
+pdfIsNoWriterErrorMsg =
+ "To create a pdf using pandoc, use " ++
+ "-t latex|beamer|context|ms|html5" ++
+ "\nand specify an output file with " ++
+ ".pdf extension (-o filename.pdf)."
+
pdfWriterAndProg :: Maybe String -- ^ user-specified writer name
-> Maybe String -- ^ user-specified pdf-engine
-> IO (String, Maybe String) -- ^ IO (writerName, maybePdfEngineProg)
@@ -165,6 +172,7 @@ pdfWriterAndProg mWriter mEngine = do
[] -> Left $
"pdf-engine " ++ eng ++ " not known"
+ engineForWriter "pdf" = Left pdfIsNoWriterErrorMsg
engineForWriter w = case [e | (f,e) <- engines, f == baseWriterName w] of
eng : _ -> Right eng
[] -> Left $
@@ -233,11 +241,7 @@ convertWithOpts opts = do
else case getWriter (map toLower writerName) of
Left e -> E.throwIO $ PandocAppError $
if format == "pdf"
- then e ++
- "\nTo create a pdf using pandoc, use " ++
- "-t latex|beamer|context|ms|html5" ++
- "\nand specify an output file with " ++
- ".pdf extension (-o filename.pdf)."
+ then e ++ "\n" ++ pdfIsNoWriterErrorMsg
else e
Right (w, es) -> return (w :: Writer PandocIO, es)