Oh dear. Markdown has no standard grammar or standard way of rendering.
This website lags while I scroll on mobile.
I remember when the internet used to be fast and responsive. Probably just getting old.
there is the commonmark specification https://spec.commonmark.org/0.30/
I work a lot with common mark and hoedown for work. There's no formal Grammer for parsing markdown unfortunately. The closest thing to what the parent comment is talking about is pandoc which most people are afraid of because Haskell is scary and the markdown format they use is strange.
Also all of the parsers for md are very complicated.
Hmm, have you tried pulldown-cmark. It's not easy-perse but it's readable and has an awesome interface. Though it's rust so the interface usability might differ for other languages.