Refactoring of toHtml code

I originally started this branch with the intention of adding an encoding function to convert straight quotes into curly quotes. But after thinking it over, I concluded that that substitution would better be done at runtime instead of at compile time. However, I think the changes are useful anyway.