diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Text/Hakyll/Util.hs | 11 |
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 |