Porting Markdown Editor to other application

I have a loosely connected question. How did you integrated markdown as I’m searching for a solution to replace Thunderbird’s crappy composer by something more state of the art.
@icewind Any idea how I could port to other applications without losing connection to the source?

thank you