PreTeXt
PreTeXt is an xml vocabulary promising “the best of DocBook, LaTeX, and HTML.” It used to be called MathBook XML. There are examples online, like this abstract algebra text. PreTeXt makes it easy to incorporate runnable sage cells into your text, and it also has WeBWorK integration.
They have a LaTeX-PreTeXt conversion service.
Usage
The easiest thing is to clone one of their github repos and modify it yourself. I ran out of time to investigate this properly, see the quickstart guide for instructions.