3-- https://github.com/jgm/pandoc/blob/master/src/Text/Pandoc/App/FormatHeuristics.hs
9import Data.ByteString.Lazy (ByteString)
10import Data.Char (toLower)
12import qualified Data.Map as M
13import qualified Data.OpenApi.Compare.Report.Html.Template as Html
14import Data.Text (Text)
15import qualified Data.Text.Lazy as TL
16import qualified Data.Text.Lazy.Encoding as TL
17import System.FilePath (takeExtension)
18import Text.DocTemplates.Internal
21formatFromFilePath :: forall m. PandocMonad m => FilePath -> Maybe (Pandoc -> m ByteString, FilePath)
23 case takeExtension (map toLower x) of
24 ".adoc" -> fWithDefaultFile "asciidoc" def
25 ".asciidoc" -> fWithDefaultFile "asciidoc" def
26 ".context" -> fWithDefaultFile "context" def
27 ".ctx" -> fWithDefaultFile "context" def
28 ".db" -> fWithDefaultFile "docbook" def
29 ".doc" -> fWithDefaultFile "doc" def -- so we get an "unknown reader" error
30 ".docx" -> fWithDefaultFile "docx" def
31 ".dokuwiki" -> fWithDefaultFile "dokuwiki" def
32 ".epub" -> fWithDefaultFile "epub" def
33 ".fb2" -> fWithDefaultFile "fb2" def
34 ".htm" -> fWithDefaultFile "html" def
35 ".html" -> fWithDefaultFile "html" def
36 ".icml" -> fWithDefaultFile "icml" def
37 ".json" -> fWithDefaultFile "json" def
38 ".latex" -> fWithDefaultFile "latex" def
39 ".lhs" -> fWithDefaultFile "markdown+lhs" def
40 ".ltx" -> fWithDefaultFile "latex" def
41 ".markdown" -> markdown
48 ".ms" -> fWithDefaultFile "ms" def
49 ".muse" -> fWithDefaultFile "muse" def
50 ".native" -> fWithDefaultFile "native" def
51 ".odt" -> fWithDefaultFile "odt" def
52 ".opml" -> fWithDefaultFile "opml" def
53 ".org" -> fWithDefaultFile "org" def
54 -- so we get an "unknown reader" error
55 ".pdf" -> fWithDefaultFile "pdf" def
56 ".pptx" -> fWithDefaultFile "pptx" def
57 ".roff" -> fWithDefaultFile "ms" def
58 ".rst" -> fWithDefaultFile "rst" def
59 ".rtf" -> fWithDefaultFile "rtf" def
60 ".s5" -> fWithDefaultFile "s5" def
61 ".t2t" -> fWithDefaultFile "t2t" def
62 ".tei" -> fWithDefaultFile "tei" def
63 ".tei.xml" -> fWithDefaultFile "tei" def
64 ".tex" -> fWithDefaultFile "latex" def
65 ".texi" -> fWithDefaultFile "texinfo" def
66 ".texinfo" -> fWithDefaultFile "texinfo" def
68 ".textile" -> fWithDefaultFile "textile" def
70 ".wiki" -> fWithDefaultFile "mediawiki" def
71 ".xhtml" -> fWithDefaultFile "html" def
72 ".ipynb" -> fWithDefaultFile "ipynb" def
73 ".csv" -> fWithDefaultFile "csv" def
74 ".bib" -> fWithDefaultFile "biblatex" def
75 ['.', y] | y `elem` ['1' .. '9'] -> fWithDefaultFile "man" def
81 { writerTemplate = Just Html.template
82 , -- Not actually used. Needed to silence warning.
83 writerVariables = Context $ M.fromList [("pagetitle", toVal ("CompaREST" :: Text))]
87 markdown :: Maybe (Pandoc -> m ByteString, FilePath)
88 markdown = fWithDefaultFile "markdown" markdownOpt
90 markdownOpt = def {writerExtensions = githubMarkdownExtensions}
91 fWithDefaultFile k opt = (,x) <$> f k opt
93 lookup k writers <&> \case
94 TextWriter g -> fmap (TL.encodeUtf8 . TL.fromStrict) . g opt
95 ByteStringWriter g -> g opt
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list