Worked on CompressCSS module.
This commit is contained in:
parent
01009d0ce3
commit
c1d93ebabf
2 changed files with 13 additions and 2 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue