on master help sign in
Do not strip comments that are inside constants.
commite4c7cb547d8c4754b4b54b82b4315740b7bff37c authorNicole Rauch <nicole.m@gmx.de> dateSun 14 Aug 2016, 20:00 (10 years ago) parentce97307
2 files changed+6−1
src/Hakyll/Web/CompressCss.hs+2 tests/Hakyll/Web/CompressCss/Tests.hs+4−1
src/Hakyll/Web/CompressCss.hs+2
@@ -65,6 +65,8 @@ compressWhitespace str
6565stripComments :: String -> String
6666stripComments [] = []
6767stripComments str
68+ | isPrefixOf "\"" str = head str : retainConstants stripComments "\"" (drop 1 str)
69+ | isPrefixOf "'" str = head str : retainConstants stripComments "'" (drop 1 str)
6870 | isPrefixOf "/*" str = stripComments $ eatComments $ drop 2 str
6971 | otherwise = head str : stripComments (drop 1 str)
7072 where
tests/Hakyll/Web/CompressCss/Tests.hs+4−1
@@ -30,7 +30,10 @@ tests = testGroup "Hakyll.Web.CompressCss.Tests" $ concat
3030 compressCss "abc ' \t\n\r ' xyz"
3131
3232 -- strip comments
33− , "" @=? compressCss "/* abc { } ;; \n\t\r */"
33+ , "before after" @=? compressCss "before /* abc { } ;; \n\t\r */ after"
34+ -- don't strip comments inside constants
35+ , "before \"/* abc { } ;; \n\t\r */\" after"
36+ @=? compressCss "before \"/* abc { } ;; \n\t\r */\" after"
3437
3538 -- compress separators
3639 , "}" @=? compressCss "; }"