 |
-- A decoder of a text with entities.
-- 
-- Produces a text builder, 
-- which you can then convert into a text or a lazy text,
-- using the <http://hackage.haskell.org/package/text "text"> or 
-- <http://hackage.haskell.org/package/conversion-text "conversion-text"> library.
-- 
-- >>> Data.Text.Lazy.IO.putStrLn $ Data.Text.Lazy.Builder.toLazyText $ htmlEncodedText "&euro;5 &cent;2"
-- €5 ¢2
htmlEncodedText :: Text -> TLB.Builder
htmlEncodedText =
  fmap (either (error "HTMLEntities.Decoder: impossible happened") id) $
  P.parseOnly $
  fmap fold $
  many $
  fmap TLB.fromText P.htmlEntity <|> fmap TLB.singleton P.anyChar


htmlEncodedText :: Text -> TLB.Builder
htmlEncodedText =
  fmap (either (error "HTMLEntities.Decoder: impossible happened") id) $
  P.parseOnly $
  fmap fold $
  many $
  fmap TLB.fromText P.htmlEntity <|> fmap TLB.singleton P.anyChar
htmlEncodedText =
  fmap (either (error "HTMLEntities.Decoder: impossible happened") id) $
  P.parseOnly $
  fmap fold $
  many $
  fmap TLB.fromText P.htmlEntity <|> fmap TLB.singleton P.anyChar