| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Text.Seonbi.Html.TextNormalizer
Synopsis
- escapeHtmlEntities :: Text -> Text
- normalizeCdata :: HtmlEntity -> HtmlEntity
- normalizeText :: [HtmlEntity] -> [HtmlEntity]
Documentation
escapeHtmlEntities :: Text -> Text Source #
Escape special (control) characters into corresponding character entities in the given HTML text.
>>>escapeHtmlEntities "<foo & \"bar\">""<foo & "bar">"
normalizeText :: [HtmlEntity] -> [HtmlEntity] Source #
As scanHtml may emit two or more continuous HtmlText fragments even
if these can be represented as only one HtmlText fragment, it makes
postprocessing hard.
The normalizeText function concatenates such continuous HtmlText
fragments into one if possible so that postprocessing can be easy:
>>>:set -XOverloadedStrings -XOverloadedLists>>>normalizeText [HtmlText [] "Hello, ", HtmlText [] "world!"][HtmlText {tagStack = fromList [], rawText = "Hello, world!"}]
It also transforms all HtmlCdata fragments into an HtmlText together.
>>>:{normalizeText [ HtmlText [] "foo " , HtmlCdata [] "<bar>", HtmlText [] " baz!" ] :} [HtmlText {tagStack = fromList [], rawText = "foo <bar> baz!"}]