summaryrefslogtreecommitdiff
path: root/src/Hakyll/Web/Util/Html.hs
diff options
context:
space:
mode:
authorJasper Van der Jeugt <jaspervdj@gmail.com>2011-06-05 23:07:00 +0200
committerJasper Van der Jeugt <jaspervdj@gmail.com>2011-06-05 23:07:00 +0200
commitcee7648fcf40580295ab30fa9ce676086a8c3028 (patch)
treea5fa4adf92bd9726876d513f4f34c2f067b17c95 /src/Hakyll/Web/Util/Html.hs
parent51f0bfc195aca8b911614fe3d84cb2551d722e3d (diff)
downloadhakyll-cee7648fcf40580295ab30fa9ce676086a8c3028.tar.gz
Add stripTags function
Diffstat (limited to 'src/Hakyll/Web/Util/Html.hs')
-rw-r--r--src/Hakyll/Web/Util/Html.hs30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/Hakyll/Web/Util/Html.hs b/src/Hakyll/Web/Util/Html.hs
new file mode 100644
index 0000000..5330cdd
--- /dev/null
+++ b/src/Hakyll/Web/Util/Html.hs
@@ -0,0 +1,30 @@
+-- | Miscellaneous HTML manipulation functions
+--
+module Hakyll.Web.Util.Html
+ ( stripTags
+ ) where
+
+-- | Strip all HTML tags from a string
+--
+-- Example:
+--
+-- > stripTags "<p>foo</p>"
+--
+-- Result:
+--
+-- > "foo"
+--
+-- This also works for incomplete tags
+--
+-- Example:
+--
+-- > stripTags "<p>foo</p"
+--
+-- Result:
+--
+-- > "foo"
+--
+stripTags :: String -> String
+stripTags [] = []
+stripTags ('<' : xs) = stripTags $ drop 1 $ dropWhile (/= '>') xs
+stripTags (x : xs) = x : stripTags xs