I will not have a complete solution. In my opinion, there are two or even three stages in such a transformation:
Stage 1: get HTML5 with well-formed
There is black art here where you need to ensure that there is no well-structured HTML 5 requirement.
You need this before you have the DOM, before you have any chance of getting tools that expect a function that looks remotely like xml to function.
, : (?) . . :
, - , .
, xhtml - (FCKeditor ..)
. <p>para<ul><li>bullet</ul><p>para
<p>para</p><ul><li>bullet</li></ul><p>para</p>
2: , Polyglot
, html- , , , polyglot, , html XML.
, XSLT, , , DTD - polyglot (x) html. xhtml5, , , .
, , , , .
3:
? , polyglot (x) html javascript, document.write, . , .