From 01009d0ce38cbad5130b5861ebd7ab8ac8603877 Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Fri, 18 Dec 2009 16:31:56 +0100 Subject: Started a CompressCss module. --- src/Text/Hakyll/CompressCSS.hs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/Text/Hakyll/CompressCSS.hs (limited to 'src/Text/Hakyll/CompressCSS.hs') 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' -- cgit v1.2.3