Would you consider using regular expressions to find Markdown syntax in your text?
I think it will help you to identify pieces of text easier.
For example: bold text is a pattern of: **\w+**
And this will help you avoid replacing irrelevant strings. You need to identift all markdown syntaxes and write similar conversions. I can help you with that too. Let me know if you are happy to utilize regex.