Package

purescript-html-parser-halogen

Repository
rnons/purescript-html-parser-halogen
License
BSD-3-Clause
Uploaded by
rnons
Published on
2018-04-11T04:50:04Z
purescript-html-parser-halogen on Pursuit

A library to render raw HTML string into halogen views.

See Demo for an example.

How to use

import Html.Parser.Halogen as PH

rawHtml :: String
rawHtml = """<a href="https://github.com">a link</a>"""

render =
  ...
  HH.div_ [ PH.render rawHtml ]

It's as simple as this, in most cases you only need the render function from Html.Parser.Halogen module.

Be cautious

This library doesn't support malformed HTML, and is prone to XSS attack. Use it only when you trust the HTML string.

You can balance and sanitize the HTML on the backend, e.g. sanitizeBalance from xss-sanitize.

How it works

Html.Parser parses HTML String as HtmlNode. Html.Parser.Halogen converts HtmlNode to halogen HTML. You can also write adapters to convert HtmlNode to the HTML type of other view libraries.

If you want to `Html.Parser** with other view libraries, I can release it as a separate package, let me know if you are interested.

Other approaches to render raw HTML into halogen views