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

adding colon inside string breaks gray-matter parsing

kartik-madhak opened this issue · comments

In my md file, I have this at the beginning:

+++
authors = ["ABC"]
categories = ["cat"]
date = 2023-04-14T00:00:00Z
description = "Title: something about title"
draft = false
+++

... 

This results in error when I try to parse it like this:

const result = grayMatter(content, {
  delimiters: '+++',
  engines: { toml: toml.parse }
})

The error:

✖ Failed to compile template: filename.md
⚠ end of the stream or a document separator is expected at line 10, column 6:
    title = "Title: something about title"
                  ^

Is there a way to make the parser ignore the colon? Any help would be appreciated!

This worked:

const result = grayMatter(html, {
  delimiters: ['+++', '+++'],
  language: 'toml',
  engines: { toml: toml.parse.bind(toml) }
})