I’ve been obsessing over ways to make this more efficient, so I wrote a markdown parser that can parse streaming markdown (semi) incrementally. Instead of re-processing the whole document each time, it only parses what’s new, processing each line only once. Block‑level nodes are buffered until they’re complete (for example, once a paragraph is done and won’t be extended by more text).
The API is intentionally simple, but there’s an experimental mode that surfaces all finalized nodes (both top‑level and nested), so you can take more control over how and when you render.
Here’s a demo if you’d like to see it in action:
https://markdownparser.vercel.app/
I’ve spent a lot of time thinking about this problem, so if you’re working on similar issues, I'd love to chat.