diff options
Diffstat (limited to 'src/Text/Hakyll/CompressCSS.hs')
-rw-r--r-- | src/Text/Hakyll/CompressCSS.hs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/Text/Hakyll/CompressCSS.hs b/src/Text/Hakyll/CompressCSS.hs index b638654..5cb3b16 100644 --- a/src/Text/Hakyll/CompressCSS.hs +++ b/src/Text/Hakyll/CompressCSS.hs @@ -3,10 +3,21 @@ module Text.Hakyll.CompressCSS ) where import Data.List +import Text.Regex -- | Compress CSS to speed up your site. compressCSS :: String -> String -compressCSS = stripComments +compressCSS = compressSeparators + . compressWhitespace + . stripComments + +-- | Compresses certain forms of separators. +compressSeparators :: String -> String +compressSeparators str = subRegex (mkRegex "\\s*([;:])\\s*") str "\\1" + +-- | Compresses all whitespace. +compressWhitespace :: String -> String +compressWhitespace str = subRegex (mkRegex "\\s\\s*") str " " -- | Function that strips CSS comments away. stripComments :: String -> String |