Open lqmanh opened 5 years ago
Metadata is similar to YAML but it's not YAML. It's supposed to be a way for defining HTML metadata.
I think it would be great if it fully support YAML though. That metadata is just a subset of YAML, right?
If you do Converter.getMetadata(true)
it should return the raw metadata block, you could then pass that to a YAML parser.
This commit should work (I'm trying to do the same thing myself.): https://gitlab.com/random-reviews/random-reviews.gitlab.io/tree/bb1c92d1e40d765112e69ccd55917b4f4a209e84
@jcc10 Currently I use gray-matter
. It's totally enough for my needs but I'm saying it would be great if this is implemented natively in showdown
. Then I don't have to use a different tool to parse front matter just because the built-in one is worse.
While I understand the appeal of supporting full YAML, I don't think the pros outweigh the cons.
The metadata feature is meant for defining HTML metadata which is rather simple and does not support most YAML features (like arrays, lists, etc...). It's not
Also, it would slow down the parser just for those extra features, which most users don't really care about.
Then I don't have to use a different tool to parse front matter just because the built-in one is worse.
In order for fully support YAML I would need to add an extra dependency (a YAML parser) to showdown so you would be using a different tool anyways, you just wouldn't notice it.
As @jcc10 pointed out, using getMetadata(true)
is more flexible. You get the raw stuff and can parse it however you want.
I have some markdown files with the front-matter lilke this:
Currently Showdown
Converter.getMetadata()
doesn't parse Boolean, Date or Array values correctly but literal strings. Could you please make it fully support YAML front-matter format?