Some markdown parsers allow you to take a look at the AST.
I used it to replace a code section containing dot code with a png.
or using comments like <!--more--> to generate site Teasers.
https://github.com/enter-haken/book/blob/master/lib/generato...
You can use pandoc to convert markdown in almost every format you like.
I use it to write letters. https://hake.one/blog/letter.html
If you have access to the AST, you can integrate as much metadata as you like.