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.
Merge pull request #117 from mikemcquaid/fix-html-printing

Fix HTML printing.