From ff55530c038e954d6736984a31032b21162d1812 Mon Sep 17 00:00:00 2001 From: Albert Krewinkel Date: Wed, 7 Nov 2018 21:31:09 +0100 Subject: T.P.App: fix regression in output format heuristics This fix is necessary due to a rebasing error introduced in commit 418bd42df85b93016e50ba48042804e8f51341b5 --- src/Text/Pandoc/App/OutputSettings.hs | 52 ++++------------------------------- 1 file changed, 5 insertions(+), 47 deletions(-) (limited to 'src') diff --git a/src/Text/Pandoc/App/OutputSettings.hs b/src/Text/Pandoc/App/OutputSettings.hs index 654e240d4..3788af7bf 100644 --- a/src/Text/Pandoc/App/OutputSettings.hs +++ b/src/Text/Pandoc/App/OutputSettings.hs @@ -50,6 +50,7 @@ import System.Exit (exitSuccess) import System.FilePath import System.IO (stdout) import Text.Pandoc +import Text.Pandoc.App.FormatHeuristics (formatFromFilePaths) import Text.Pandoc.App.Opt (Opt (..)) import Text.Pandoc.App.CommandLineOptions (engines) import Text.Pandoc.BCP47 (Lang (..), parseBCP47) @@ -81,14 +82,14 @@ optToOutputSettings opts = do Nothing -> return Nothing Just fp -> Just <$> readUtf8File fp - let nonPdfWriterName Nothing = defaultWriterName outputFile - nonPdfWriterName (Just x) = x - let pdfOutput = map toLower (takeExtension outputFile) == ".pdf" (writerName, maybePdfProg) <- if pdfOutput then liftIO $ pdfWriterAndProg (optWriter opts) (optPdfEngine opts) - else return (nonPdfWriterName $ optWriter opts, Nothing) + else case optWriter opts of + Nothing -> + return (formatFromFilePaths "html" [outputFile], Nothing) + Just f -> return (f, Nothing) let format = map toLower $ baseWriterName $ takeFileName writerName -- in case path to lua script @@ -232,49 +233,6 @@ optToOutputSettings opts = do , outputPdfProgram = maybePdfProg } --- Determine default writer based on output file extension -defaultWriterName :: FilePath -> String -defaultWriterName "-" = "html" -- no output file -defaultWriterName x = - case takeExtension (map toLower x) of - "" -> "markdown" -- empty extension - ".tex" -> "latex" - ".latex" -> "latex" - ".ltx" -> "latex" - ".context" -> "context" - ".ctx" -> "context" - ".rtf" -> "rtf" - ".rst" -> "rst" - ".s5" -> "s5" - ".native" -> "native" - ".json" -> "json" - ".txt" -> "markdown" - ".text" -> "markdown" - ".md" -> "markdown" - ".muse" -> "muse" - ".markdown" -> "markdown" - ".textile" -> "textile" - ".lhs" -> "markdown+lhs" - ".texi" -> "texinfo" - ".texinfo" -> "texinfo" - ".db" -> "docbook" - ".odt" -> "odt" - ".docx" -> "docx" - ".epub" -> "epub" - ".org" -> "org" - ".asciidoc" -> "asciidoc" - ".adoc" -> "asciidoc" - ".fb2" -> "fb2" - ".opml" -> "opml" - ".icml" -> "icml" - ".tei.xml" -> "tei" - ".tei" -> "tei" - ".ms" -> "ms" - ".roff" -> "ms" - ".pptx" -> "pptx" - ['.',y] | y `elem` ['1'..'9'] -> "man" - _ -> "html" - baseWriterName :: String -> String baseWriterName = takeWhile (\c -> c /= '+' && c /= '-') -- cgit v1.2.3