jonschlinkert / gray-matter

Smarter YAML front matter parser, used by metalsmith, Gatsby, Netlify, Assemble, mapbox-gl, phenomic, vuejs vitepress, TinaCMS, Shopify Polaris, Ant Design, Astro, hashicorp, garden, slidev, saber, sourcegraph, and many others. Simple to use, and battle tested. Parses YAML by default but can also parse JSON Front Matter, Coffee Front Matter, TOML Front Matter, and has support for custom parsers. Please follow gray-matter's author: https://github.com/jonschlinkert

Home Page:https://github.com/jonschlinkert

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Text containing only one delimiter is detected as empty front matter

jpreynat opened this issue · comments

I have a file with the following content:

---

When running it through gray-matter, or use gm.test(content), it is detected as empty front matter.
It seems like an issue since both delimiters should be present to have a "valid" front matter.

Actually, the issue seems worst than only that:

gm.test('---\nSome text');
// true
gm('---\nSome text');
// { content: '', data: 'Some text', isEmpty: false, excerpt: '' }