1 | var domToReact = require('./lib/dom-to-react');
|
2 | var attributesToProps = require('./lib/attributes-to-props');
|
3 | var htmlToDOM = require('html-dom-parser');
|
4 |
|
5 | var domParserOptions = { lowerCaseAttributeNames: false };
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | function HTMLReactParser(html, options) {
|
18 | if (typeof html !== 'string') {
|
19 | throw new TypeError('First argument must be a string');
|
20 | }
|
21 | if (html === '') {
|
22 | return [];
|
23 | }
|
24 | options = options || {};
|
25 | return domToReact(
|
26 | htmlToDOM(html, options.htmlparser2 || domParserOptions),
|
27 | options
|
28 | );
|
29 | }
|
30 |
|
31 | HTMLReactParser.domToReact = domToReact;
|
32 | HTMLReactParser.htmlToDOM = htmlToDOM;
|
33 | HTMLReactParser.attributesToProps = attributesToProps;
|
34 |
|
35 |
|
36 | module.exports = HTMLReactParser;
|
37 | module.exports.default = HTMLReactParser;
|