diff options
Diffstat (limited to 'src/Text/Hakyll')
-rw-r--r-- | src/Text/Hakyll/CompressCSS.hs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/Text/Hakyll/CompressCSS.hs b/src/Text/Hakyll/CompressCSS.hs new file mode 100644 index 0000000..b638654 --- /dev/null +++ b/src/Text/Hakyll/CompressCSS.hs @@ -0,0 +1,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' |