summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNicole Rauch <nicole.m@gmx.de>2016-08-14 20:08:47 +0200
committerNicole Rauch <nicole.m@gmx.de>2016-08-14 22:13:31 +0200
commitc32e55447793af259f8483f14c4a93bec882dc65 (patch)
treefb8218c3a703d685baeb1a6acd73b751b29d49da /src
parente4c7cb547d8c4754b4b54b82b4315740b7bff37c (diff)
downloadhakyll-c32e55447793af259f8483f14c4a93bec882dc65.tar.gz
Extracted a helper method because it was defined locally twice.
Diffstat (limited to 'src')
-rw-r--r--src/Hakyll/Web/CompressCss.hs19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/Hakyll/Web/CompressCss.hs b/src/Hakyll/Web/CompressCss.hs
index a032b10..21f3087 100644
--- a/src/Hakyll/Web/CompressCss.hs
+++ b/src/Hakyll/Web/CompressCss.hs
@@ -37,13 +37,12 @@ compressSeparators [] = []
compressSeparators str
| isPrefixOf "\"" str = head str : retainConstants compressSeparators "\"" (drop 1 str)
| isPrefixOf "'" str = head str : retainConstants compressSeparators "'" (drop 1 str)
- | stripFirst = compressSeparators (drop 1 str)
+ | stripFirst = compressSeparators (drop 1 str)
| stripSecond = compressSeparators (head str : (drop 2 str))
- | otherwise = head str : compressSeparators (drop 1 str)
+ | otherwise = head str : compressSeparators (drop 1 str)
where
- prefix p = isPrefixOf p str
- stripFirst = or $ map prefix [" ", " {", " }", ";;", ";}"]
- stripSecond = or $ map prefix ["{ ", "} ", "; "]
+ stripFirst = or $ map (isOfPrefix str) [" ", " {", " }", ";;", ";}"]
+ stripSecond = or $ map (isOfPrefix str) ["{ ", "} ", "; "]
--------------------------------------------------------------------------------
-- | Compresses all whitespace.
@@ -56,9 +55,8 @@ compressWhitespace str
| replaceTwo = compressWhitespace (' ' : (drop 2 str))
| otherwise = head str : compressWhitespace (drop 1 str)
where
- prefix p = isPrefixOf p str
- replaceOne = or $ map prefix ["\t", "\n", "\r"]
- replaceTwo = or $ map prefix [" \t", " \n", " \r", " "]
+ replaceOne = or $ map (isOfPrefix str) ["\t", "\n", "\r"]
+ replaceTwo = or $ map (isOfPrefix str) [" \t", " \n", " \r", " "]
--------------------------------------------------------------------------------
-- | Function that strips CSS comments away.
@@ -82,3 +80,8 @@ retainConstants f delim str
| null str = []
| isPrefixOf delim str = head str : f (drop 1 str)
| otherwise = head str : retainConstants f delim (drop 1 str)
+
+--------------------------------------------------------------------------------
+-- | Helper function to determine whether a string is a substring.
+isOfPrefix :: String -> String -> Bool
+isOfPrefix = flip isPrefixOf