seonbi-0.4.0: SmartyPants for Korean language
Safe HaskellSafe-Inferred
LanguageHaskell2010

Text.Seonbi.Html.Printer

Synopsis

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>&lt;&gt;&quot;&amp;</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>"