Fix .tex.lhs patch, add some test cases
This commit is contained in:
parent
d2d52133f6
commit
eaa190f1e3
3 changed files with 35 additions and 3 deletions
|
@ -8,7 +8,7 @@ module Hakyll.Web.Pandoc.FileType
|
|||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
import System.FilePath (takeExtension)
|
||||
import System.FilePath (splitExtension)
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
@ -36,12 +36,16 @@ data FileType
|
|||
--------------------------------------------------------------------------------
|
||||
-- | Get the file type for a certain file. The type is determined by extension.
|
||||
fileType :: FilePath -> FileType
|
||||
fileType = uncurry fileType' . splitExtension
|
||||
fileType = uncurry fileType' . splitExtension
|
||||
where
|
||||
fileType' _ ".css" = Css
|
||||
fileType' _ ".htm" = Html
|
||||
fileType' _ ".html" = Html
|
||||
fileType' f ".lhs" = LiterateHaskell (fileType' (takeExtension f))
|
||||
fileType' f ".lhs" = LiterateHaskell $ case fileType f of
|
||||
-- If no extension is given, default to Markdown + LiterateHaskell
|
||||
Binary -> Markdown
|
||||
-- Otherwise, LaTeX + LiterateHaskell or whatever the user specified
|
||||
x -> x
|
||||
fileType' _ ".markdown" = Markdown
|
||||
fileType' _ ".md" = Markdown
|
||||
fileType' _ ".mdn" = Markdown
|
||||
|
|
26
tests/Hakyll/Web/Pandoc/FileType/Tests.hs
Normal file
26
tests/Hakyll/Web/Pandoc/FileType/Tests.hs
Normal file
|
@ -0,0 +1,26 @@
|
|||
--------------------------------------------------------------------------------
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
module Hakyll.Web.Pandoc.FileType.Tests
|
||||
( tests
|
||||
) where
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
import Test.Framework (Test, testGroup)
|
||||
import Test.HUnit ((@=?))
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
import Hakyll.Web.Pandoc.FileType
|
||||
import TestSuite.Util
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
tests :: Test
|
||||
tests = testGroup "Hakyll.Web.Pandoc.FileType.Tests" $
|
||||
fromAssertions "fileType"
|
||||
[ Markdown @=? fileType "index.md"
|
||||
, Rst @=? fileType "about/foo.rst"
|
||||
, LiterateHaskell Markdown @=? fileType "posts/bananas.lhs"
|
||||
, LiterateHaskell LaTeX @=? fileType "posts/bananas.tex.lhs"
|
||||
]
|
|
@ -20,6 +20,7 @@ import qualified Hakyll.Core.UnixFilter.Tests
|
|||
import qualified Hakyll.Core.Util.String.Tests
|
||||
import qualified Hakyll.Web.Html.RelativizeUrls.Tests
|
||||
import qualified Hakyll.Web.Html.Tests
|
||||
import qualified Hakyll.Web.Pandoc.FileType.Tests
|
||||
import qualified Hakyll.Web.Template.Context.Tests
|
||||
import qualified Hakyll.Web.Template.Tests
|
||||
|
||||
|
@ -38,6 +39,7 @@ main = defaultMain
|
|||
, Hakyll.Core.Util.String.Tests.tests
|
||||
, Hakyll.Web.Html.RelativizeUrls.Tests.tests
|
||||
, Hakyll.Web.Html.Tests.tests
|
||||
, Hakyll.Web.Pandoc.FileType.Tests.tests
|
||||
, Hakyll.Web.Template.Context.Tests.tests
|
||||
, Hakyll.Web.Template.Tests.tests
|
||||
]
|
||||
|
|
Loading…
Reference in a new issue