Improved the compaction a bit more.

This commit is contained in:
Nicole Rauch 2016-08-14 19:37:29 +02:00
parent ec1486c4ba
commit 8f11bbd1d7
2 changed files with 3 additions and 2 deletions

View File

@ -39,11 +39,10 @@ compressSeparators str
| isPrefixOf "'" str = head str : retainConstants compressSeparators "'" (drop 1 str)
| stripFirst = compressSeparators (drop 1 str)
| stripSecond = compressSeparators (head str : (drop 2 str))
| isPrefixOf ";}" str = '}' : compressSeparators (drop 2 str)
| otherwise = head str : compressSeparators (drop 1 str)
where
prefix p = isPrefixOf p str
stripFirst = or $ map prefix [" ", " {", " }", ";;"]
stripFirst = or $ map prefix [" ", " {", " }", ";;", ";}"]
stripSecond = or $ map prefix ["{ ", "} ", "; "]
--------------------------------------------------------------------------------

View File

@ -30,6 +30,8 @@ tests = testGroup "Hakyll.Web.CompressCss.Tests" $ concat
-- compress separators
, "}" @=? compressCss "; }"
, "{};" @=? compressCss " { } ; "
-- compress whitespace even after this curly brace
, "}" @=? compressCss "; } "
-- but do not compress separators inside of constants
, "\" { } ; \"" @=? compressCss "\" { } ; \""
-- don't compress separators at the start or end of constants