on master help sign in
Worked on CompressCSS module.
commitc1d93ebabfc03cf68ffabc7c2957c2c8935e4bc4 authorJasper Van der Jeugt <jaspervdj@gmail.com> dateFri 18 Dec 2009, 19:25 (17 years ago) parent01009d0
2 files changed+13−2
hakyll.cabal+1−1 src/Text/Hakyll/CompressCSS.hs+12−1
hakyll.cabal+1−1
@@ -19,7 +19,7 @@ library
1919 ghc-options: -Wall
2020 hs-source-dirs: src/
2121 build-depends: base >= 4 && < 5, template, filepath, directory, containers, bytestring,
22− pandoc >= 1
22+ pandoc >= 1, regex-compat
2323 exposed-modules: Text.Hakyll.Render
2424 Text.Hakyll.Renderable
2525 Text.Hakyll.Renderables
src/Text/Hakyll/CompressCSS.hs+12−1
@@ -3,10 +3,21 @@ module Text.Hakyll.CompressCSS
33 ) where
44
55import Data.List
6+import Text.Regex
67
78-- | Compress CSS to speed up your site.
89compressCSS :: String -> String
9−compressCSS = stripComments
10+compressCSS = compressSeparators
11+ . compressWhitespace
12+ . stripComments
13+
14+-- | Compresses certain forms of separators.
15+compressSeparators :: String -> String
16+compressSeparators str = subRegex (mkRegex "\\s*([;:])\\s*") str "\\1"
17+
18+-- | Compresses all whitespace.
19+compressWhitespace :: String -> String
20+compressWhitespace str = subRegex (mkRegex "\\s\\s*") str " "
1021
1122-- | Function that strips CSS comments away.
1223stripComments :: String -> String