Skip to content

Commit ad9e290

Browse files
committed
remark: add examples on how to configure
Closes GH-314.
1 parent 0e38987 commit ad9e290

1 file changed

Lines changed: 61 additions & 4 deletions

File tree

packages/remark/readme.md

Lines changed: 61 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# remark [![Build Status][build-badge]][build-status] [![Coverage Status][coverage-badge]][coverage-status] [![Chat][chat-badge]][chat]
22

3-
The [**remark**][remark] processor is a markdown processor powered by
3+
The [`remark`][remark] processor is a markdown processor powered by
44
[plugins][].
55

6-
* Interface by [**unified**][unified]
6+
* Interface by [`unified`][unified]
77
* [**MDAST**][mdast] syntax tree
8-
* Parses markdown to the tree with [**remark-parse**][parse]
8+
* Parses markdown to the tree with [`remark-parse`][parse]
99
* [Plugins][] transform the tree
10-
* Compiles the tree to markdown using [**remark-stringify**][stringify]
10+
* Compiles the tree to markdown using [`remark-stringify`][stringify]
1111

1212
Don’t need the parser? Or the compiler? [That’s OK][unified-usage].
1313

@@ -21,6 +21,10 @@ npm install remark
2121

2222
## Usage
2323

24+
###### Common example
25+
26+
This example lints markdown and turns it into HTML.
27+
2428
```js
2529
var remark = require('remark');
2630
var recommended = require('remark-preset-lint-recommended');
@@ -42,9 +46,58 @@ Yields:
4246
1:1 warning Missing newline character at end of file final-newline remark-lint
4347
4448
⚠ 1 warning
49+
```
50+
51+
```html
4552
<h2>Hello world!</h2>
4653
```
4754

55+
###### Settings through data
56+
57+
This example prettifies markdown and configures [`remark-parse`][parse] and
58+
[`remark-stringify`][stringify] through [data][].
59+
60+
```js
61+
var remark = require('remark');
62+
63+
remark()
64+
.data('settings', {commonmark: true, emphasis: '*', strong: '*'})
65+
.process('_Emphasis_ and __importance__', function (err, file) {
66+
if (err) throw err;
67+
console.log(String(file));
68+
});
69+
```
70+
71+
Yields:
72+
73+
```markdown
74+
*Emphasis* and **importance**
75+
```
76+
77+
###### Settings through a preset
78+
79+
This example prettifies markdown and configures [`remark-parse`][parse] and
80+
[`remark-stringify`][stringify] through a [preset][].
81+
82+
```js
83+
var remark = require('remark');
84+
85+
remark()
86+
.use({
87+
settings: {commonmark: true, emphasis: '*', strong: '*'}
88+
})
89+
.process('_Emphasis_ and __importance__', function (err, file) {
90+
if (err) throw err;
91+
console.log(String(file));
92+
});
93+
```
94+
95+
Yields:
96+
97+
```markdown
98+
*Emphasis* and **importance**
99+
```
100+
48101
## License
49102

50103
[MIT][license] © [Titus Wormer][author]
@@ -82,3 +135,7 @@ Yields:
82135
[plugins]: https://github.com/remarkjs/remark/blob/master/doc/plugins.md
83136

84137
[unified-usage]: https://github.com/unifiedjs/unified#usage
138+
139+
[preset]: https://github.com/unifiedjs/unified#preset
140+
141+
[data]: https://github.com/unifiedjs/unified#processordatakey-value

0 commit comments

Comments
 (0)