@@ -3,10 +3,21 @@ module Text.Hakyll.CompressCSS
33 ) where
44
55import Data.List
6+import Text.Regex
67
78-- | Compress CSS to speed up your site.
89compressCSS :: String -> String
9−compressCSS = stripComments
10+compressCSS = compressSeparators
11+ . compressWhitespace
12+ . stripComments
13+
14+-- | Compresses certain forms of separators.
15+compressSeparators :: String -> String
16+compressSeparators str = subRegex (mkRegex "\\s*([;:])\\s*") str "\\1"
17+
18+-- | Compresses all whitespace.
19+compressWhitespace :: String -> String
20+compressWhitespace str = subRegex (mkRegex "\\s\\s*") str " "
1021
1122-- | Function that strips CSS comments away.
1223stripComments :: String -> String