How to embed arbitrary dynamic HTML String into Haskell's Lucid Html type?

291 Views Asked by At

How can I parse an html string for example <p>Test</p> and have this be converted to value that would be similar to p_ "Test"?

So the function type would be String -> Html ().

I've found the following project https://github.com/dbaynard/lucid-from-html but this generates actual Haskell source code as a String.

I'm aware that there are HTML parsing libraries, but I'm just wondering if there already exists a library that has implemented this?

1

There are 1 best solutions below

1
On BEST ANSWER

http://hackage.haskell.org/package/lucid-2.9.11/docs/Lucid-Base.html#v:toHtmlRaw

toHtmlRaw "<p>Test</p>"

The above seems to work well enough, though possibly it does not check for valid syntax.