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

leading newline in body #11

Closed ianstormtaylor closed 9 years ago

ianstormtaylor commented 9 years ago

Hey, looking to port Metalsmith to gray-matter!

Ran into a question: it was previously using front-matter which stripped a trailing newline after the closing ---, which seemed to mesh more with how a user "perceives" the frontmatter, if not with the way a computer reads it.

Such that...


---
property: true

---
body

...would end up being stripped so that it is exactly equal to...

body

What do you think about supporting that, by swallowing a single newline if one (or more) are present after the closing ---? Technically not "pure", but matches with users editing the frontmatter more I think?

ghost commented 9 years ago

EDIT: Sorry, I misunderstood your words…

jonschlinkert commented 9 years ago

Hey, looking to port Metalsmith to gray-matter!

Awesome! that's great!

About the newline, sure no problem. Someone else recently mentioned that it should strip the newline.

The extra newline can be easily detected after extracting the front matter.

Meaning that implementors could strip the newline? true, but the same point holds for adding a newline.

ghost commented 9 years ago

EDIT: Sorry, I misunderstood your words…

jonschlinkert commented 9 years ago

closing based on #13