swiftlang / swift-markdown

A Swift package for parsing, building, editing, and analyzing Markdown documents.
https://swiftpackageindex.com/swiftlang/swift-markdown/documentation/markdown
Apache License 2.0
2.78k stars 190 forks source link

Plans to support Markdown Metadata / YAML Front Matter? #73

Open bdrelling opened 2 years ago

bdrelling commented 2 years ago

Many Markdown parsing engines have adopted Metadata parsing as well, which is usually written as a YAML block at the top of a document, popularized by Jekyll (as far as I'm aware): https://jekyllrb.com/docs/front-matter/

As an example, the popular Swift Markdown library Ink also includes automatic parsing.

Xcode also uniquely highlights YAML at the top of a Markdown file.

I'm wondering if there are plans to support this within the swift-markdown repository, and if not, what the proper way would be to extend the swift-markdown library for doing this? Currently, I'm fetching the document, stripping the YAML from it, then parsing the YAML and Markdown separately.

Thanks!

alexito4 commented 1 year ago

I'm also interested in this for my blog. I find swift-markdown a great libray to parse and manipulate markdown in a structured way, so I was hoping to replace the current markdown parser I use for this. It would be very interesting if it supported front-matter out of the box.

Right now, at least in my tests, it gets parsed as a ThematicBreak followed by Heading level: 2.

tscholze commented 1 year ago

I would highly welcome this feature

twostraws commented 8 months ago

I'm also keen to see this addition – thank you!