1module Text.Hakyll.CompressCSS
5import Data.List (isPrefixOf)
6import Text.Regex (subRegex, mkRegex)
8-- | subRegex with arguments flipped for easy function composition.
9subRegex' :: String -> String -> String -> String
10subRegex' pattern replacement str = subRegex (mkRegex pattern) str replacement
12-- | Compress CSS to speed up your site.
13compressCSS :: String -> String
14compressCSS = compressSeparators
18-- | Compresses certain forms of separators.
19compressSeparators :: String -> String
20compressSeparators = subRegex' ";\\s*}" "}"
21 . subRegex' "\\s*([{};:])\\s*" "\\1"
24-- | Compresses all whitespace.
25compressWhitespace :: String -> String
26compressWhitespace = subRegex' "\\s\\s*" " "
28-- | Function that strips CSS comments away.
29stripComments :: String -> String
31stripComments str | isPrefixOf "/*" str = stripComments $ eatComments $ drop 2 str
32 | otherwise = (head str) : (stripComments $ tail str)
33 where eatComments str' | null str' = []
34 | isPrefixOf "*/" str' = drop 2 str'
35 | 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