Extract HTML generation to its own function

See #7.
Docs for HTML helper functions