diff options
-rw-r--r-- | src/Text/Hakyll/Page.hs | 8 | ||||
-rw-r--r-- | tests/CompressCSS.hs | 35 | ||||
-rw-r--r-- | tests/CompressCss.hs | 35 | ||||
-rw-r--r-- | tests/Main.hs | 4 | ||||
-rw-r--r-- | tests/Util.hs | 28 |
5 files changed, 57 insertions, 53 deletions
diff --git a/src/Text/Hakyll/Page.hs b/src/Text/Hakyll/Page.hs index d2c73bd..54f9c84 100644 --- a/src/Text/Hakyll/Page.hs +++ b/src/Text/Hakyll/Page.hs @@ -58,14 +58,18 @@ getBody (Page page) = fromMaybe [] $ M.lookup "body" page -- | The default reader options for pandoc parsing. readerOptions :: ParserState -readerOptions = defaultParserState { stateSmart = True } +readerOptions = defaultParserState + { -- The following option causes pandoc to read smart typography, a nice + -- and free bonus. + stateSmart = True + } -- | The default writer options for pandoc rendering. writerOptions :: WriterOptions writerOptions = defaultWriterOptions { -- This option causes literate haskell to be written using '>' marks in -- html, which I think is a good default. - , writerLiterateHaskell = True + writerLiterateHaskell = True } -- | Get a render function for a given extension. diff --git a/tests/CompressCSS.hs b/tests/CompressCSS.hs deleted file mode 100644 index 855efcf..0000000 --- a/tests/CompressCSS.hs +++ /dev/null @@ -1,35 +0,0 @@ -module CompressCSS - ( compressCSSGroup - ) where - -import qualified Data.Map as M - -import Data.Binary -import Test.Framework (testGroup) -import Test.Framework.Providers.HUnit -import Test.Framework.Providers.QuickCheck2 -import Test.HUnit - -import Text.Hakyll.Internal.CompressCSS - --- CompressCSS test group. -compressCSSGroup = testGroup "CompressCSS" - [ testProperty "prop_compressCSS_length" prop_compressCSS_length - , testCase "test_compressCSS_1" test_compressCSS_1 - , testCase "test_compressCSS_2" test_compressCSS_2 - , testCase "test_compressCSS_3" test_compressCSS_3 - , testCase "test_compressCSS_4" test_compressCSS_4 - ] - --- CSS compression should always decrease the text length. -prop_compressCSS_length str = length str >= length (compressCSS str) - --- Compress CSS test cases. -test_compressCSS_1 = compressCSS "a { \n color : red; }" @?= "a{color:red}" -test_compressCSS_2 = compressCSS "img {border :none;;;; }" - @?= "img{border:none}" -test_compressCSS_3 = - compressCSS "p {font-size : 90%;} h1 {color :white;;; }" - @?= "p{font-size:90%}h1{color:white}" -test_compressCSS_4 = compressCSS "a { /* /* red is pretty cool */ color: red; }" - @?= "a{color:red}" diff --git a/tests/CompressCss.hs b/tests/CompressCss.hs new file mode 100644 index 0000000..38b9b28 --- /dev/null +++ b/tests/CompressCss.hs @@ -0,0 +1,35 @@ +module CompressCss + ( compressCssGroup + ) where + +import qualified Data.Map as M + +import Data.Binary +import Test.Framework (testGroup) +import Test.Framework.Providers.HUnit +import Test.Framework.Providers.QuickCheck2 +import Test.HUnit + +import Text.Hakyll.Internal.CompressCss + +-- CompressCss test group. +compressCssGroup = testGroup "CompressCss" + [ testProperty "prop_compressCss_length" prop_compressCss_length + , testCase "test_compressCss_1" test_compressCss_1 + , testCase "test_compressCss_2" test_compressCss_2 + , testCase "test_compressCss_3" test_compressCss_3 + , testCase "test_compressCss_4" test_compressCss_4 + ] + +-- Css compression should always decrease the text length. +prop_compressCss_length str = length str >= length (compressCss str) + +-- Compress Css test cases. +test_compressCss_1 = compressCss "a { \n color : red; }" @?= "a{color:red}" +test_compressCss_2 = compressCss "img {border :none;;;; }" + @?= "img{border:none}" +test_compressCss_3 = + compressCss "p {font-size : 90%;} h1 {color :white;;; }" + @?= "p{font-size:90%}h1{color:white}" +test_compressCss_4 = compressCss "a { /* /* red is pretty cool */ color: red; }" + @?= "a{color:red}" diff --git a/tests/Main.hs b/tests/Main.hs index 9022dda..a2fc8e5 100644 --- a/tests/Main.hs +++ b/tests/Main.hs @@ -4,7 +4,7 @@ import Test.Framework (defaultMain, testGroup) import Test.Framework.Providers.HUnit import Test.Framework.Providers.QuickCheck2 -import CompressCSS +import CompressCss import Context import File import Page @@ -12,7 +12,7 @@ import Regex import Template import Util -main = defaultMain [ compressCSSGroup +main = defaultMain [ compressCssGroup , contextGroup , fileGroup , pageGroup diff --git a/tests/Util.hs b/tests/Util.hs index 1369ada..4b29f5f 100644 --- a/tests/Util.hs +++ b/tests/Util.hs @@ -16,11 +16,11 @@ import Text.Hakyll.Util utilGroup = testGroup "Util" [ testProperty "prop_trim_length" prop_trim_length , testProperty "prop_trim_id" prop_trim_id - , testProperty "prop_stripHTML_length" prop_stripHTML_length - , testProperty "prop_stripHTML_id" prop_stripHTML_id - , testCase "test_stripHTML_1" test_stripHTML_1 - , testCase "test_stripHTML_2" test_stripHTML_2 - , testCase "test_stripHTML_3" test_stripHTML_3 + , testProperty "prop_stripHtml_length" prop_stripHtml_length + , testProperty "prop_stripHtml_id" prop_stripHtml_id + , testCase "test_stripHtml_1" test_stripHtml_1 + , testCase "test_stripHtml_2" test_stripHtml_2 + , testCase "test_stripHtml_3" test_stripHtml_3 , testCase "test_link_1" test_link_1 , testCase "test_link_2" test_link_2 ] @@ -35,17 +35,17 @@ prop_trim_id str = (not $ null str) && isAlreadyTrimmed ==> str == (trim str) isAlreadyTrimmed = (not $ isSpace $ head str) && (not $ isSpace $ last str) -- Check that a stripped string is shorter. -prop_stripHTML_length str = length str >= length (stripHTML str) +prop_stripHtml_length str = length str >= length (stripHtml str) -- Check that strings without tags remain untouched. -prop_stripHTML_id str = (not $ any (`elem` ['>', '<']) str) - ==> str == stripHTML str - --- Strip HTML test cases. -test_stripHTML_1 = stripHTML "<b>text</b>" @?= "text" -test_stripHTML_2 = stripHTML "text" @?= "text" -test_stripHTML_3 = - stripHTML "<b>Hakyll</b>, a <i>website</i> generator<img src=\"foo.png\" />" +prop_stripHtml_id str = (not $ any (`elem` ['>', '<']) str) + ==> str == stripHtml str + +-- Strip Html test cases. +test_stripHtml_1 = stripHtml "<b>text</b>" @?= "text" +test_stripHtml_2 = stripHtml "text" @?= "text" +test_stripHtml_3 = + stripHtml "<b>Hakyll</b>, a <i>website</i> generator<img src=\"foo.png\" />" @?= "Hakyll, a website generator" -- Link test cases. |