module HTMLEntities.Text where import qualified Data.Text as Text import HTMLEntities.Prelude -- | -- HTML-encodes the given char. char :: Char -> Text char :: Char -> Text char = \case Char '<' -> Text "<" Char '>' -> Text ">" Char '&' -> Text "&" Char '"' -> Text """ Char '\'' -> Text "'" Char x -> Char -> Text Text.singleton Char x -- | -- HTML-encodes the given text. -- -- >>> Data.Text.IO.putStrLn $ text "<a href=\"\">" -- <a href=""> text :: Text -> Text text :: Text -> Text text = (Char -> Text) -> Text -> Text Text.concatMap Char -> Text char