Sorry for the SO like answer, but id recommend not thinking very hard about PDF compilation of you're writing in markdown, for now.
I've done something similar but I burnt so much time on configuring Pandoc, citations, formulas, and a compilation process, instead of writing the actual book. If you're writing in Markdown, most of this process for you can be done at the end too.
With that said, Pandoc has been great. Gotta dive into some configuration to get things how you want for the finalized PDF, but it's great.