on master help sign in
Do not strip comments that are inside constants.
e4c7cb5Nicole Rauch
src/Hakyll/Web/CompressCss.hs+2
@@ -65,6 +65,8 @@ compressWhitespace str
65stripComments :: String -> String
65stripComments :: String -> String
66stripComments [] = []
66stripComments [] = []
67stripComments str
67stripComments str
68+ | isPrefixOf "\"" str = head str : retainConstants stripComments "\"" (drop 1 str)
69+ | isPrefixOf "'" str = head str : retainConstants stripComments "'" (drop 1 str)
68 | isPrefixOf "/*" str = stripComments $ eatComments $ drop 2 str
70 | isPrefixOf "/*" str = stripComments $ eatComments $ drop 2 str
69 | otherwise = head str : stripComments (drop 1 str)
71 | otherwise = head str : stripComments (drop 1 str)
70 where
72 where
tests/Hakyll/Web/CompressCss/Tests.hs+4−1
@@ -30,7 +30,10 @@ tests = testGroup "Hakyll.Web.CompressCss.Tests" $ concat
30 compressCss "abc ' \t\n\r ' xyz"
30 compressCss "abc ' \t\n\r ' xyz"
31
31
32 -- strip comments
32 -- strip comments
33+ , "before after" @=? compressCss "before /* abc { } ;; \n\t\r */ after"
34+ -- don't strip comments inside constants
35+ , "before \"/* abc { } ;; \n\t\r */\" after"
33− , "" @=? compressCss "/* abc { } ;; \n\t\r */"
36+ @=? compressCss "before \"/* abc { } ;; \n\t\r */\" after"
34
37
35 -- compress separators
38 -- compress separators
36 , "}" @=? compressCss "; }"
39 , "}" @=? compressCss "; }"