Print/Merge Document to HTML uses PHPWord to process the HTML - is this meant to happen?
In 'Print/Merge Document' you can select to output to HTML. In practice, this processes the HTML via PHPWord. This seems to mangle it quite badly: div tags get converted into text (it literally says 'div'), styling gets removed, etc. I'm not sure whether this is deliberate or not, but there's an easy alternative that seems to work well.
The conversion starts in CRM_Contact_Form_Task_PDFLetterCommon. If we want to export anything other than a PDF it's sent to CRM_Utils_PDF_Document::html2doc(), which uses PHPWord. But I'm wondering if it makes more sense to actually use the PDF route for HTML - this goes via CRM_Utils_PDF_Utils::html2pdf().
html2PDF works by generating HTML pages for the PDF processor. So it produces an elegant HTML document by itself anyway. It does some basic processing like removing header tags, applying the appropriate margins, and applying print.css. But other than that the HTML is untouched. It's very easy just to output the HTML before the final step of converting to PDF.
I have this working here, and I can make it into an extension easily enough (though it'd need to override core files). But as the HTML output functionality doesn't really seem to work like I'd expect, I thought I'd flag it here. I can put the changes into a PR if that'd help.