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 |
|
6 | htmlToDOM =
|
7 |
|
8 | typeof htmlToDOM.default === 'function' ? htmlToDOM.default : htmlToDOM;
|
9 |
|
10 | var domParserOptions = { lowerCaseAttributeNames: false };
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 | function HTMLReactParser(html, options) {
|
23 | if (typeof html !== 'string') {
|
24 | throw new TypeError('First argument must be a string');
|
25 | }
|
26 | if (html === '') {
|
27 | return [];
|
28 | }
|
29 | options = options || {};
|
30 | return domToReact(
|
31 | htmlToDOM(html, options.htmlparser2 || domParserOptions),
|
32 | options
|
33 | );
|
34 | }
|
35 |
|
36 | HTMLReactParser.domToReact = domToReact;
|
37 | HTMLReactParser.htmlToDOM = htmlToDOM;
|
38 | HTMLReactParser.attributesToProps = attributesToProps;
|
39 | HTMLReactParser.Element = require('domhandler/lib/node').Element;
|
40 |
|
41 |
|
42 | module.exports = HTMLReactParser;
|
43 | module.exports.default = HTMLReactParser;
|