Skip to content

Commit ddcdf9f

Browse files
committed
Expose htmlparser2
1 parent 9de3651 commit ddcdf9f

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ yarn add react-html-parser
2121

2222
```javascript
2323
import React from 'react';
24-
import ReactHtmlParser, { processNodes, convertNodeToElement } from 'react-html-parser';
24+
import ReactHtmlParser, { processNodes, convertNodeToElement, htmlparser2 } from 'react-html-parser';
2525

2626
class HtmlComponent extends React.Component {
2727
render() {
@@ -118,4 +118,10 @@ function transform(node, index) {
118118
return convertNodeToElement(node, index, transform);
119119
}
120120
}
121-
```
121+
```
122+
123+
### `htmlparser2`
124+
The library exposes the `htmlparser2` library it uses. This allows consumers
125+
to use it without having to add it as a separate dependency.
126+
127+
See https://github.com/fb55/htmlparser2 for full details.

src/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@ export default HtmlParser;
33

44
export { default as processNodes } from './processNodes';
55
export { default as convertNodeToElement } from './convertNodeToElement';
6+
7+
// expose htmlparser2 so it can be used if required
8+
export { default as htmlparser2 } from 'htmlparser2';

test/integration/integration.spec.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,4 +185,8 @@ describe('Integration tests: ', () => {
185185
);
186186
});
187187

188+
it('should expose htmlparser2', () => {
189+
expect(htmlparser2).toBeDefined();
190+
});
191+
188192
});

0 commit comments

Comments
 (0)