@@ -33,14 +33,15 @@ compressCss = compressSeparators . stripComments . compressWhitespace
33compressSeparators :: String -> String
33compressSeparators :: String -> String
34compressSeparators [] = []
34compressSeparators [] = []
35compressSeparators str
35compressSeparators str
36− | isConstant = head str : retainConstants compressSeparators (head str) (drop 1 str)
36+ | isConstant = head str : retainConstants compressSeparators (head str) (drop 1 str)
37 | stripFirst = compressSeparators (drop 1 str)
37 | stripFirst = compressSeparators (drop 1 str)
38 | stripSecond = compressSeparators (head str : (drop 2 str))
38 | stripSecond = compressSeparators (head str : (drop 2 str))
39 | otherwise = head str : compressSeparators (drop 1 str)
39 | otherwise = head str : compressSeparators (drop 1 str)
41 isConstant = or $ map (isOfPrefix str) ["\"", "'"]
41 isConstant = or $ map (isOfPrefix str) ["\"", "'"]
42− stripFirst = or $ map (isOfPrefix str) [" ", " {", " }", " :", ";;", ";}"]
42+ stripFirst = or $ map (isOfPrefix str) $ [";;", ";}"] ++ (map (\c -> " " ++ c) separators)
43− stripSecond = or $ map (isOfPrefix str) ["{ ", "} ", ": ", "; "]
43+ stripSecond = or $ map (isOfPrefix str) $ map (\c -> c ++ " ") separators
44+ separators = [" ", "{", "}", ":", ";", ",", ">", "+", "!"]
45--------------------------------------------------------------------------------
46--------------------------------------------------------------------------------
46-- | Compresses all whitespace.
47-- | Compresses all whitespace.
@@ -50,7 +51,7 @@ compressWhitespace str
50 | isConstant = head str : retainConstants compressWhitespace (head str) (drop 1 str)
51 | isConstant = head str : retainConstants compressWhitespace (head str) (drop 1 str)
51 | replaceOne = compressWhitespace (' ' : (drop 1 str))
52 | replaceOne = compressWhitespace (' ' : (drop 1 str))
52 | replaceTwo = compressWhitespace (' ' : (drop 2 str))
53 | replaceTwo = compressWhitespace (' ' : (drop 2 str))
53− | otherwise = head str : compressWhitespace (drop 1 str)
54+ | otherwise = head str : compressWhitespace (drop 1 str)
55 isConstant = or $ map (isOfPrefix str) ["\"", "'"]
56 isConstant = or $ map (isOfPrefix str) ["\"", "'"]
56 replaceOne = or $ map (isOfPrefix str) ["\t", "\n", "\r"]
57 replaceOne = or $ map (isOfPrefix str) ["\t", "\n", "\r"]
@@ -61,9 +62,9 @@ compressWhitespace str
61stripComments :: String -> String
62stripComments :: String -> String
62stripComments [] = []
63stripComments [] = []
63stripComments str
64stripComments str
64− | isConstant = head str : retainConstants stripComments (head str) (drop 1 str)
65+ | isConstant = head str : retainConstants stripComments (head str) (drop 1 str)
65 | isPrefixOf "/*" str = stripComments $ eatComments $ drop 2 str
66 | isPrefixOf "/*" str = stripComments $ eatComments $ drop 2 str
66− | otherwise = head str : stripComments (drop 1 str)
67+ | otherwise = head str : stripComments (drop 1 str)
68 isConstant = or $ map (isOfPrefix str) ["\"", "'"]
69 isConstant = or $ map (isOfPrefix str) ["\"", "'"]
69 eatComments str'
70 eatComments str'