haskellhaskell-lucid

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


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 I want it not to escape the HTML as it does by default.

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?


Solution

  • 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.