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

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

bluelovers opened this issue · comments

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: ''
}
 */