I'll second the asciidoc approach. After my wife was killed by a Russian tank in Ukraine, I collected up everything she wrote (she wrote a LOT - I've collected 250,000 words so far) and needed to compile it into a book in a way that allowed easy edits and arrangements.
Asciidoctor was a godsend in this regard, able to output in PDF, EPUB, MS Word, whatever you want.
With Asciidoctor, ImageMagick, FFMpeg, LibreTranslate, and about 800 lines of Python code I'm now able to generate any part of the book draft in any language (this is mainly to build excerpts for publishers).