Have you tried AsciiDoc as a publishing tool? It converts to docboocs xml, from which it’s easy to make pdf, html, epub etc…