@@ -65,21 +65,26 @@ optToOutputSettings opts = do
6565 Nothing -> return Nothing
6666 Just fp -> Just <$> readUtf8File fp
6767
68− let pdfOutput = map toLower (takeExtension outputFile) == ".pdf"
68+ let pdfOutput = map toLower (takeExtension outputFile) == ".pdf" ||
69+ optTo opts == Just "pdf"
6970 (writerName, maybePdfProg) <-
7071 if pdfOutput
71− then liftIO $ pdfWriterAndProg (optTo opts) (optPdfEngine opts)
72+ then liftIO $ pdfWriterAndProg
73+ (case optTo opts of
74+ Just "pdf" -> Nothing
75+ x -> x)
76+ (optPdfEngine opts)
7277 else case optTo opts of
78+ Just f -> return (f, Nothing)
7379 Nothing
74− | outputFile == "-" -> return ("html", Nothing)
75− | otherwise ->
76− case formatFromFilePaths [outputFile] of
80+ | outputFile == "-" -> return ("html", Nothing)
81+ | otherwise ->
82+ case formatFromFilePaths [outputFile] of
7783 Nothing -> do
7884 report $ CouldNotDeduceFormat
7985 [takeExtension outputFile] "html"
8086 return ("html", Nothing)
8187 Just f -> return (f, Nothing)
82− Just f -> return (f, Nothing)
8388
8489 let format = if ".lua" `isSuffixOf` writerName
8590 then writerName
@@ -244,13 +249,10 @@ baseWriterName = takeWhile (\c -> c /= '+' && c /= '-')
244249pdfWriterAndProg :: Maybe String -- ^ user-specified writer name
245250 -> Maybe String -- ^ user-specified pdf-engine
246251 -> IO (String, Maybe String) -- ^ IO (writerName, maybePdfEngineProg)
247−pdfWriterAndProg mWriter mEngine = do
248− let panErr msg = liftIO $ E.throwIO $ PandocAppError msg
252+pdfWriterAndProg mWriter mEngine =
249253 case go mWriter mEngine of
250254 Right (writ, prog) -> return (writ, Just prog)
251− Left "pdf writer" -> liftIO $ E.throwIO $
252− PandocUnknownWriterError "pdf"
253− Left err -> panErr err
255+ Left err -> liftIO $ E.throwIO $ PandocAppError err
254256 where
255257 go Nothing Nothing = Right ("latex", "pdflatex")
256258 go (Just writer) Nothing = (writer,) <$> engineForWriter writer
@@ -273,4 +275,5 @@ pdfWriterAndProg mWriter mEngine = do
273275 "cannot produce pdf output from " ++ w
274276
275277isTextFormat :: String -> Bool
276−isTextFormat s = s `notElem` ["odt","docx","epub2","epub3","epub","pptx"]
278+isTextFormat s =
279+ s `notElem` ["odt","docx","epub2","epub3","epub","pptx","pdf"]