I would do it in Javascript. There is a lot a existing open source code that will teach you how to do that and you will learn the de facto programming language for the web which would complement nicely your HTML learning. A good library to start with would be Markdown-it.
https://markdown-it.github.io/
It looks like this is the parser used, with some options to reduce the set with the sanitizer. At least, that's my reading of markdown.js
I'd recommend markdown-it(GitHub). Showdown was already mentioned, but if you decide to use it, you have to remember that it does nothing to prevent XSS, so you'll also need a sanitizer. With markdown-it you can just disable html markdown and you're good to go!