That's a big ask. I've written a couple of books, and PDF/print vs. ePub/webpage is a decision I had to make up front. For anything with more than the most basic formatting (e.g. a novel), the design and layout are different enough that one of them will turn out looking like crap. Given the audience, I probably would have chosen ePub for this one, but the book's done now.
Also, a TOC and sample chapter would be great. A lot more people will be likely to pay if they know what they're getting.
Honestly I haven't tried yet. Maybe Asciidoctor (Which I used) has it figured out. It would at least need to have good enough output for the code examples, otherwise it would probably be a non-starter.
I added links to example pages (which include TOC) to the Gumroad page and here, but yeah I should have put it on the homepage.