diff options
author | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2010-01-09 21:40:31 +0100 |
---|---|---|
committer | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2010-01-09 21:40:31 +0100 |
commit | 73f6b1ab8cf3cb9468c547db6df1df9596f1470d (patch) | |
tree | 1d8b7205cc88388573c50798dd6e16effeb39ece /src/Text/Hakyll/CompressCSS.hs | |
parent | cb3e3b119313145b5b79d46d2c40390ce9d9a51b (diff) | |
download | hakyll-73f6b1ab8cf3cb9468c547db6df1df9596f1470d.tar.gz |
Some changes to the regex interface, and version bump.
Diffstat (limited to 'src/Text/Hakyll/CompressCSS.hs')
-rw-r--r-- | src/Text/Hakyll/CompressCSS.hs | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/src/Text/Hakyll/CompressCSS.hs b/src/Text/Hakyll/CompressCSS.hs index 8745368..85c061d 100644 --- a/src/Text/Hakyll/CompressCSS.hs +++ b/src/Text/Hakyll/CompressCSS.hs @@ -3,27 +3,23 @@ module Text.Hakyll.CompressCSS ) where import Data.List (isPrefixOf) -import Text.Regex (subRegex, mkRegex) - --- | subRegex with arguments flipped for easy function composition. -subRegex' :: String -> String -> String -> String -subRegex' pattern replacement str = subRegex (mkRegex pattern) str replacement +import Text.Hakyll.Regex (substitute) -- | Compress CSS to speed up your site. compressCSS :: String -> String compressCSS = compressSeparators - . compressWhitespace . stripComments + . compressWhitespace -- | Compresses certain forms of separators. compressSeparators :: String -> String -compressSeparators = subRegex' ";\\s*}" "}" - . subRegex' "\\s*([{};:])\\s*" "\\1" - . subRegex' ";;*" ";" +compressSeparators = substitute "; *}" "}" + . substitute " *([{};:]) *" "\\1" + . substitute ";;*" ";" -- | Compresses all whitespace. compressWhitespace :: String -> String -compressWhitespace = subRegex' "\\s\\s*" " " +compressWhitespace = substitute "[ \t\n][ \t\n]*" " " -- | Function that strips CSS comments away. stripComments :: String -> String |