You know what, while you're at it, I might as well bring it up. How about XML?
I haven't really tried writing large pieces of text in it but I am already seriously considering. All other alternatives are too complicated and have a learning curve that gets in the way of writing itself. With XML, I'd be able to define my own tags and run them by a parser later on to auto-generate indexable footnotes, and create my own ways of structuring text besides the usual ones (chapters, sections, etcetera). Has anyone tried this approach?
I have been thinking about this seriously myself. Not with a specific existing schema like DocBook, but with a custom schema (defined by me) that I then compile to standard schemas, like DocBook or HTML.
This seems extensible to the degree that I want (i.e. semantically rich enough that you can conceivably hang any application from it). But I just can't bring myself to write in XML syntax, especially for maths.
There's also a standard to turn XML into HTML via XSLT.
Professional tech writer here: We use GitHub and a tool called OxygenXML to write docs-as-code in an XML DTD called "DITA". It's a hefty IBM invention from the early aughts, but it covers every use case I've thrown at it, from small documentation sets to multi-thousand-page monsters. Supports PDF, HTML, Word, and many other output types.