From 137bf6880558603fbbf918e2977b88231065b8a8 Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Sun, 20 Dec 2009 10:02:20 +0100 Subject: Some more CSS compression. --- src/Text/Hakyll/CompressCSS.hs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/Text/Hakyll/CompressCSS.hs') diff --git a/src/Text/Hakyll/CompressCSS.hs b/src/Text/Hakyll/CompressCSS.hs index 5cb3b16..7f3ddc3 100644 --- a/src/Text/Hakyll/CompressCSS.hs +++ b/src/Text/Hakyll/CompressCSS.hs @@ -5,6 +5,10 @@ module Text.Hakyll.CompressCSS import Data.List import Text.Regex +-- | subRegex with arguments flipped for easy function composition. +subRegex' :: String -> String -> String -> String +subRegex' pattern replacement str = subRegex (mkRegex pattern) str replacement + -- | Compress CSS to speed up your site. compressCSS :: String -> String compressCSS = compressSeparators @@ -13,11 +17,12 @@ compressCSS = compressSeparators -- | Compresses certain forms of separators. compressSeparators :: String -> String -compressSeparators str = subRegex (mkRegex "\\s*([;:])\\s*") str "\\1" +compressSeparators = subRegex' ";\\s*}" "}" + . subRegex' "\\s*([{};:])\\s*" "\\1" -- | Compresses all whitespace. compressWhitespace :: String -> String -compressWhitespace str = subRegex (mkRegex "\\s\\s*") str " " +compressWhitespace = subRegex' "\\s\\s*" " " -- | Function that strips CSS comments away. stripComments :: String -> String -- cgit v1.2.3