1-- | Module used for CSS compression. The compression is currently in a simple
2-- state, but would typically reduce the number of bytes by about 25%.
3module Text.Hakyll.CompressCSS
7import Data.List (isPrefixOf)
9import Text.Hakyll.Regex (substituteRegex)
11-- | Compress CSS to speed up your site.
12compressCSS :: String -> String
13compressCSS = compressSeparators
17-- | Compresses certain forms of separators.
18compressSeparators :: String -> String
19compressSeparators = substituteRegex "; *}" "}"
20 . substituteRegex " *([{};:]) *" "\\1"
21 . substituteRegex ";;*" ";"
23-- | Compresses all whitespace.
24compressWhitespace :: String -> String
25compressWhitespace = substituteRegex "[ \t\n][ \t\n]*" " "
27-- | Function that strips CSS comments away.
28stripComments :: String -> String
31 | isPrefixOf "/*" str = stripComments $ eatComments $ drop 2 str
32 | otherwise = head str : stripComments (tail str)
34 eatComments str' | null str' = []
35 | isPrefixOf "*/" str' = drop 2 str'
36 | otherwise = eatComments $ tail str'
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list