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

Do it support multiple documents in one file? #21

Closed fghhfg closed 9 years ago

fghhfg commented 9 years ago

like this:


---
Time: 2001-11-23 15:01:42 -5
User: ed
Warning:
  This is an error message
  for the log file

---
Time: 2001-11-23 15:02:31 -5
User: ed
Warning:
  A slightly different error
  message.

---
Date: 2001-11-23 15:03:17 -5
User: ed
Fatal:
  Unknown variable "bar"
Stack:
  - file: TopClass.py
    line: 23
    code: |
      x = MoreObject("345\n")
  - file: MoreClass.py
    line: 58
    code: |-
      foo = bar

I tried, but failed...

> var matter = require('gray-matter');
> matter('---\ntitle: Front Matter\n---\nThis is content.\n---\ndddsss');
{ orig: '---\ntitle: Front Matter\n---\nThis is content.\n---\ndddsss',
  data: { title: 'Front Matter' },
  content: 'This is content.\n---\ndddsss' }

I want to save multiple part html,

title: aaa
description: bbb

---
<div>
    <div id="ad-535" class="ad-535"></div>
    <div id="ad-267" class="ad-267 ad-middle"></div>
    <div id="ad-458" class="ad-458"></div>
</div>

---
<div>
    <div id="ad-535" class="ad-535"></div>
    <div id="ad-267" class="ad-267 ad-middle"></div>
    <div id="ad-458" class="ad-458"></div>
</div>

and I don't want to write something like this:

part1: <div><div id="ad-535" class="ad-535"></div><div id="ad-267" class="ad-267 ad-middle"></div><div id="ad-458" class="ad-458"></div></div>
part2: <div><div id="ad-535" class="ad-535"></div><div id="ad-267" class="ad-267 ad-middle"></div><div id="ad-458" class="ad-458"></div></div>