diff options
author | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2009-12-17 16:42:59 +0100 |
---|---|---|
committer | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2009-12-17 16:42:59 +0100 |
commit | 6bbf514c77205b04c0b9ee38a0f6298e3e52e85a (patch) | |
tree | 3ebc210eab4be50711f530c87a9b53db1eafcf89 /src/Text/Hakyll | |
parent | 57eadcf836963ec8f1c0ec47f859bad2183849e9 (diff) | |
download | hakyll-6bbf514c77205b04c0b9ee38a0f6298e3e52e85a.tar.gz |
Added a stripHtml function.
Diffstat (limited to 'src/Text/Hakyll')
-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 |