on master help sign in
Added a stripHtml function.
commit6bbf514c77205b04c0b9ee38a0f6298e3e52e85a authorJasper Van der Jeugt <jaspervdj@gmail.com> dateThu 17 Dec 2009, 16:42 (17 years ago) parent57eadcf
1 file changed+11
src/Text/Hakyll/Util.hs+11
src/Text/Hakyll/Util.hs+11
@@ -6,6 +6,7 @@ module Text.Hakyll.Util
66 getRecursiveContents,
77 trim,
88 split,
9+ stripHtml,
910 isCacheValid
1011 ) where
1112
@@ -53,6 +54,16 @@ trim :: String -> String
5354trim = reverse . trim' . reverse . trim'
5455 where trim' = dropWhile isSpace
5556
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+
5667-- | Split a list at a certain element.
5768split :: (Eq a) => a -> [a] -> [[a]]
5869split element = unfoldr splitOnce