Skip to content

Commit 7fd6680

Browse files
committed
docs: update explaination for the trim flag
1 parent ce5e01b commit 7fd6680

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

README.md

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -351,16 +351,16 @@ By default, whitespace is preserved:
351351
parse('<br>\n'); // [React.createElement('br'), '\n']
352352
```
353353

354-
To remove whitespace, enable the `trim` option:
354+
However, whitespace that are invalid under certain nodes like `<table>` will be stripped out.
355355

356356
```js
357-
parse('<br>\n', { trim: true }); // React.createElement('br')
357+
parse('<table>\n</table>'); // [React.createElement('table')]
358358
```
359359

360-
This fixes the warning:
360+
To remove whitespace, enable the `trim` option:
361361

362-
```
363-
Warning: validateDOMNesting(...): Whitespace text nodes cannot appear as a child of <table>. Make sure you don't have any extra whitespace between tags on each line of your source code.
362+
```js
363+
parse('<br>\n', { trim: true }); // React.createElement('br')
364364
```
365365

366366
However, intentional whitespace may be stripped out:
@@ -427,10 +427,6 @@ parse('<div /><div />'); // returns single element instead of array of elements
427427

428428
See [#158](https://github.com/remarkablemark/html-react-parser/issues/158).
429429

430-
### Warning: validateDOMNesting(...): Whitespace text nodes cannot appear as a child of table
431-
432-
Enable the [trim](#trim) option. See [#155](https://github.com/remarkablemark/html-react-parser/issues/155).
433-
434430
### Don't change case of tags
435431

436432
Tags are lowercased by default. To prevent that from happening, pass the [htmlparser2 option](#htmlparser2):

0 commit comments

Comments
 (0)