I use asciidoc. Have a file per chapter. This then gets combined with a GitHub action into a PDF using book.adoc with a theme. A release package has everything to upload to Amazon for self publishing.
Pretty cool. I reverse engineering how Andreas Antonopoulos did it for Mastering Bitcoin I think it was.