I've often been disappointed at the type of html it's possible to force out of (La)TeX. And epubs are pretty much html, css and images.
I generally think that some kind of markdown with the help of pandoc is the happy path for pleasant writing/editing and good output for html/epub and print/pdf.
I did find this, that have some hints on how to get xml, and then xhtml with support for equations - but it looks cumbersome: