diff options
author | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2009-12-20 10:02:20 +0100 |
---|---|---|
committer | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2009-12-20 10:02:20 +0100 |
commit | 137bf6880558603fbbf918e2977b88231065b8a8 (patch) | |
tree | f0d9a99f3899d148004c031a67cf0f1eaf2f7c36 /src/Text/Hakyll | |
parent | 5985951bed75216b0fa923ee7339ea92ccc9bd8e (diff) | |
download | hakyll-137bf6880558603fbbf918e2977b88231065b8a8.tar.gz |
Some more CSS compression.
Diffstat (limited to 'src/Text/Hakyll')
-rw-r--r-- | src/Text/Hakyll/CompressCSS.hs | 9 |
1 files changed, 7 insertions, 2 deletions
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 |