If anyone is curious this open source tool will convert markdown (with support for images) into pdf, epub, mobi and html:
https://github.com/softcover/softcover
It was written by the same guy who created the original Rails tutorial. You'll be able to generate books that look and feel like this https://www.railstutorial.org/book.
I've released a couple of PDFs using it, and it's pretty decent to work with. There's room for improvement but I haven't come across anything better.