diff options
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 |