You could consider parsing into Pandoc AST (just need to output the JSON representation of it). Then you can automatically interface with all the output formats supported by Pandoc, including HTML. See pandoc --from json, and
https://pandoc.org/using-the-pandoc-api.html