I haven't tried this myself but I think ConTeXt can output PDFs with embedded XML markup and even epub files. You need to use \startsection and \stopsection instead of just \section, and maybe there are other limitations, but it's a small price to pay, isn't it?
https://wiki.contextgarden.net/Epub
https://wiki.contextgarden.net/Export