In LlamaIndex for example, there are a a few markdown-specific classes that work well with this.
You can find an example over in the repo -- https://github.com/run-llama/llama_parse/blob/main/examples/...