summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hakyll.cabal2
-rw-r--r--src/Text/Hakyll/CompressCSS.hs18
2 files changed, 20 insertions, 0 deletions
diff --git a/hakyll.cabal b/hakyll.cabal
index 97b7807..171c7ce 100644
--- a/hakyll.cabal
+++ b/hakyll.cabal
@@ -23,5 +23,7 @@ library
exposed-modules: Text.Hakyll.Render
Text.Hakyll.Renderable
Text.Hakyll.Renderables
+ Text.Hakyll.CompressCSS
+ Text.Hakyll.File
Text.Hakyll.Page
Text.Hakyll.Util
diff --git a/src/Text/Hakyll/CompressCSS.hs b/src/Text/Hakyll/CompressCSS.hs
new file mode 100644
index 0000000..b638654
--- /dev/null
+++ b/src/Text/Hakyll/CompressCSS.hs
@@ -0,0 +1,18 @@
+module Text.Hakyll.CompressCSS
+ ( compressCSS
+ ) where
+
+import Data.List
+
+-- | Compress CSS to speed up your site.
+compressCSS :: String -> String
+compressCSS = stripComments
+
+-- | Function that strips CSS comments away.
+stripComments :: String -> String
+stripComments [] = []
+stripComments str | isPrefixOf "/*" str = stripComments $ eatComments $ drop 2 str
+ | otherwise = (head str) : (stripComments $ tail str)
+ where eatComments str' | null str' = []
+ | isPrefixOf "*/" str' = drop 2 str'
+ | otherwise = eatComments $ tail str'