@@ -161,7 +161,9 @@ parse('<br>', {
161
161
});
162
162
```
163
163
164
- Console output:
164
+ <details >
165
+ <summary >Console output</summary >
166
+ <p >
165
167
166
168
``` js
167
169
Element {
@@ -177,6 +179,9 @@ Element {
177
179
}
178
180
```
179
181
182
+ </p >
183
+ </details >
184
+
180
185
The element is replaced if a ** valid** React element is returned:
181
186
182
187
``` jsx
@@ -245,7 +250,9 @@ const options = {
245
250
parse (html, options);
246
251
```
247
252
248
- HTML output:
253
+ <details >
254
+ <summary >HTML output</summary >
255
+ <p >
249
256
250
257
<!-- prettier-ignore-start -->
251
258
@@ -259,6 +266,9 @@ HTML output:
259
266
260
267
<!-- prettier-ignore-end -->
261
268
269
+ </p >
270
+ </details >
271
+
262
272
#### replace element attributes
263
273
264
274
Convert DOM attributes to React props with ` attributesToProps ` :
@@ -282,12 +292,17 @@ const options = {
282
292
parse (html, options);
283
293
```
284
294
285
- HTML output:
295
+ <details >
296
+ <summary >HTML output</summary >
297
+ <p >
286
298
287
299
``` html
288
300
<div class =" prettify" style =" background :#fff ;text-align :center " ></div >
289
301
```
290
302
303
+ </p >
304
+ </details >
305
+
291
306
#### replace and remove element
292
307
293
308
[ Exclude] ( https://replit.com/@remarkablemark/html-react-parser-56 ) an element from rendering by replacing it with ` <React.Fragment> ` :
@@ -298,12 +313,17 @@ parse('<p><br id="remove"></p>', {
298
313
});
299
314
```
300
315
301
- HTML output:
316
+ <details >
317
+ <summary >HTML output</summary >
318
+ <p >
302
319
303
320
``` html
304
321
<p ></p >
305
322
```
306
323
324
+ </p >
325
+ </details >
326
+
307
327
### transform
308
328
309
329
The ` transform ` option allows you to transform each element individually after it's parsed.
@@ -522,7 +542,7 @@ If you see the TypeScript error:
522
542
node_modules/htmlparser2/lib/index.d.ts:2:23 - error TS1005: ',' expected.
523
543
524
544
2 export { Parser, type ParserOptions };
525
- ~~~~~~~~~~~~~
545
+ ~~~~~~~~~~~~~
526
546
```
527
547
528
548
Then upgrade to the latest version of [ typescript] ( https://www.npmjs.com/package/typescript ) . See [ #748 ] ( https://github.com/remarkablemark/html-react-parser/issues/748 ) .
0 commit comments