Of possible interest is a blog post on converting Project Gutenberg Projects to Markdown for further typesetting (using pandoc to transform Markdown into ConTeXt):
https://dave.autonoma.ca/blog/2020/04/11/project-gutenberg-projects/
The programming bits are in the section that uses XSLT to convert from XHTML (epubs) to Markdown:
https://dave.autonoma.ca/blog/2020/04/11/project-gutenberg-projects/#xhtml-to-markdown
The build script in the download section uses pandoc to convert the Markdown to ConTeXt. The ConTeXt document will be typeset in a subsequent post. This particular blog series is about using pandoc, Markdown, and ConTeXt to produce beautiful output and may be of general interest:
https://dave.autonoma.ca/blog/
Stay safe.