diff options
author | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2009-12-18 19:25:28 +0100 |
---|---|---|
committer | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2009-12-18 19:25:28 +0100 |
commit | c1d93ebabfc03cf68ffabc7c2957c2c8935e4bc4 (patch) | |
tree | 1440f775b3a1681bc52c7f19c0b7da095173714b | |
parent | 01009d0ce38cbad5130b5861ebd7ab8ac8603877 (diff) | |
download | hakyll-c1d93ebabfc03cf68ffabc7c2957c2c8935e4bc4.tar.gz |
Worked on CompressCSS module.
-rw-r--r-- | hakyll.cabal | 2 | ||||
-rw-r--r-- | src/Text/Hakyll/CompressCSS.hs | 13 |
2 files changed, 13 insertions, 2 deletions
diff --git a/hakyll.cabal b/hakyll.cabal index 171c7ce..3312dc7 100644 --- a/hakyll.cabal +++ b/hakyll.cabal @@ -19,7 +19,7 @@ library ghc-options: -Wall hs-source-dirs: src/ build-depends: base >= 4 && < 5, template, filepath, directory, containers, bytestring, - pandoc >= 1 + pandoc >= 1, regex-compat exposed-modules: Text.Hakyll.Render Text.Hakyll.Renderable Text.Hakyll.Renderables 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 |