aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlbert Krewinkel <albert@zeitkraut.de>2018-11-07 21:31:09 +0100
committerAlbert Krewinkel <albert@zeitkraut.de>2018-11-07 21:36:36 +0100
commitff55530c038e954d6736984a31032b21162d1812 (patch)
treead390618b94ae3945387585ee9be2b3d5daced0a /src
parent12f6cf13ad3ff48bede646ceff7ee2db300b4051 (diff)
downloadpandoc-ff55530c038e954d6736984a31032b21162d1812.tar.gz
T.P.App: fix regression in output format heuristics
This fix is necessary due to a rebasing error introduced in commit 418bd42df85b93016e50ba48042804e8f51341b5
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/App/OutputSettings.hs52
1 files changed, 5 insertions, 47 deletions
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 /= '-')