Whilst preparing my book Development I constructed a small toolchain to assemble the ePub, mobi and pdf files.
I have chosen the “Bring Your Own Book” option on leanpub to give me the maximum flexibility.
From the project files from Development I have extracted a github project that can act as a starting point for writing another book: Writers Toolkit.
Currently the scripts to setup and build are mac centric but I would welcome pull requests for other platforms.
The build tools are based upon the wonderful Pandoc. I use this to turn markdown files into ePub and pdf files. The ePub is then converted into a mobi file for Kindle.
The only issue that I have had with Pandoc is trying to convince it to correctly form P2 paragraphs. I had been using the inline ## form for this. The other option adding —- to the following line seems to be more reliable.