@@ -2,8 +2,12 @@
22--
33module Hakyll.Web.Util.Html
44 ( stripTags
5+ , escapeHtml
56 ) where
67
8+import Text.Blaze (toHtml)
9+import Text.Blaze.Renderer.String (renderHtml)
10+
711-- | Strip all HTML tags from a string
812--
913-- Example:
@@ -28,3 +32,16 @@ stripTags :: String -> String
2832stripTags [] = []
2933stripTags ('<' : xs) = stripTags $ drop 1 $ dropWhile (/= '>') xs
3034stripTags (x : xs) = x : stripTags xs
35+
36+-- | HTML-escape a string
37+--
38+-- Example:
39+--
40+-- > escapeHtml "Me & Dean"
41+--
42+-- Result:
43+--
44+-- > "Me & Dean"
45+--
46+escapeHtml :: String -> String
47+escapeHtml = renderHtml . toHtml