git.iko.soy/typeable/pandoc
on master help sign in
T.P.App: fix regression in output format heuristics

This fix is necessary due to a rebasing error introduced in commit 418bd42df85b93016e50ba48042804e8f51341b5

commitff55530c038e954d6736984a31032b21162d1812 authorAlbert Krewinkel <albert@zeitkraut.de> dateWed 7 Nov 2018, 21:31 (8 years ago) parent12f6cf1
1 file changed+5−47
src/Text/Pandoc/App/OutputSettings.hs+5−47
src/Text/Pandoc/App/OutputSettings.hs+5−47
@@ -50,6 +50,7 @@ import System.Exit (exitSuccess)
5050import System.FilePath
5151import System.IO (stdout)
5252import Text.Pandoc
53+import Text.Pandoc.App.FormatHeuristics (formatFromFilePaths)
5354import Text.Pandoc.App.Opt (Opt (..))
5455import Text.Pandoc.App.CommandLineOptions (engines)
5556import Text.Pandoc.BCP47 (Lang (..), parseBCP47)
@@ -81,14 +82,14 @@ optToOutputSettings opts = do
8182 Nothing -> return Nothing
8283 Just fp -> Just <$> readUtf8File fp
8384
84− let nonPdfWriterName Nothing = defaultWriterName outputFile
85− nonPdfWriterName (Just x) = x
86−
8785 let pdfOutput = map toLower (takeExtension outputFile) == ".pdf"
8886 (writerName, maybePdfProg) <-
8987 if pdfOutput
9088 then liftIO $ pdfWriterAndProg (optWriter opts) (optPdfEngine opts)
91− else return (nonPdfWriterName $ optWriter opts, Nothing)
89+ else case optWriter opts of
90+ Nothing ->
91+ return (formatFromFilePaths "html" [outputFile], Nothing)
92+ Just f -> return (f, Nothing)
9293
9394 let format = map toLower $ baseWriterName
9495 $ takeFileName writerName -- in case path to lua script
@@ -232,49 +233,6 @@ optToOutputSettings opts = do
232233 , outputPdfProgram = maybePdfProg
233234 }
234235
235−-- Determine default writer based on output file extension
236−defaultWriterName :: FilePath -> String
237−defaultWriterName "-" = "html" -- no output file
238−defaultWriterName x =
239− case takeExtension (map toLower x) of
240− "" -> "markdown" -- empty extension
241− ".tex" -> "latex"
242− ".latex" -> "latex"
243− ".ltx" -> "latex"
244− ".context" -> "context"
245− ".ctx" -> "context"
246− ".rtf" -> "rtf"
247− ".rst" -> "rst"
248− ".s5" -> "s5"
249− ".native" -> "native"
250− ".json" -> "json"
251− ".txt" -> "markdown"
252− ".text" -> "markdown"
253− ".md" -> "markdown"
254− ".muse" -> "muse"
255− ".markdown" -> "markdown"
256− ".textile" -> "textile"
257− ".lhs" -> "markdown+lhs"
258− ".texi" -> "texinfo"
259− ".texinfo" -> "texinfo"
260− ".db" -> "docbook"
261− ".odt" -> "odt"
262− ".docx" -> "docx"
263− ".epub" -> "epub"
264− ".org" -> "org"
265− ".asciidoc" -> "asciidoc"
266− ".adoc" -> "asciidoc"
267− ".fb2" -> "fb2"
268− ".opml" -> "opml"
269− ".icml" -> "icml"
270− ".tei.xml" -> "tei"
271− ".tei" -> "tei"
272− ".ms" -> "ms"
273− ".roff" -> "ms"
274− ".pptx" -> "pptx"
275− ['.',y] | y `elem` ['1'..'9'] -> "man"
276− _ -> "html"
277−
278236baseWriterName :: String -> String
279237baseWriterName = takeWhile (\c -> c /= '+' && c /= '-')
280238