Fix HTML printing.

With inspiration from:
https://github.com/michaeldv/awesome_print/issues/49
https://github.com/michaeldv/awesome_print/commit/b1b8dd

Thanks to @yebyen and @denishaskin

Fixes #49.
Fixes #78.