Technically Markdown is supposed to support you adding HTML in.
So in theory, depending on your markdown parser, you should just be able to feed everything through a markdown parser and get out the valid HTML, even if the content contains HTML itself.