aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/App
diff options
context:
space:
mode:
Diffstat (limited to 'src/Text/Pandoc/App')
-rw-r--r--src/Text/Pandoc/App/FormatHeuristics.hs12
-rw-r--r--src/Text/Pandoc/App/OutputSettings.hs3
2 files changed, 8 insertions, 7 deletions
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