Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- printHtml :: [HtmlEntity] -> Text
- printText :: [HtmlEntity] -> Text
- printXhtml :: [HtmlEntity] -> Text
Documentation
printHtml :: [HtmlEntity] -> Text Source #
Print the list of HtmlEntity
into a lazy Text
.
>>>
let Done "" tokens = scanHtml "<p>Hello,<br>\n<em>world</em>!</p>"
>>>
printHtml tokens
"<p>Hello,<br>\n<em>world</em>!</p>"
printText :: [HtmlEntity] -> Text Source #
Print only the text contents (including CDATA sections) without tags
into a lazy Text
.
>>>
let Done "" tokens = scanHtml "<p>Hello,<br>\n<em>world</em>!</p>"
>>>
printText tokens
"Hello,\nworld!"
Entities are decoded:
>>>
let Done "" tokens = scanHtml "<p><code><>"&</code></p>"
>>>
printText tokens
"<>\"&"
printXhtml :: [HtmlEntity] -> Text Source #
Similar to printHtml
except it renders void (self-closing) tags as
like br/
instead of br
.
>>>
let Done "" tokens = scanHtml "<p>Hello,<br>\n<em>world</em>!</p>"
>>>
printXhtml tokens
"<p>Hello,<br/>\n<em>world</em>!</p>"
Note that normal tags are not rendered as self-closed; only void tags according to HTML specification are:
>>>
let Done "" tokens' = scanHtml "<p></p><p><br></p>"
>>>
printXhtml tokens'
"<p></p><p><br/></p>"