I built the following function with functions from the tagsoup package. It processes all named and numerical objects from the HTML5 standard (more than 2000, see the List ).
import qualified Text.HTML.TagSoup as TS decodeHTMLentities :: (StringLike str, Show str) => str -> str decodeHTMLentities s = TS.fromTagText $ head $ TS.parseTags s
StringLike has instances for String , Lazy and Strict ByteString and Text .
Unknown rights will not be saved. If you want a warning about unknown objects to use:
> parseTagsOptions parseOptions{optTagWarning=True} "&asdasd;" [TagText "&asdasd;",TagWarning "Unknown entity: asdasd"]
source share