UNPKG

2.29 kBMarkdownView Raw
1# remark-yaml-config [![Build Status](https://img.shields.io/travis/wooorm/remark-yaml-config.svg)](https://travis-ci.org/wooorm/remark-yaml-config) [![Coverage Status](https://img.shields.io/codecov/c/github/wooorm/remark-yaml-config.svg)](https://codecov.io/github/wooorm/remark-yaml-config)
2
3Configure **remark** with YAML front-matter.
4
5## Installation
6
7[npm](https://docs.npmjs.com/cli/install)
8
9```bash
10npm install remark-yaml-config
11```
12
13**remark-yaml-config** is also available for [duo](http://duojs.org/#getting-started),
14and as an AMD, CommonJS, and globals module, [uncompressed and
15compressed](https://github.com/wooorm/remark-yaml-config/releases).
16
17## Table of Contents
18
19* [Usage](#usage)
20
21* [API](#api)
22
23 * [remark.use(yamlConfig, options)](#remarkuseyamlconfig-options)
24
25* [License](#license)
26
27## Usage
28
29```javascript
30var yamlConfig = require('remark-yaml-config');
31var remark = require('remark').use(yamlConfig);
32var input = [
33 '---',
34 'remark:',
35 ' commonmark: true',
36 ' bullet: "*"',
37 '---',
38 '',
39 '1) Commonmark list (this is a parse setting)',
40 '',
41 '- Hello (this is a stringification setting)',
42 ''
43].join('\n');
44var tree = remark.parse(input);
45```
46
47Stringifying the document yields:
48
49```javascript
50var doc = remark.stringify(tree);
51```
52
53```markdown
54---
55remark:
56 commonmark: true
57 bullet: '*'
58---
59
601. Commonmark list (this is a parse setting)
61
62* Hello (this is a stringification setting)
63```
64
65## API
66
67### [remark](https://github.com/wooorm/remark#api).[use](https://github.com/wooorm/remark#remarkuseplugin-options)(yamlConfig, options)
68
69Passes the [configuration](https://github.com/wooorm/remark/blob/master/doc/Options.md)
70found in YAML front-matter (under the `remark` key) to **remark**.
71
72This is especially useful if you’re using **remark**’s [CLI](https://github.com/wooorm/remark#cli),
73which allows multiple documents to be processed in one go, but you’d like
74certain files to have different formatting.
75
76**Signatures**
77
78* `remark = remark.use(yamlConfig, options?)`.
79
80**Parameters**
81
82* `yamlConfig` — This plugin;
83* `options` (`Object?`) — Passed to [remark-yaml](https://github.com/wooorm/remark-yaml#remarkuseyaml-options).
84
85## License
86
87[MIT](LICENSE) © [Titus Wormer](http://wooorm.com)