aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Text/Pandoc/App.hs3
-rw-r--r--src/Text/Pandoc/App/FormatHeuristics.hs12
-rw-r--r--src/Text/Pandoc/App/OutputSettings.hs3
3 files changed, 10 insertions, 8 deletions
diff --git a/src/Text/Pandoc/App.hs b/src/Text/Pandoc/App.hs
index aabefc64a..d48ae1932 100644
--- a/src/Text/Pandoc/App.hs
+++ b/src/Text/Pandoc/App.hs
@@ -104,7 +104,8 @@ convertWithOpts opts = do
-- assign reader and writer based on options and filenames
let readerName = case optReader opts of
Just f -> f
- Nothing -> formatFromFilePaths fallback sources
+ Nothing -> fromMaybe fallback $
+ formatFromFilePaths sources
where fallback = if any isURI sources
then "html"
else "markdown"
diff --git a/src/Text/Pandoc/App/FormatHeuristics.hs b/src/Text/Pandoc/App/FormatHeuristics.hs
index 6198e83dc..a02d8d15e 100644
--- a/src/Text/Pandoc/App/FormatHeuristics.hs
+++ b/src/Text/Pandoc/App/FormatHeuristics.hs
@@ -18,13 +18,13 @@ import Prelude
import Data.Char (toLower)
import System.FilePath (takeExtension)
--- Determine default reader based on source file extensions.
-formatFromFilePaths :: String -> [FilePath] -> String
-formatFromFilePaths fallback [] = fallback
-formatFromFilePaths fallback (x:xs) =
+-- Determine default format based on file extensions.
+formatFromFilePaths :: [FilePath] -> Maybe String
+formatFromFilePaths [] = Nothing
+formatFromFilePaths (x:xs) =
case formatFromFilePath x of
- Just f -> f
- Nothing -> formatFromFilePaths fallback xs
+ Just f -> Just f
+ Nothing -> formatFromFilePaths xs
-- Determine format based on file extension
formatFromFilePath :: FilePath -> Maybe String
diff --git a/src/Text/Pandoc/App/OutputSettings.hs b/src/Text/Pandoc/App/OutputSettings.hs
index 837636503..a9034d6f2 100644
--- a/src/Text/Pandoc/App/OutputSettings.hs
+++ b/src/Text/Pandoc/App/OutputSettings.hs
@@ -71,7 +71,8 @@ optToOutputSettings opts = do
then liftIO $ pdfWriterAndProg (optWriter opts) (optPdfEngine opts)
else case optWriter opts of
Nothing ->
- return (formatFromFilePaths "html" [outputFile], Nothing)
+ return (fromMaybe "html" $ formatFromFilePaths [outputFile],
+ Nothing)
Just f -> return (f, Nothing)
let format = if ".lua" `isSuffixOf` writerName