Using blaze to reverse engineer an HTML page
In this recipe, we will use a package blaze-from-html to reverse engineer an existing HTML page, to create Haskell
code that uses blaze-html.
How to do it...
- Install
blaze-from-html
using stack. Here we use the resolverlts-9.1
. Feel free to use the latest or your favorite resolver:
stack --resolver lts-9.1 install blaze-from-html
- Check the location of the tool using
stack
:
stack path --local-bin
- Use
curl
to download the home page from haskell.org (http://www.haskell.org/):
curl -X GET http://www.haskell.org -o index.html
- Use
blaze-from-html
to engineer the blaze DSL from the HTML page:
blaze-from-html -v html5 -s index.html > index.hs
- You will need to tweak the code.
- Correct the encoding of the copyright message in the footer class (find the code
H.div ! class_ "footer"
). Find the message "2014-2017 haskell.org
". Either correct the encoding or remove the characters that create problems. - Add the module for rendering at...