From 6bbf514c77205b04c0b9ee38a0f6298e3e52e85a Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Thu, 17 Dec 2009 16:42:59 +0100 Subject: Added a stripHtml function. --- src/Text/Hakyll/Util.hs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src') 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 -- cgit v1.2.3