How about HTML -> pandoc -> epub
This looks promising to me. I have actually used "Pro Git"
Creating an ebook with pandoc
A real book
To see what this would look like for a real book, let’s convert Scott Chacon’s book Pro Git, which he wrote using pandoc’s markdown variant and released under a Creative Commons license. (If you use the book, please consider buying a copy to help support his excellent work.)