17
17
* [ Install] ( #install )
18
18
* [ Use] ( #use )
19
19
* [ API] ( #api )
20
- * [ ` findAndReplace(tree, find, replace[, options]) ` ] ( #findandreplacetree-find-replace-options )
21
20
* [ ` defaultIgnore ` ] ( #defaultignore )
21
+ * [ ` findAndReplace(tree, find, replace[, options]) ` ] ( #findandreplacetree-find-replace-options )
22
22
* [ ` Find ` ] ( #find )
23
23
* [ ` FindAndReplaceList ` ] ( #findandreplacelist )
24
24
* [ ` FindAndReplaceSchema ` ] ( #findandreplaceschema )
@@ -49,7 +49,7 @@ One example is when you have some form of “mentions” (such as
49
49
## Install
50
50
51
51
This package is [ ESM only] [ esm ] .
52
- In Node.js (version 14.14+ and or 16.0 +), install with [ npm] [ ] :
52
+ In Node.js (version 16 +), install with [ npm] [ ] :
53
53
54
54
``` sh
55
55
npm install hast-util-find-and-replace
@@ -127,10 +127,16 @@ element<p>[9]
127
127
128
128
## API
129
129
130
- This package exports the identifiers [ ` defaultIgnore ` ] [ defaultignore ] and
131
- [ ` findAndReplace ` ] [ findandreplace ] .
130
+ This package exports the identifiers [ ` defaultIgnore ` ] [ api-default-ignore ] and
131
+ [ ` findAndReplace ` ] [ api-find-and-replace ] .
132
132
There is no default export.
133
133
134
+ ### ` defaultIgnore `
135
+
136
+ Default tag names to ignore (` Array<string> ` ).
137
+
138
+ The defaults are ` math ` , ` script ` , ` style ` , ` svg ` , and ` title ` .
139
+
134
140
### ` findAndReplace(tree, find, replace[, options]) `
135
141
136
142
Find patterns in a tree and replace them.
@@ -148,32 +154,20 @@ Partial matches are not supported.
148
154
149
155
* ` tree ` ([ ` Node ` ] [ node ] )
150
156
— tree to change
151
- * ` find ` ([ ` Find ` ] [ find ] )
157
+ * ` find ` ([ ` Find ` ] [ api- find] )
152
158
— value to find and remove
153
- * ` replace ` ([ ` Replace ` ] [ replace ] )
159
+ * ` replace ` ([ ` Replace ` ] [ api- replace] )
154
160
— thing to replace with
155
- * ` search ` ([ ` FindAndReplaceSchema ` ] [ findandreplaceschema ] or
156
- [ ` FindAndReplaceList ` ] [ findandreplacelist ] )
161
+ * ` search ` ([ ` FindAndReplaceSchema ` ] [ api-find-and-replace-schema ] or
162
+ [ ` FindAndReplaceList ` ] [ api-find-and-replace-list ] )
157
163
— several find and replaces
158
- * ` options ` ([ ` Options ` ] [ options ] )
164
+ * ` options ` ([ ` Options ` ] [ api- options] )
159
165
— configuration
160
166
161
167
###### Returns
162
168
163
169
Nothing (` undefined ` ).
164
170
165
- ### ` defaultIgnore `
166
-
167
- Default tag names to ignore.
168
-
169
- The defaults are ` math ` , ` script ` , ` style ` , ` svg ` , and ` title ` .
170
-
171
- ###### Type
172
-
173
- ``` ts
174
- type defaultIgnore = Array <string >
175
- ` ` `
176
-
177
171
### ` Find `
178
172
179
173
Pattern to find (TypeScript type).
@@ -183,7 +177,7 @@ Strings are escaped and then turned into global expressions.
183
177
###### Type
184
178
185
179
``` ts
186
- type Find = string | RegExp
180
+ type Find = RegExp | string
187
181
` ` `
188
182
189
183
### ` FindAndReplaceList `
@@ -196,7 +190,7 @@ Several find and replaces, in array form (TypeScript type).
196
190
type FindAndReplaceList = Array <FindAndReplaceTuple >
197
191
` ` `
198
192
199
- See [ ` FindAndReplaceTuple ` ][findandreplacetuple ].
193
+ See [ ` FindAndReplaceTuple ` ][api-find-and-replace-tuple ].
200
194
201
195
### ` FindAndReplaceSchema `
202
196
@@ -208,7 +202,7 @@ Several find and replaces, in object form (TypeScript type).
208
202
type FindAndReplaceSchema = Record <string , Replace >
209
203
` ` `
210
204
211
- See [ ` Replace ` ][replace].
205
+ See [ ` Replace ` ][api- replace].
212
206
213
207
### ` FindAndReplaceTuple `
214
208
@@ -220,7 +214,7 @@ Find and replace in tuple form (TypeScript type).
220
214
type FindAndReplaceTuple = [Find , Replace ]
221
215
` ` `
222
216
223
- See [ ` Find ` ][find] and [ ` Replace ` ][replace].
217
+ See [ ` Find ` ][api- find] and [ ` Replace ` ][api- replace].
224
218
225
219
### ` Options `
226
220
@@ -251,10 +245,10 @@ Thing to replace with (TypeScript type).
251
245
###### Type
252
246
253
247
` ` ` ts
254
- type Replace = string | ReplaceFunction
248
+ type Replace = ReplaceFunction | string
255
249
` ` `
256
250
257
- See [ ` ReplaceFunction ` ][replacefunction ].
251
+ See [ ` ReplaceFunction ` ][api-replace-function ].
258
252
259
253
### ` ReplaceFunction `
260
254
@@ -268,7 +262,7 @@ The parameters are the result of corresponding search expression:
268
262
— whole match
269
263
* ` ...capture ` ( ` Array <string >` )
270
264
— matches from regex capture groups
271
- * ` match ` ([ ` RegExpMatchObject ` ][regexpmatchobject ])
265
+ * ` match ` ([ ` RegExpMatchObject ` ][api-regexp-match-object ])
272
266
— info on the match
273
267
274
268
###### Returns
@@ -278,26 +272,29 @@ Thing to replace with:
278
272
* when ` null ` , ` undefined ` , ` ' ' ` , remove the match
279
273
* …or when ` false ` , do not replace at all
280
274
* …or when ` string ` , replace with a text node of that value
281
- * …or when ` Node ` or ` Array < Node > ` , replace with those nodes
275
+ * …or when ` Array < Node > ` or ` Node ` , replace with those nodes
282
276
283
277
## Types
284
278
285
279
This package is fully typed with [TypeScript][].
286
- It exports the additional types [ ` Find ` ][find],
287
- [ ` FindAndReplaceList ` ][findandreplacelist ],
288
- [ ` FindAndReplaceSchema ` ][findandreplaceschema ],
289
- [ ` FindAndReplaceTuple ` ][findandreplacetuple ],
290
- [ ` Options ` ][options],
291
- [ ` RegExpMatchObject ` ][regexpmatchobject ],
292
- [ ` Replace ` ][replace], and
293
- [ ` ReplaceFunction ` ][replacefunction ].
280
+ It exports the additional types [ ` Find ` ][api- find],
281
+ [ ` FindAndReplaceList ` ][api-find-and-replace-list ],
282
+ [ ` FindAndReplaceSchema ` ][api-find-and-replace-schema ],
283
+ [ ` FindAndReplaceTuple ` ][api-find-and-replace-tuple ],
284
+ [ ` Options ` ][api- options],
285
+ [ ` RegExpMatchObject ` ][api-regexp-match-object ],
286
+ [ ` Replace ` ][api- replace], and
287
+ [ ` ReplaceFunction ` ][api-replace-function ].
294
288
295
289
## Compatibility
296
290
297
- Projects maintained by the unified collective are compatible with all maintained
291
+ Projects maintained by the unified collective are compatible with maintained
298
292
versions of Node.js.
299
- As of now, that is Node.js 14.14+ and 16.0+.
300
- Our projects sometimes work with older versions, but this is not guaranteed.
293
+
294
+ When we cut a new major release, we drop support for unmaintained versions of
295
+ Node.
296
+ This means we try to keep the current release line,
297
+ ` hast -util -find -and -replace @^4 ` , compatible with Node.js 12.
301
298
302
299
## Security
303
300
@@ -359,9 +356,9 @@ abide by its terms.
359
356
360
357
[ downloads ] : https://www.npmjs.com/package/hast-util-find-and-replace
361
358
362
- [ size-badge ] : https://img.shields.io/bundlephobia/minzip/ hast-util-find-and-replace.svg
359
+ [ size-badge ] : https://img.shields.io/badge/dynamic/json?label=minzipped%20size&query=$.size.compressedSize&url=https://deno.bundlejs.com/?q= hast-util-find-and-replace
363
360
364
- [ size ] : https://bundlephobia .com/result?p =hast-util-find-and-replace
361
+ [ size ] : https://bundlejs .com/?q =hast-util-find-and-replace
365
362
366
363
[ sponsors-badge ] : https://opencollective.com/unified/sponsors/badge.svg
367
364
@@ -407,22 +404,22 @@ abide by its terms.
407
404
408
405
[ test ] : https://github.com/syntax-tree/hast-util-is-element#test
409
406
410
- [ defaultignore ] : #defaultignore
407
+ [ api-default-ignore ] : #defaultignore
411
408
412
- [ findandreplace ] : #findandreplacetree-find-replace-options
409
+ [ api-find-and-replace ] : #findandreplacetree-find-replace-options
413
410
414
- [ options ] : #options
411
+ [ api- options] : #options
415
412
416
- [ find ] : #find
413
+ [ api- find] : #find
417
414
418
- [ replace ] : #replace
415
+ [ api- replace] : #replace
419
416
420
- [ replacefunction ] : #replacefunction
417
+ [ api-replace-function ] : #replacefunction
421
418
422
- [ findandreplacelist ] : #findandreplacelist
419
+ [ api-find-and-replace-list ] : #findandreplacelist
423
420
424
- [ findandreplaceschema ] : #findandreplaceschema
421
+ [ api-find-and-replace-schema ] : #findandreplaceschema
425
422
426
- [ findandreplacetuple ] : #findandreplacetuple
423
+ [ api-find-and-replace-tuple ] : #findandreplacetuple
427
424
428
- [ regexpmatchobject ] : #regexpmatchobject
425
+ [ api-regexp-match-object ] : #regexpmatchobject
0 commit comments