@@ -17,6 +17,7 @@ import Text.Hakyll.Hakyll
1717import Text.Hakyll.Regex (substituteRegex, matchesRegex)
1818import Text.Hakyll.Util (trim)
1919import Text.Hakyll.Internal.Cache
20+import Text.Hakyll.Internal.FileType
2021
2122-- | The default reader options for pandoc parsing.
2223readerOptions :: ParserState
@@ -35,18 +36,19 @@ writerOptions = defaultWriterOptions
3536 }
3637
3738-- | Get a render function for a given extension.
38−getRenderFunction :: String -> (String -> String)
39−getRenderFunction ".html" = id
40−getRenderFunction ".htm" = id
41−getRenderFunction ext = writeHtmlString writerOptions
42− . readFunction ext (readOptions ext)
39+getRenderFunction :: FileType -> (String -> String)
40+getRenderFunction Html = id
41+getRenderFunction fileType = writeHtmlString writerOptions
42+ . readFunction fileType (readOptions fileType)
4343 where
44− readFunction ".rst" = readRST
45− readFunction ".tex" = readLaTeX
46− readFunction _ = readMarkdown
44+ readFunction ReStructuredText = readRST
45+ readFunction LaTeX = readLaTeX
46+ readFunction Markdown = readMarkdown
47+ readFunction t = error $ "Cannot render file " ++ show t
4748
48− readOptions ".lhs" = readerOptions { stateLiterateHaskell = True }
49− readOptions _ = readerOptions
49+ readOptions LiterateHaskellMarkdown =
50+ readerOptions { stateLiterateHaskell = True }
51+ readOptions _ = readerOptions
5052
5153-- | Split a page into sections.
5254splitAtDelimiters :: [String] -> [[String]]
@@ -89,7 +91,7 @@ readSection renderFunction isFirst ls
8991-- has a @.markdown@ extension, it will be rendered using pandoc.
9092readPageFromFile :: FilePath -> Hakyll Context
9193readPageFromFile path = do
92− let renderFunction = getRenderFunction $ takeExtension path
94+ let renderFunction = getRenderFunction $ getFileType path
9395 sectionFunctions = map (readSection renderFunction)
9496 (True : repeat False)
9597