summaryrefslogtreecommitdiff
path: root/src/Text/Hakyll/CompressCSS.hs
blob: b63865472a24350ea48bbdd3a64988eb8c0bc716 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
module Text.Hakyll.CompressCSS
    ( compressCSS
    ) where

import Data.List

-- | Compress CSS to speed up your site.
compressCSS :: String -> String
compressCSS = stripComments

-- | Function that strips CSS comments away.
stripComments :: String -> String
stripComments [] = []
stripComments str | isPrefixOf "/*" str = stripComments $ eatComments $ drop 2 str
                  | otherwise = (head str) : (stripComments $ tail str)
    where eatComments str' | null str' = []
                           | isPrefixOf "*/" str' = drop 2 str'
                           | otherwise = eatComments $ tail str'