mirror of
https://github.com/ilyakooo0/hakyll.git
synced 2024-10-06 09:17:15 +03:00
We need to constantly check whether we are at the start of a constant, not just once.
This commit is contained in:
parent
c0a86b3d7e
commit
0404185e83
@ -37,11 +37,17 @@ compressSeparators [] = []
|
||||
compressSeparators str
|
||||
| isPrefixOf "\"" str = head str : retainConstants compressSeparators "\"" (drop 1 str)
|
||||
| isPrefixOf "'" str = head str : retainConstants compressSeparators "'" (drop 1 str)
|
||||
| otherwise =
|
||||
replaceAll "; *}" (const "}") $
|
||||
replaceAll " *([{};]) *" (take 1 . dropWhile isSpace) $
|
||||
replaceAll ";+" (const ";") str
|
||||
where
|
||||
| isPrefixOf " " str = compressSeparators (drop 1 str)
|
||||
| isPrefixOf " {" str = compressSeparators (drop 1 str)
|
||||
| isPrefixOf " }" str = compressSeparators (drop 1 str)
|
||||
| isPrefixOf " ;" str = compressSeparators (drop 1 str)
|
||||
| isPrefixOf ";;" str = compressSeparators (drop 1 str)
|
||||
| isPrefixOf "{ " str = compressSeparators (head str : (drop 2 str))
|
||||
| isPrefixOf "} " str = compressSeparators (head str : (drop 2 str))
|
||||
| isPrefixOf "; " str = compressSeparators (head str : (drop 2 str))
|
||||
| isPrefixOf ";}" str = '}' : compressSeparators (drop 2 str)
|
||||
| otherwise = head str : compressSeparators (drop 1 str)
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- | Compresses all whitespace.
|
||||
|
@ -46,11 +46,13 @@ tests = testGroup "Hakyll.Web.CompressCss.Tests" $ concat
|
||||
compressCss "\" ' \""
|
||||
, "' \" '" @=?
|
||||
compressCss "' \" '"
|
||||
-- don't compress whitespace in constants in the middle of a string
|
||||
, "abc '{ '" @=?
|
||||
compressCss "abc '{ '"
|
||||
, "abc \"{ \"" @=?
|
||||
compressCss "abc \"{ \""
|
||||
-- compress multiple semicolons
|
||||
, ";" @=?
|
||||
compressCss ";;;;;;;"
|
||||
|
||||
-- some real-life css
|
||||
, "a:after{content: \" (\" attr(href) \")\"}" @=?
|
||||
compressCss "a:after { content: \" (\" attr(href) \")\"; }"
|
||||
]
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user