summaryrefslogtreecommitdiff
path: root/src/Text/Hakyll
diff options
context:
space:
mode:
authorJasper Van der Jeugt <jaspervdj@gmail.com>2009-12-17 16:42:59 +0100
committerJasper Van der Jeugt <jaspervdj@gmail.com>2009-12-17 16:42:59 +0100
commit6bbf514c77205b04c0b9ee38a0f6298e3e52e85a (patch)
tree3ebc210eab4be50711f530c87a9b53db1eafcf89 /src/Text/Hakyll
parent57eadcf836963ec8f1c0ec47f859bad2183849e9 (diff)
downloadhakyll-6bbf514c77205b04c0b9ee38a0f6298e3e52e85a.tar.gz
Added a stripHtml function.
Diffstat (limited to 'src/Text/Hakyll')
-rw-r--r--src/Text/Hakyll/Util.hs11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/Text/Hakyll/Util.hs b/src/Text/Hakyll/Util.hs
index 83e7faf..35f7b33 100644
--- a/src/Text/Hakyll/Util.hs
+++ b/src/Text/Hakyll/Util.hs
@@ -6,6 +6,7 @@ module Text.Hakyll.Util
getRecursiveContents,
trim,
split,
+ stripHtml,
isCacheValid
) where
@@ -53,6 +54,16 @@ trim :: String -> String
trim = reverse . trim' . reverse . trim'
where trim' = dropWhile isSpace
+-- | Strip html tags.
+stripHtml :: String -> String
+stripHtml [] = []
+stripHtml str = let (beforeTag, rest) = break (== '<') str
+ (_, afterTag) = break (== '>') rest
+ in beforeTag ++ (stripHtml $ tail' afterTag)
+ -- We need a failsafe tail function.
+ where tail' [] = []
+ tail' xs = tail xs
+
-- | Split a list at a certain element.
split :: (Eq a) => a -> [a] -> [[a]]
split element = unfoldr splitOnce