on master help sign in
Worked on CompressCSS module.
c1d93ebJasper Van der Jeugt
hakyll.cabal+1−1
@@ -19,7 +19,7 @@ library
19 ghc-options: -Wall
19 ghc-options: -Wall
20 hs-source-dirs: src/
20 hs-source-dirs: src/
21 build-depends: base >= 4 && < 5, template, filepath, directory, containers, bytestring,
21 build-depends: base >= 4 && < 5, template, filepath, directory, containers, bytestring,
22− pandoc >= 1
22+ pandoc >= 1, regex-compat
23 exposed-modules: Text.Hakyll.Render
23 exposed-modules: Text.Hakyll.Render
24 Text.Hakyll.Renderable
24 Text.Hakyll.Renderable
25 Text.Hakyll.Renderables
25 Text.Hakyll.Renderables
src/Text/Hakyll/CompressCSS.hs+12−1
@@ -3,10 +3,21 @@ module Text.Hakyll.CompressCSS
3 ) where
3 ) where
4
4
5import Data.List
5import Data.List
6+import Text.Regex
6
7
7-- | Compress CSS to speed up your site.
8-- | Compress CSS to speed up your site.
8compressCSS :: String -> String
9compressCSS :: String -> String
10+compressCSS = compressSeparators
11+ . compressWhitespace
9−compressCSS = stripComments
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 " "
10
21
11-- | Function that strips CSS comments away.
22-- | Function that strips CSS comments away.
12stripComments :: String -> String
23stripComments :: String -> String