18
18
* [ Use] ( #use )
19
19
* [ API] ( #api )
20
20
* [ ` unified().use(rehypeSlug[, options]) ` ] ( #unifieduserehypeslug-options )
21
+ * [ ` Options ` ] ( #options )
21
22
* [ Types] ( #types )
22
23
* [ Compatibility] ( #compatibility )
23
24
* [ Security] ( #security )
@@ -50,8 +51,8 @@ more easily link to particular sections.
50
51
51
52
## Install
52
53
53
- This package is [ ESM only] ( https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c ) .
54
- In Node.js (version 12.20+, 14.14+, or 16.0 +), install with [ npm] [ ] :
54
+ This package is [ ESM only] [ esm ] .
55
+ In Node.js (version 16 +), install with [ npm] [ ] :
55
56
56
57
``` sh
57
58
npm install rehype-slug
@@ -83,7 +84,7 @@ Say we have the following file `example.html`:
83
84
<h5 >elit</h5 >
84
85
```
85
86
86
- And our module ` example.js ` looks as follows:
87
+ …and our module ` example.js ` looks as follows:
87
88
88
89
``` js
89
90
import {read } from ' to-vfile'
@@ -98,7 +99,7 @@ const file = await rehype()
98
99
console .log (String (file))
99
100
```
100
101
101
- Now, running ` node example.js ` yields:
102
+ …then running ` node example.js ` yields:
102
103
103
104
``` html
104
105
<h1 id =" some-id" >Lorem ipsum</h1 >
@@ -111,31 +112,44 @@ Now, running `node example.js` yields:
111
112
## API
112
113
113
114
This package exports no identifiers.
114
- The default export is ` rehypeSlug ` .
115
+ The default export is [ ` rehypeSlug ` ] [ api-rehype-slug ] .
115
116
116
117
### ` unified().use(rehypeSlug[, options]) `
117
118
118
119
Add ` id ` s to headings.
119
120
120
- ##### ` options `
121
+ ###### Parameters
121
122
122
- Configuration (optional).
123
+ * ` options ` ([ ` Options ` ] [ api-options ] , optional)
124
+ — configuration
123
125
124
- ###### ` options.prefix `
126
+ ###### Returns
125
127
126
- Prefix to add in front of ` id ` s (` string ` , default: ` '' ` ).
128
+ Transform ([ ` Transformer ` ] [ unified-transformer ] ).
129
+
130
+ ### ` Options `
131
+
132
+ Configuration (TypeScript type).
133
+
134
+ ###### Fields
135
+
136
+ * ` prefix ` (` string ` , default: ` '' ` )
137
+ — prefix to add in front of ` id ` s
127
138
128
139
## Types
129
140
130
141
This package is fully typed with [ TypeScript] [ ] .
131
- It exports the additional type ` Options ` .
142
+ It exports the additional type [ ` Options ` ] [ api-options ] .
132
143
133
144
## Compatibility
134
145
135
- Projects maintained by the unified collective are compatible with all maintained
146
+ Projects maintained by the unified collective are compatible with maintained
136
147
versions of Node.js.
137
- As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
138
- Our projects sometimes work with older versions, but this is not guaranteed.
148
+
149
+ When we cut a new major release, we drop support for unmaintained versions of
150
+ Node.
151
+ This means we try to keep the current release line, ` rehype-slug@^5 ` ,
152
+ compatible with Node.js 12.
139
153
140
154
This plugin works with ` rehype-parse ` version 1+, ` rehype-stringify ` version 1+,
141
155
` rehype ` version 1+, and ` unified ` version 4+.
@@ -182,9 +196,9 @@ abide by its terms.
182
196
183
197
[ downloads ] : https://www.npmjs.com/package/rehype-slug
184
198
185
- [ size-badge ] : https://img.shields.io/bundlephobia/minzip /rehype-slug.svg
199
+ [ size-badge ] : https://img.shields.io/bundlejs/size /rehype-slug
186
200
187
- [ size ] : https://bundlephobia .com/result?p =rehype-slug
201
+ [ size ] : https://bundlejs .com/?q =rehype-slug
188
202
189
203
[ sponsors-badge ] : https://opencollective.com/unified/sponsors/badge.svg
190
204
@@ -198,32 +212,40 @@ abide by its terms.
198
212
199
213
[ npm ] : https://docs.npmjs.com/cli/install
200
214
215
+ [ esm ] : https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
216
+
201
217
[ esmsh ] : https://esm.sh
202
218
203
219
[ health ] : https://github.com/rehypejs/.github
204
220
205
- [ contributing ] : https://github.com/rehypejs/.github/blob/HEAD /contributing.md
221
+ [ contributing ] : https://github.com/rehypejs/.github/blob/main /contributing.md
206
222
207
- [ support ] : https://github.com/rehypejs/.github/blob/HEAD /support.md
223
+ [ support ] : https://github.com/rehypejs/.github/blob/main /support.md
208
224
209
- [ coc ] : https://github.com/rehypejs/.github/blob/HEAD /code-of-conduct.md
225
+ [ coc ] : https://github.com/rehypejs/.github/blob/main /code-of-conduct.md
210
226
211
227
[ license ] : license
212
228
213
229
[ author ] : https://wooorm.com
214
230
215
- [ typescript ] : https://www.typescriptlang.org
216
-
217
- [ unified ] : https://github.com/unifiedjs/unified
231
+ [ github-slugger ] : https://github.com/Flet/github-slugger
218
232
219
233
[ rehype ] : https://github.com/rehypejs/rehype
220
234
221
- [ xss ] : https://en.wikipedia.org/wiki/Cross-site_scripting
222
-
223
- [ github-slugger ] : https://github.com/Flet/github-slugger
224
-
225
235
[ rehype-autolink-headings ] : https://github.com/rehypejs/rehype-autolink-headings
226
236
227
237
[ rehype-sanitize ] : https://github.com/rehypejs/rehype-sanitize
228
238
229
239
[ rehype-sanitize-example ] : https://github.com/rehypejs/rehype-sanitize#example-headings-dom-clobbering
240
+
241
+ [ typescript ] : https://www.typescriptlang.org
242
+
243
+ [ unified ] : https://github.com/unifiedjs/unified
244
+
245
+ [ unified-transformer ] : https://github.com/unifiedjs/unified#transformer
246
+
247
+ [ xss ] : https://en.wikipedia.org/wiki/Cross-site_scripting
248
+
249
+ [ api-options ] : #options
250
+
251
+ [ api-rehype-slug ] : #unifieduserehypeslug-options
0 commit comments