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
https://github.com/jonschlinkert
MIT License
3.97k stars 138 forks source link

[request] add option for only match when language is set on matter #99

Open bluelovers opened 4 years ago

bluelovers commented 4 years ago
let text_not_parse = `---
title: Hello
slug: home
---
<h1>Hello world!</h1>
This is content
<!-- end -->
<h1>Hello world</h1>`;
/*
{
  content: '---\ntitle: Hello\nslug: home\n---<h1>Hello world!</h1>\nThis is content\n<!-- end -->\n<h1>Hello world</h1>',
  data: {},
  isEmpty: false,
  excerpt: ''
}
 */
let text_will_parse = `---yaml
title: Hello
slug: home
---
<h1>Hello world!</h1>
This is content
<!-- end -->
<h1>Hello world</h1>`;
/*
{
  content: '<h1>Hello world!</h1>\nThis is content\n<!-- end -->\n<h1>Hello world</h1>',
  data: { title: 'Hello', slug: 'home' },
  isEmpty: false,
  excerpt: ''
}
 */