Skip to content

Commit 78da4d4

Browse files
docs(readme): update instructions for htmlparser2 options
1 parent 80bbea0 commit 78da4d4

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

README.md

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ HTML output:
286286

287287
### library
288288

289-
This option specifies the library that creates elements. The default library is **React**.
289+
The `library` option specifies the UI library. The default library is **React**.
290290

291291
To use Preact:
292292

@@ -316,17 +316,11 @@ parse('<br>', {
316316

317317
### htmlparser2
318318

319-
Along with the default [htmlparser2 options](https://github.com/fb55/htmlparser2/wiki/Parser-options#option-xmlmode), the parser also sets:
319+
> `htmlparser2` options **do not work on the client-side** (browser) and **only works on the server-side** (Node.js). By overriding `htmlparser2` options, universal rendering can break.
320320
321-
```json
322-
{
323-
"lowerCaseAttributeNames": false
324-
}
325-
```
321+
Default [htmlparser2 options](https://github.com/fb55/htmlparser2/wiki/Parser-options#option-xmlmode) can be overridden in >=[0.12.0](https://github.com/remarkablemark/html-react-parser/tree/v0.12.0).
326322

327-
Since [v0.12.0](https://github.com/remarkablemark/html-react-parser/tree/v0.12.0), the htmlparser2 options can be overridden.
328-
329-
The following example enables [`xmlMode`](https://github.com/fb55/htmlparser2/wiki/Parser-options#option-xmlmode) but disables [`lowerCaseAttributeNames`](https://github.com/fb55/htmlparser2/wiki/Parser-options#option-lowercaseattributenames):
323+
To enable [`xmlMode`](https://github.com/fb55/htmlparser2/wiki/Parser-options#option-xmlmode):
330324

331325
```js
332326
parse('<p /><p />', {
@@ -336,17 +330,15 @@ parse('<p /><p />', {
336330
});
337331
```
338332

339-
> **WARNING**: `htmlparser2` options do not apply on the _client-side_ (browser). The options only apply on the _server-side_ (Node.js). By overriding `htmlparser2` options, universal rendering can break. Do this at your own risk.
340-
341333
### trim
342334

343-
Normally, whitespace is preserved:
335+
By default, whitespace is preserved:
344336

345337
```js
346338
parse('<br>\n'); // [React.createElement('br'), '\n']
347339
```
348340

349-
Enable the `trim` option to remove whitespace:
341+
To remove whitespace, enable the `trim` option:
350342

351343
```js
352344
parse('<br>\n', { trim: true }); // React.createElement('br')

0 commit comments

Comments
 (0)