https://github.com/landakram/remark-parse-yaml
Parse YAML blocks into structured data.
https://github.com/landakram/remark-parse-yaml
remark remark-plugin yaml yaml-frontmatter
Last synced: about 1 year ago
JSON representation
Parse YAML blocks into structured data.
- Host: GitHub
- URL: https://github.com/landakram/remark-parse-yaml
- Owner: landakram
- License: mit
- Created: 2017-12-24T19:03:29.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-07-28T18:41:36.000Z (almost 7 years ago)
- Last Synced: 2025-04-16T02:56:50.482Z (about 1 year ago)
- Topics: remark, remark-plugin, yaml, yaml-frontmatter
- Language: JavaScript
- Homepage:
- Size: 4.88 KB
- Stars: 14
- Watchers: 2
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# remark-parse-yaml
[](https://badge.fury.io/js/remark-parse-yaml) [](https://travis-ci.org/landakram/remark-parse-yaml)
This [remark](https://github.com/wooorm/remark) plugin takes markdown with yaml frontmatter and parses the yaml into an object.
## Usage
```javascript
const unified = require('unified')
const markdown = require('remark-parse')
const frontmatter = require('remark-frontmatter')
const parseFrontmatter = require('remark-parse-yaml');
let processor = unified()
.use(markdown)
.use(frontmatter)
.use(parseFrontmatter)
```
When the processor is run, `yaml` nodes will now have an additional key, `parsedValue`,
attached to its `data` key.
Say that we have this markdown string:
``` markdown
---
metadata: this is metadata
tags:
- one
- two
---
# Heading
```
When parsed, this will produce a `yaml` node with a `data` object that looks like this:
```javascript
data: {
parsedValue: {
metadata: "this is metadata",
tags: ["one", "two"]
}
}
```