markup

Abstraction for markup languages

Version on this page:1.1.0
LTS Haskell 11.22:4.0.4
Stackage Nightly 2018-03-12:4.0.4
Latest on Hackage:4.2.0

See all snapshots markup appears in

MIT licensed and maintained by Athan Clark
This version can be pinned in stack with:markup-1.1.0@sha256:46029820106f3f27a2264c4b7f8906e751efce91c955d69375695ae802c59dfc,2572

Module documentation for 1.1.0

This library tries to make things more uniformly controlled when working with markup languages in haskell - namely deployment of markup assets.

Deployment, from this library's perspective, means how something can be rendered to markup, yet still achieve the same "result" to the end user (namely the DOM).

We use monad transformers to infer the deployment mechanism for a context of markup. The three deployment mechanisms provided include inline (content is slapped between markup tags), hosted (entirely external - uses raw text as a url), and local (which uses the urlpath library to realize what kind of link to create).

As an example, here is remotely hosted image:

image = deploy Image "foo.png" :: HostedMarkupM (Html ())

λ> renderMarkup image

<img src="foo.png">

Here is the same example, going relative instead:

image :: LocalMarkupM (HtmlT AbsoluteUrl ())
image = deploy Image $ "foo.png" <?> ("some","getparam")

λ> (runUrlReader $ renderTextT $ renderMarkup image $
   ) "example.com"

"<img src=\"example.com/foo.png?some=getparam\">"