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

Document readme.md serious error about the options of delimiters #91

Open donaldtone opened 5 years ago

donaldtone commented 5 years ago

options.delimiters Type: String Default: ---

Open and close delimiters can be passed in as an array of strings.

Example:

// format delims as a string
matter.read('file.md', {delims: '~~~'});
// or an array (open/close)
matter.read('file.md', {delims: ['~~~', '~~~']});

the example is wrong. it should use delimiters instead of delims.

like that:

Example:

// format delims as a string
matter.read('file.md', {delimiters: '~~~'});
// or an array (open/close)
matter.read('file.md', {delimiters: ['~~~', '~~~']});
eikowagenknecht commented 9 months ago

I checked the code. Indeed delims is still the primary source and delimiters is only used when delims is not present.


  // ensure that delimiters are an array
  opts.delimiters = utils.arrayify(opts.delims || opts.delimiters || '---');
  if (opts.delimiters.length === 1) {
    opts.delimiters.push(opts.delimiters[0]);
  }