pretty-html-0.1.0.1: Produce nice human-readable HTML
Safe HaskellSafe-Inferred
LanguageHaskell2010

PrettyHTML

Description

Text elements and attribute values are escaped. Tag names, attribute keys, and comments are neither escaped nor validated; it is possible to construct malformed documents.

Build an Html value using tag, tag', attr, attr', text, comment, and inline. Then use runHtml to get a TextBuilder.

Html has a Monoid instance. It is often more convenient to apply fold a list literal than to chain the (<>) operator. You can use mempty when you need an HTML tag with an empty body.

Synopsis

The Html type

data Html Source #

Instances

Instances details
Monoid Html Source # 
Instance details

Defined in PrettyHTML

Methods

mempty :: Html #

mappend :: Html -> Html -> Html #

mconcat :: [Html] -> Html #

Semigroup Html Source # 
Instance details

Defined in PrettyHTML

Methods

(<>) :: Html -> Html -> Html #

sconcat :: NonEmpty Html -> Html #

stimes :: Integral b => b -> Html -> Html #

Tags

tag Source #

Arguments

:: Foldable t 
=> LazyText

Tag name. This must be a valid tag name; no checking or escaping is done.

-> t Attr

List of attributes. See attr and attr'.

-> Html

Content nested within the tag.

-> Html 

Element with opening and closing tags.

tag' Source #

Arguments

:: Foldable t 
=> LazyText

Tag name. This must be a valid tag name; no checking or escaping is done.

-> t Attr

List of attributes. See attr and attr'.

-> Html 

Self-closing tag, e.g. "meta", "br", "li".

Attributes

attr Source #

Arguments

:: LazyText

Attribute key. This must be a valid key; no checking or escaping is done.

-> LazyText

Attribute value. This can safely be anything; it will be escaped.

-> Attr 

Attribute with a key and value.

attr' Source #

Arguments

:: LazyText

Attribute key. This must be a valid key; no checking or escaping is done.

-> Attr 

Attribute without a value, e.g. "autofocus", "checked".

Plain text

text Source #

Arguments

:: LazyText

Can safely be anything; it will be escaped.

-> Html 

A text element.

Comments

comment Source #

Arguments

:: LazyText

Must not contain a comment closing tag; this is neither checked nor escaped.

-> Html 

A comment appears in the HTML source code but is ignored when read.

Formatting

inline :: Html -> Html Source #

Content wrapped in inline is rendered tersely, without line breaks and indentation.

Typically paragraphs should be rendered inline, e.g. inline (tag "p" [] $ fold [ _, _, _ ])

Text aliases