on master help sign in
Compacted the code by unifying all the similar prefix options.
commitec1486c4ba18452da4a5948477c1f8fe02c46d8f authorNicole Rauch <nicole.m@gmx.de> dateSun 14 Aug 2016, 19:35 (10 years ago) parentc6fdffc
1 file changed+6−9
src/Hakyll/Web/CompressCss.hs+6−9
src/Hakyll/Web/CompressCss.hs+6−9
@@ -37,17 +37,14 @@ compressSeparators [] = []
3737compressSeparators str
3838 | isPrefixOf "\"" str = head str : retainConstants compressSeparators "\"" (drop 1 str)
3939 | isPrefixOf "'" str = head str : retainConstants compressSeparators "'" (drop 1 str)
40− | isPrefixOf " " str = compressSeparators (drop 1 str)
41− | isPrefixOf " {" str = compressSeparators (drop 1 str)
42− | isPrefixOf " }" str = compressSeparators (drop 1 str)
43− | isPrefixOf " ;" str = compressSeparators (drop 1 str)
44− | isPrefixOf ";;" str = compressSeparators (drop 1 str)
45− | isPrefixOf "{ " str = compressSeparators (head str : (drop 2 str))
46− | isPrefixOf "} " str = compressSeparators (head str : (drop 2 str))
47− | isPrefixOf "; " str = compressSeparators (head str : (drop 2 str))
40+ | stripFirst = compressSeparators (drop 1 str)
41+ | stripSecond = compressSeparators (head str : (drop 2 str))
4842 | isPrefixOf ";}" str = '}' : compressSeparators (drop 2 str)
4943 | otherwise = head str : compressSeparators (drop 1 str)
50−
44+ where
45+ prefix p = isPrefixOf p str
46+ stripFirst = or $ map prefix [" ", " {", " }", ";;"]
47+ stripSecond = or $ map prefix ["{ ", "} ", "; "]
5148
5249--------------------------------------------------------------------------------
5350-- | Compresses all whitespace.