diff options
Diffstat (limited to 'src/Text/Pandoc/App')
-rw-r--r-- | src/Text/Pandoc/App/CommandLineOptions.hs | 23 | ||||
-rw-r--r-- | src/Text/Pandoc/App/OutputSettings.hs | 21 |
2 files changed, 23 insertions, 21 deletions
diff --git a/src/Text/Pandoc/App/CommandLineOptions.hs b/src/Text/Pandoc/App/CommandLineOptions.hs index cffe69eca..abb73ec92 100644 --- a/src/Text/Pandoc/App/CommandLineOptions.hs +++ b/src/Text/Pandoc/App/CommandLineOptions.hs @@ -768,12 +768,25 @@ options = , Option "" ["list-extensions"] (OptArg (\arg _ -> do - let exts = getDefaultExtensions (fromMaybe "markdown" arg) - let showExt x = (if extensionEnabled x exts - then '+' - else '-') : drop 4 (show x) + let extList :: [Extension] + extList = [minBound..maxBound] + let allExts = + case arg of + Nothing -> extensionsFromList extList + Just fmt -> getAllExtensions fmt + let defExts = + case arg of + Nothing -> getDefaultExtensions + "markdown" + Just fmt -> getDefaultExtensions fmt + let showExt x = + (if extensionEnabled x defExts + then '+' + else if extensionEnabled x allExts + then '-' + else ' ') : drop 4 (show x) mapM_ (UTF8.hPutStrLn stdout . showExt) - ([minBound..maxBound] :: [Extension]) + [ex | ex <- extList, extensionEnabled ex allExts] exitSuccess ) "FORMAT") "" diff --git a/src/Text/Pandoc/App/OutputSettings.hs b/src/Text/Pandoc/App/OutputSettings.hs index 744f4591f..cfb6f7ec2 100644 --- a/src/Text/Pandoc/App/OutputSettings.hs +++ b/src/Text/Pandoc/App/OutputSettings.hs @@ -85,18 +85,12 @@ optToOutputSettings opts = do then writerName else map toLower $ baseWriterName writerName - (writer, writerExts) <- + (writer :: Writer PandocIO, writerExts) <- if ".lua" `isSuffixOf` format then return (TextWriter (\o d -> writeCustom writerName o d) :: Writer PandocIO, mempty) - else case getWriter (map toLower writerName) of - Left e -> throwError $ PandocAppError $ - if format == "pdf" - then e ++ "\n" ++ pdfIsNoWriterErrorMsg - else e - Right (w, es) -> return (w :: Writer PandocIO, es) - + else getWriter (map toLower writerName) let standalone = optStandalone opts || not (isTextFormat format) || pdfOutput @@ -249,13 +243,6 @@ optToOutputSettings opts = do baseWriterName :: String -> String baseWriterName = takeWhile (\c -> c /= '+' && c /= '-') -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) @@ -263,6 +250,8 @@ pdfWriterAndProg mWriter mEngine = do let panErr msg = liftIO $ E.throwIO $ PandocAppError msg case go mWriter mEngine of Right (writ, prog) -> return (writ, Just prog) + Left "pdf writer" -> liftIO $ E.throwIO $ + PandocUnknownWriterError "pdf" Left err -> panErr err where go Nothing Nothing = Right ("latex", "pdflatex") @@ -279,7 +268,7 @@ pdfWriterAndProg mWriter mEngine = do [] -> Left $ "pdf-engine " ++ eng ++ " not known" - engineForWriter "pdf" = Left pdfIsNoWriterErrorMsg + engineForWriter "pdf" = Left "pdf writer" engineForWriter w = case [e | (f,e) <- engines, f == baseWriterName w] of eng : _ -> Right eng [] -> Left $ |