on master help sign in
Added a stripHtml function.
6bbf514Jasper Van der Jeugt
src/Text/Hakyll/Util.hs+11
@@ -6,6 +6,7 @@ module Text.Hakyll.Util
6 getRecursiveContents,
6 getRecursiveContents,
7 trim,
7 trim,
8 split,
8 split,
9+ stripHtml,
9 isCacheValid
10 isCacheValid
10 ) where
11 ) where
11
12
@@ -53,6 +54,16 @@ trim :: String -> String
53trim = reverse . trim' . reverse . trim'
54trim = reverse . trim' . reverse . trim'
54 where trim' = dropWhile isSpace
55 where trim' = dropWhile isSpace
55
56
57+-- | Strip html tags.
58+stripHtml :: String -> String
59+stripHtml [] = []
60+stripHtml str = let (beforeTag, rest) = break (== '<') str
61+ (_, afterTag) = break (== '>') rest
62+ in beforeTag ++ (stripHtml $ tail' afterTag)
63+ -- We need a failsafe tail function.
64+ where tail' [] = []
65+ tail' xs = tail xs
66+
56-- | Split a list at a certain element.
67-- | Split a list at a certain element.
57split :: (Eq a) => a -> [a] -> [[a]]
68split :: (Eq a) => a -> [a] -> [[a]]
58split element = unfoldr splitOnce
69split element = unfoldr splitOnce