on master help sign in
Some more CSS compression.
commit137bf6880558603fbbf918e2977b88231065b8a8 authorJasper Van der Jeugt <jaspervdj@gmail.com> dateSun 20 Dec 2009, 10:02 (17 years ago) parent5985951
1 file changed+7−2
src/Text/Hakyll/CompressCSS.hs+7−2
src/Text/Hakyll/CompressCSS.hs+7−2
@@ -5,6 +5,10 @@ module Text.Hakyll.CompressCSS
55import Data.List
66import Text.Regex
77
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+
812-- | Compress CSS to speed up your site.
913compressCSS :: String -> String
1014compressCSS = compressSeparators
@@ -13,11 +17,12 @@ compressCSS = compressSeparators
1317
1418-- | Compresses certain forms of separators.
1519compressSeparators :: String -> String
16−compressSeparators str = subRegex (mkRegex "\\s*([;:])\\s*") str "\\1"
20+compressSeparators = subRegex' ";\\s*}" "}"
21+ . subRegex' "\\s*([{};:])\\s*" "\\1"
1722
1823-- | Compresses all whitespace.
1924compressWhitespace :: String -> String
20−compressWhitespace str = subRegex (mkRegex "\\s\\s*") str " "
25+compressWhitespace = subRegex' "\\s\\s*" " "
2126
2227-- | Function that strips CSS comments away.
2328stripComments :: String -> String