markup: Abstraction for HTML-embedded content

[ bsd3, data, library, web ] [ Propose Tags ] [ Report a vulnerability ]

Please see the README on Github at https://github.com/githubuser/markup#readme


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.0.1, 0.0.2, 0.0.3, 0.0.4, 0.0.5, 0.0.6, 0.0.6.1, 0.0.7, 0.0.8, 1.0.0, 1.1.0, 2.0.0, 2.1.0, 2.1.1, 2.2.0, 3.0.0, 3.1.0, 4.0.0, 4.0.1, 4.0.2, 4.0.3, 4.0.4, 4.1.0, 4.2.0 (info)
Dependencies attoparsec-uri (>=0.0.4), base (>=4.8 && <5), blaze-html, blaze-markup, clay, comonad, lucid (>=2.5), mmorph, monad-control, monad-logger, mtl, path, path-extra (>=0.2.0), resourcet, text, transformers-base, urlpath (>=9.0.0) [details]
License BSD-3-Clause
Copyright Copyright (c) 2018 Athan Clark
Author Athan Clark
Maintainer athan.clark@localcooking.com
Category Data, Web
Home page https://github.com/athanclark/markup#readme
Bug tracker https://github.com/athanclark/markup/issues
Source repo head: git clone https://github.com/athanclark/markup
Uploaded by athanclark at 2018-04-11T15:39:39Z
Distributions
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 13344 total (25 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2018-04-13 [all 1 reports]

Readme for markup-4.2.0

[back to package description]

MIT License Hackage Stories in Ready

markup

WARNING: This project is in it's infancy, please don't expect it to work. Thank you :)

A generic interface to chunks of markup.

In this library, we try to ambiguate types of markup via data types, namely Image and JavaScript as examples. From here, we can issue a call to renderMarkup on these abstract labels, which will return some markup wrapped in a monad - in our case, we've made a few monad readers to represent the different ways a single idea can be deployed as markup.

We have three different deployment schemes - inline, hosted, and local. Inline markup simply tries to take the information in question and insert it inside the markup. Hosted markup simply takes the idea and expects it to be somewhere else, possibly hosted in a CDN. Local markup tries to utilize urlpath as the means of representing a local link (absolute, relative, and grounded methods are in another monad - inside the HtmlT m () of lucid, in this case. Urlpath isn't supported for Blaze-html.)

Installation

cabal install markup

Usage

It's a little awkward at the moment:

image' = renderMarkup Image :: Monad m => HostedMarkupT m T.Text (Html ())

image = runHostedMarkupT image' "foo.png"

λ> renderText image

<img src="foo.png">

We could also overload the run* monad transformer actions of each deployment scheme, allowing for the decision to be made just with a type coersion. Maybe in v0.0.2 :)

Here is the same example, going relative instead:

image' = renderMarkup Image :: (Monad m, Url UrlString AbsoluteUrl) => LocalMarkupT UrlString m (HtmlT AbsoluteUrl ())

λ> (runUrlReader $ renderTextT $ runIdentity $ runLocalMarkupT image' $
     "foo.png" <?> ("key","bar")
   ) "example.com"

"<img src=\"example.com/foo.png?key=bar\">"

How to run tests

cabal configure --enable-tests && cabal build && cabal test

Contributing

Fork, PR, repeat.