on master help sign in
Some more CSS compression.
137bf68Jasper Van der Jeugt
src/Text/Hakyll/CompressCSS.hs+7−2
@@ -5,6 +5,10 @@ module Text.Hakyll.CompressCSS
5import Data.List
5import Data.List
6import Text.Regex
6import Text.Regex
7
7
8+-- | subRegex with arguments flipped for easy function composition.
9+subRegex' :: String -> String -> String -> String
10+subRegex' pattern replacement str = subRegex (mkRegex pattern) str replacement
11+
8-- | Compress CSS to speed up your site.
12-- | Compress CSS to speed up your site.
9compressCSS :: String -> String
13compressCSS :: String -> String
10compressCSS = compressSeparators
14compressCSS = compressSeparators
@@ -13,11 +17,12 @@ compressCSS = compressSeparators
13
17
14-- | Compresses certain forms of separators.
18-- | Compresses certain forms of separators.
15compressSeparators :: String -> String
19compressSeparators :: String -> String
16−compressSeparators str = subRegex (mkRegex "\\s*([;:])\\s*") str "\\1"
20+compressSeparators = subRegex' ";\\s*}" "}"
21+ . subRegex' "\\s*([{};:])\\s*" "\\1"
17
22
18-- | Compresses all whitespace.
23-- | Compresses all whitespace.
19compressWhitespace :: String -> String
24compressWhitespace :: String -> String
20−compressWhitespace str = subRegex (mkRegex "\\s\\s*") str " "
25+compressWhitespace = subRegex' "\\s\\s*" " "
21
26
22-- | Function that strips CSS comments away.
27-- | Function that strips CSS comments away.
23stripComments :: String -> String
28stripComments :: String -> String