Skip to content

lightlii/remark-yaml-config

 
 

Repository files navigation

remark-yaml-config

Build Coverage Downloads Size Sponsors Backers Chat

remark plugin to configure it with YAML frontmatter. This requires remark-frontmatter as well.

Important!

This plugin is affected by the new parser in remark (micromark, see remarkjs/remark#536). Use version 4 while you’re still on remark 12. Use version 5 for remark 13+.

Install

This package is ESM only: Node 12+ is needed to use it and it must be imported instead of required.

npm:

npm install remark-yaml-config

Use

Say we have the following file, example.md:

---
remark:
  bullet: "*"
---

-   Hello

And our module, example.js, looks as follows:

import {readSync} from 'to-vfile'
import {remark} from 'remark'
import remarkFrontmatter from 'remark-frontmatter'
import remarkYamlConfig from 'remark-yaml-config'

const file = readSync('example.md')

remark()
  .use(remarkFrontmatter)
  .use(remarkYamlConfig)
  .process(file)
  .then((file) => {
    console.log(String(file))
  })

Now, running node example yields:

---
remark:
  bullet: "*"
---

*   Hello

API

This package exports no identifiers. The default export is remarkYamlconfig.

unified().use(remarkYamlconfig)

Plugin to configure the processor with YAML frontmatter. Takes the 'remark' field in the frontmatter and passes it as configuration to remark-stringify.

Just like remark-comment-config, but YAML is more visible.

Security

Use of remark-yaml-config can change how Markdown is parsed or compiled. If the Markdown is user provided, this may open you up to a cross-site scripting (XSS) attack.

Related

Contribute

See contributing.md in remarkjs/.github for ways to get started. See support.md for ways to get help.

This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.

License

MIT © Titus Wormer

About

plugin to configure remark with YAML frontmatter

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%