on master help sign in
Started a CompressCss module.
commit01009d0ce38cbad5130b5861ebd7ab8ac8603877 authorJasper Van der Jeugt <jaspervdj@gmail.com> dateFri 18 Dec 2009, 16:31 (17 years ago) parent221c029
2 files changed+20
hakyll.cabal+2 src/Text/Hakyll/CompressCSS.hs+18
hakyll.cabal+2
@@ -23,5 +23,7 @@ library
2323 exposed-modules: Text.Hakyll.Render
2424 Text.Hakyll.Renderable
2525 Text.Hakyll.Renderables
26+ Text.Hakyll.CompressCSS
27+ Text.Hakyll.File
2628 Text.Hakyll.Page
2729 Text.Hakyll.Util
src/Text/Hakyll/CompressCSS.hsnew file+18
@@ -0,0 +1,18 @@
1+module Text.Hakyll.CompressCSS
2+ ( compressCSS
3+ ) where
4+
5+import Data.List
6+
7+-- | Compress CSS to speed up your site.
8+compressCSS :: String -> String
9+compressCSS = stripComments
10+
11+-- | Function that strips CSS comments away.
12+stripComments :: String -> String
13+stripComments [] = []
14+stripComments str | isPrefixOf "/*" str = stripComments $ eatComments $ drop 2 str
15+ | otherwise = (head str) : (stripComments $ tail str)
16+ where eatComments str' | null str' = []
17+ | isPrefixOf "*/" str' = drop 2 str'
18+ | otherwise = eatComments $ tail str'