html-react-parser 0.6.0 → 0.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +38 -2
- package/README.md +97 -84
- package/dist/html-react-parser.js +2 -2
- package/dist/html-react-parser.min.js +1 -1
- package/lib/dom-to-react.js +3 -1
- package/lib/utilities.js +1 -1
- package/package.json +24 -19
- package/types/index.d.ts +40 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,8 +2,44 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
<a name="0.6.4"></a>
|
|
6
|
+
## [0.6.4](https://github.com/remarkablemark/html-react-parser/compare/v0.6.3...v0.6.4) (2019-03-29)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **dom-to-react:** allow custom keys for replacement ([abf20a2](https://github.com/remarkablemark/html-react-parser/commit/abf20a2))
|
|
12
|
+
* **dom-to-react:** fix typos in the test ([4eec53e](https://github.com/remarkablemark/html-react-parser/commit/4eec53e))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
<a name="0.6.3"></a>
|
|
17
|
+
## [0.6.3](https://github.com/remarkablemark/html-react-parser/compare/v0.6.2...v0.6.3) (2019-03-19)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* **typescript:** test.tsx after dtslint run ([38e6bba](https://github.com/remarkablemark/html-react-parser/commit/38e6bba))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
<a name="0.6.2"></a>
|
|
27
|
+
## [0.6.2](https://github.com/remarkablemark/html-react-parser/compare/v0.6.1...v0.6.2) (2019-03-07)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
<a name="0.6.1"></a>
|
|
32
|
+
## [0.6.1](https://github.com/remarkablemark/html-react-parser/compare/v0.6.0...v0.6.1) (2019-01-03)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
### Bug Fixes
|
|
36
|
+
|
|
37
|
+
* **utilities:** allow numbers in custom style names ([5a6600f](https://github.com/remarkablemark/html-react-parser/commit/5a6600f))
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
5
41
|
<a name="0.6.0"></a>
|
|
6
|
-
|
|
42
|
+
## [0.6.0](https://github.com/remarkablemark/html-react-parser/compare/v0.5.0...v0.6.0) (2018-12-17)
|
|
7
43
|
|
|
8
44
|
|
|
9
45
|
### Features
|
|
@@ -13,7 +49,7 @@ All notable changes to this project will be documented in this file. See [standa
|
|
|
13
49
|
|
|
14
50
|
|
|
15
51
|
<a name="0.5.0"></a>
|
|
16
|
-
|
|
52
|
+
## [0.5.0](https://github.com/remarkablemark/html-react-parser/compare/v0.4.7...v0.5.0) (2018-12-16)
|
|
17
53
|
|
|
18
54
|
|
|
19
55
|
### Bug Fixes
|
package/README.md
CHANGED
|
@@ -7,38 +7,41 @@
|
|
|
7
7
|
[](https://coveralls.io/github/remarkablemark/html-react-parser?branch=master)
|
|
8
8
|
[](https://david-dm.org/remarkablemark/html-react-parser)
|
|
9
9
|
|
|
10
|
-
An HTML to React parser that works on the server and the browser:
|
|
10
|
+
An HTML to React parser that works on both the server and the browser:
|
|
11
|
+
|
|
11
12
|
```
|
|
12
13
|
HTMLReactParser(htmlString[, options])
|
|
13
14
|
```
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
There's also an [option](#options) to [replace](#replacedomnode) elements with your own custom React elements.
|
|
16
|
+
The parser converts an HTML string to [React element(s)](https://reactjs.org/docs/react-api.html#creating-react-elements). If you want to [replace an element](#replacedomnode) with your own custom element, there's an [option](#options) to do that.
|
|
18
17
|
|
|
19
|
-
|
|
18
|
+
Example:
|
|
20
19
|
|
|
21
20
|
```js
|
|
22
|
-
var
|
|
23
|
-
|
|
24
|
-
// same output as `React.createElement('p', {}, 'Hello, world!')`
|
|
21
|
+
var parse = require('html-react-parser');
|
|
22
|
+
parse('<div>text</div>'); // equivalent to `React.createElement('div', {}, 'text')`
|
|
25
23
|
```
|
|
26
24
|
|
|
27
|
-
[JSFiddle](https://jsfiddle.net/remarkablemark/7v86d800/) | [repl.it](https://repl.it/@remarkablemark/html-react-parser)
|
|
25
|
+
[CodeSandbox](https://codesandbox.io/s/940pov1l4w) | [JSFiddle](https://jsfiddle.net/remarkablemark/7v86d800/) | [repl.it](https://repl.it/@remarkablemark/html-react-parser)
|
|
26
|
+
|
|
27
|
+
See [usage](#usage) and [examples](https://github.com/remarkablemark/html-react-parser/tree/master/examples).
|
|
28
28
|
|
|
29
29
|
## Installation
|
|
30
30
|
|
|
31
31
|
[NPM](https://www.npmjs.com/package/html-react-parser):
|
|
32
|
+
|
|
32
33
|
```sh
|
|
33
34
|
$ npm install html-react-parser --save
|
|
34
35
|
```
|
|
35
36
|
|
|
36
|
-
[Yarn](https://
|
|
37
|
+
[Yarn](https://yarnpkg.com/package/html-react-parser):
|
|
38
|
+
|
|
37
39
|
```sh
|
|
38
40
|
$ yarn add html-react-parser
|
|
39
41
|
```
|
|
40
42
|
|
|
41
|
-
[
|
|
43
|
+
[unpkg](https://unpkg.com/html-react-parser/) (CDN):
|
|
44
|
+
|
|
42
45
|
```html
|
|
43
46
|
<!-- HTMLReactParser depends on React -->
|
|
44
47
|
<script src="https://unpkg.com/react@16/umd/react.production.min.js"></script>
|
|
@@ -48,56 +51,50 @@ $ yarn add html-react-parser
|
|
|
48
51
|
</script>
|
|
49
52
|
```
|
|
50
53
|
|
|
51
|
-
See more [examples](https://github.com/remarkablemark/html-react-parser/tree/master/examples).
|
|
52
|
-
|
|
53
54
|
## Usage
|
|
54
55
|
|
|
55
|
-
Given you have
|
|
56
|
+
Given you have `html-react-parser` imported:
|
|
57
|
+
|
|
56
58
|
```js
|
|
57
59
|
// ES Modules
|
|
58
|
-
import
|
|
59
|
-
import { render } from 'react-dom';
|
|
60
|
+
import parse from 'html-react-parser';
|
|
60
61
|
```
|
|
61
62
|
|
|
62
|
-
|
|
63
|
+
Parse single element:
|
|
64
|
+
|
|
63
65
|
```js
|
|
64
|
-
|
|
65
|
-
Parser('<h1>single</h1>'),
|
|
66
|
-
document.getElementById('root')
|
|
67
|
-
);
|
|
66
|
+
parse('<h1>single</h1>');
|
|
68
67
|
```
|
|
69
68
|
|
|
70
|
-
|
|
69
|
+
Parse multiple elements:
|
|
70
|
+
|
|
71
71
|
```js
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
// the parser returns an array for adjacent elements
|
|
75
|
-
// so make sure they're nested under a parent React element
|
|
76
|
-
<div>{Parser('<p>brother</p><p>sister</p>')}</div>,
|
|
77
|
-
document.getElementById('root')
|
|
78
|
-
);
|
|
72
|
+
parse('<p>sibling 1</p><p>sibling 2</p>');
|
|
73
|
+
```
|
|
79
74
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
75
|
+
Because the parser returns an array for adjacent elements, make sure it's nested under a parent element when rendered:
|
|
76
|
+
|
|
77
|
+
```jsx
|
|
78
|
+
import React, { Component } from 'react';
|
|
79
|
+
import parse from 'html-react-parser';
|
|
80
|
+
|
|
81
|
+
class App extends Component {
|
|
82
|
+
render() {
|
|
83
|
+
return <div>{parse('<p>sibling 1</p><p>sibling 2</p>')}</div>;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
85
86
|
```
|
|
86
87
|
|
|
87
|
-
|
|
88
|
+
Parse nested elements:
|
|
89
|
+
|
|
88
90
|
```js
|
|
89
|
-
|
|
90
|
-
Parser('<ul><li>inside</li></ul>'),
|
|
91
|
-
document.getElementById('root')
|
|
92
|
-
);
|
|
91
|
+
parse('<ul><li>text</li></ul>');
|
|
93
92
|
```
|
|
94
93
|
|
|
95
|
-
|
|
94
|
+
Parse element with attributes:
|
|
95
|
+
|
|
96
96
|
```js
|
|
97
|
-
|
|
98
|
-
Parser('<p id="foo" class="bar baz" data-qux="42">look at me now</p>'),
|
|
99
|
-
document.getElementById('root')
|
|
100
|
-
);
|
|
97
|
+
parse('<hr id="foo" class="bar" data-baz="qux">');
|
|
101
98
|
```
|
|
102
99
|
|
|
103
100
|
### Options
|
|
@@ -106,12 +103,12 @@ render(
|
|
|
106
103
|
|
|
107
104
|
The `replace` method allows you to swap an element with your own React element.
|
|
108
105
|
|
|
109
|
-
The first argument is `domNode
|
|
106
|
+
The first argument is `domNode`―an object with the same output as [htmlparser2](https://github.com/fb55/htmlparser2)'s [domhandler](https://github.com/fb55/domhandler#example).
|
|
110
107
|
|
|
111
108
|
The element is replaced only if a valid React element is returned.
|
|
112
109
|
|
|
113
110
|
```js
|
|
114
|
-
|
|
111
|
+
parse('<p id="replace">text</p>', {
|
|
115
112
|
replace: function(domNode) {
|
|
116
113
|
if (domNode.attribs && domNode.attribs.id === 'replace') {
|
|
117
114
|
return React.createElement('span', {}, 'replaced');
|
|
@@ -120,63 +117,77 @@ Parser('<p id="replace">text</p>', {
|
|
|
120
117
|
});
|
|
121
118
|
```
|
|
122
119
|
|
|
123
|
-
|
|
120
|
+
The following [example](https://repl.it/@remarkablemark/html-react-parser-replace-example) uses `replace` to modify the children:
|
|
121
|
+
|
|
124
122
|
```jsx
|
|
125
|
-
|
|
123
|
+
import React from 'react';
|
|
124
|
+
import { renderToStaticMarkup } from 'react-dom/server';
|
|
125
|
+
import parse from 'html-react-parser';
|
|
126
126
|
import domToReact from 'html-react-parser/lib/dom-to-react';
|
|
127
127
|
|
|
128
|
-
const
|
|
128
|
+
const elements = parse(
|
|
129
|
+
`
|
|
129
130
|
<p id="main">
|
|
130
131
|
<span class="prettify">
|
|
131
132
|
keep me and make me pretty!
|
|
132
133
|
</span>
|
|
133
134
|
</p>
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
)
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
135
|
+
`,
|
|
136
|
+
{
|
|
137
|
+
replace: ({ attribs, children }) => {
|
|
138
|
+
if (!attribs) return;
|
|
139
|
+
|
|
140
|
+
if (attribs.id === 'main') {
|
|
141
|
+
return (
|
|
142
|
+
<h1 style={{ fontSize: 42 }}>
|
|
143
|
+
{domToReact(children, parserOptions)}
|
|
144
|
+
</h1>
|
|
145
|
+
);
|
|
146
|
+
} else if (attribs.class === 'prettify') {
|
|
147
|
+
return (
|
|
148
|
+
<span style={{ color: 'hotpink' }}>
|
|
149
|
+
{domToReact(children, parserOptions)}
|
|
150
|
+
</span>
|
|
151
|
+
);
|
|
152
|
+
}
|
|
152
153
|
}
|
|
153
154
|
}
|
|
154
|
-
|
|
155
|
+
);
|
|
155
156
|
|
|
156
|
-
|
|
157
|
-
ReactDOMServer.renderToStaticMarkup(reactElement);
|
|
157
|
+
console.log(renderToStaticMarkup(elements));
|
|
158
158
|
```
|
|
159
159
|
|
|
160
|
-
|
|
160
|
+
The output:
|
|
161
|
+
|
|
161
162
|
```html
|
|
162
163
|
<h1 style="font-size:42px">
|
|
163
|
-
<span style="color:hotpink">
|
|
164
|
-
keep me and make me pretty!
|
|
165
|
-
</span>
|
|
164
|
+
<span style="color:hotpink">keep me and make me pretty!</span>
|
|
166
165
|
</h1>
|
|
167
166
|
```
|
|
168
167
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
}
|
|
176
|
-
},
|
|
168
|
+
The following [example](https://repl.it/@remarkablemark/html-react-parser-issue-56) uses `replace` to exclude an element:
|
|
169
|
+
|
|
170
|
+
```jsx
|
|
171
|
+
parse('<p><br id="remove"></p>', {
|
|
172
|
+
replace: ({ attribs }) =>
|
|
173
|
+
attribs && attribs.id === 'remove' && <React.Fragment />
|
|
177
174
|
});
|
|
178
175
|
```
|
|
179
176
|
|
|
177
|
+
## FAQ
|
|
178
|
+
|
|
179
|
+
#### Is the library XSS safe?
|
|
180
|
+
|
|
181
|
+
No, this library does **_not_** sanitize against [XSS (Cross-Site Scripting)](https://wikipedia.org/wiki/Cross-site_scripting). See [#94](https://github.com/remarkablemark/html-react-parser/issues/94).
|
|
182
|
+
|
|
183
|
+
#### Are `<script>` tags parsed?
|
|
184
|
+
|
|
185
|
+
Although `<script>` tags are parsed, [react-dom](https://reactjs.org/docs/react-dom.html) does not render the contents. See [#98](https://github.com/remarkablemark/html-react-parser/issues/98).
|
|
186
|
+
|
|
187
|
+
#### My HTML attributes aren't getting called.
|
|
188
|
+
|
|
189
|
+
That's because [inline event handlers](https://developer.mozilla.org/docs/Web/Guide/Events/Event_handlers) like `onclick` are parsed as a _string_ rather than a _function_. See [#73](https://github.com/remarkablemark/html-react-parser/issues/73).
|
|
190
|
+
|
|
180
191
|
## Testing
|
|
181
192
|
|
|
182
193
|
```sh
|
|
@@ -191,6 +202,7 @@ $ npm run test:benchmark
|
|
|
191
202
|
```
|
|
192
203
|
|
|
193
204
|
Here's an example output of the benchmarks run on a MacBook Pro 2017:
|
|
205
|
+
|
|
194
206
|
```
|
|
195
207
|
html-to-react - Single x 415,186 ops/sec ±0.92% (85 runs sampled)
|
|
196
208
|
html-to-react - Multiple x 139,780 ops/sec ±2.32% (87 runs sampled)
|
|
@@ -199,10 +211,11 @@ html-to-react - Complex x 8,118 ops/sec ±2.99% (82 runs sampled)
|
|
|
199
211
|
|
|
200
212
|
## Release
|
|
201
213
|
|
|
214
|
+
Only collaborators with credentials can release and publish:
|
|
215
|
+
|
|
202
216
|
```sh
|
|
203
217
|
$ npm run release
|
|
204
|
-
$ npm publish
|
|
205
|
-
$ git push --follow-tags
|
|
218
|
+
$ git push --follow-tags && npm publish
|
|
206
219
|
```
|
|
207
220
|
|
|
208
221
|
## Special Thanks
|
|
@@ -125,7 +125,7 @@ eval("var DOMProperty = __webpack_require__(/*! react-dom-core/lib/DOMProperty *
|
|
|
125
125
|
/*! no static exports found */
|
|
126
126
|
/***/ (function(module, exports, __webpack_require__) {
|
|
127
127
|
|
|
128
|
-
eval("var React = __webpack_require__(/*! react */ \"react\");\nvar attributesToProps = __webpack_require__(/*! ./attributes-to-props */ \"./lib/attributes-to-props.js\");\nvar utilities = __webpack_require__(/*! ./utilities */ \"./lib/utilities.js\");\n\n/**\n * Converts DOM nodes to React elements.\n *\n * @param {Array} nodes - The DOM nodes.\n * @param {Object} [options] - The additional options.\n * @param {Function} [options.replace] - The replace method.\n * @return {ReactElement|Array}\n */\nfunction domToReact(nodes, options) {\n options = options || {};\n var result = [];\n var node;\n var isReplacePresent = typeof options.replace === 'function';\n var replacement;\n var props;\n var children;\n\n for (var i = 0, len = nodes.length; i < len; i++) {\n node = nodes[i];\n\n // replace with custom React element (if applicable)\n if (isReplacePresent) {\n replacement = options.replace(node);\n\n if (React.isValidElement(replacement)) {\n // specify a \"key\" prop if element has siblings\n // https://fb.me/react-warning-keys\n if (len > 1) {\n replacement = React.cloneElement(replacement, {
|
|
128
|
+
eval("var React = __webpack_require__(/*! react */ \"react\");\nvar attributesToProps = __webpack_require__(/*! ./attributes-to-props */ \"./lib/attributes-to-props.js\");\nvar utilities = __webpack_require__(/*! ./utilities */ \"./lib/utilities.js\");\n\n/**\n * Converts DOM nodes to React elements.\n *\n * @param {Array} nodes - The DOM nodes.\n * @param {Object} [options] - The additional options.\n * @param {Function} [options.replace] - The replace method.\n * @return {ReactElement|Array}\n */\nfunction domToReact(nodes, options) {\n options = options || {};\n var result = [];\n var node;\n var isReplacePresent = typeof options.replace === 'function';\n var replacement;\n var props;\n var children;\n\n for (var i = 0, len = nodes.length; i < len; i++) {\n node = nodes[i];\n\n // replace with custom React element (if applicable)\n if (isReplacePresent) {\n replacement = options.replace(node);\n\n if (React.isValidElement(replacement)) {\n // specify a \"key\" prop if element has siblings\n // https://fb.me/react-warning-keys\n if (len > 1) {\n replacement = React.cloneElement(replacement, {\n key: replacement.key || i\n });\n }\n result.push(replacement);\n continue;\n }\n }\n\n if (node.type === 'text') {\n result.push(node.data);\n continue;\n }\n\n props = node.attribs;\n if (!shouldPassAttributesUnaltered(node)) {\n // update values\n props = attributesToProps(node.attribs);\n }\n\n children = null;\n\n // node type for <script> is \"script\"\n // node type for <style> is \"style\"\n if (node.type === 'script' || node.type === 'style') {\n // prevent text in <script> or <style> from being escaped\n // https://facebook.github.io/react/tips/dangerously-set-inner-html.html\n if (node.children[0]) {\n props.dangerouslySetInnerHTML = {\n __html: node.children[0].data\n };\n }\n } else if (node.type === 'tag') {\n // setting textarea value in children is an antipattern in React\n // https://reactjs.org/docs/forms.html#the-textarea-tag\n if (node.name === 'textarea' && node.children[0]) {\n props.defaultValue = node.children[0].data;\n\n // continue recursion of creating React elements (if applicable)\n } else if (node.children && node.children.length) {\n children = domToReact(node.children, options);\n }\n\n // skip all other cases (e.g., comment)\n } else {\n continue;\n }\n\n // specify a \"key\" prop if element has siblings\n // https://fb.me/react-warning-keys\n if (len > 1) {\n props.key = i;\n }\n\n result.push(React.createElement(node.name, props, children));\n }\n\n return result.length === 1 ? result[0] : result;\n}\n\nfunction shouldPassAttributesUnaltered(node) {\n return (\n utilities.PRESERVE_CUSTOM_ATTRIBUTES &&\n node.type === 'tag' &&\n utilities.isCustomComponent(node.name, node.attribs)\n );\n}\n\nmodule.exports = domToReact;\n\n\n//# sourceURL=webpack://HTMLReactParser/./lib/dom-to-react.js?");
|
|
129
129
|
|
|
130
130
|
/***/ }),
|
|
131
131
|
|
|
@@ -147,7 +147,7 @@ eval("var HTMLDOMPropertyConfig = __webpack_require__(/*! react-dom-core/lib/HTM
|
|
|
147
147
|
/*! no static exports found */
|
|
148
148
|
/***/ (function(module, exports, __webpack_require__) {
|
|
149
149
|
|
|
150
|
-
eval("var React = __webpack_require__(/*! react */ \"react\");\nvar hyphenPatternRegex = /-([a-z])/g;\nvar CUSTOM_PROPERTY_OR_NO_HYPHEN_REGEX = /^--[a-zA-
|
|
150
|
+
eval("var React = __webpack_require__(/*! react */ \"react\");\nvar hyphenPatternRegex = /-([a-z])/g;\nvar CUSTOM_PROPERTY_OR_NO_HYPHEN_REGEX = /^--[a-zA-Z0-9-]+$|^[^-]+$/;\n\n/**\n * Converts a string to camelCase.\n *\n * @param {String} string - The string.\n * @return {String}\n */\nfunction camelCase(string) {\n if (typeof string !== 'string') {\n throw new TypeError('First argument must be a string');\n }\n\n // custom property or no hyphen found\n if (CUSTOM_PROPERTY_OR_NO_HYPHEN_REGEX.test(string)) {\n return string;\n }\n\n // convert to camelCase\n return string\n .toLowerCase()\n .replace(hyphenPatternRegex, function(_, character) {\n return character.toUpperCase();\n });\n}\n\n/**\n * Swap key with value in an object.\n *\n * @param {Object} obj - The object.\n * @param {Function} [override] - The override method.\n * @return {Object} - The inverted object.\n */\nfunction invertObject(obj, override) {\n if (!obj || typeof obj !== 'object') {\n throw new TypeError('First argument must be an object');\n }\n\n var key;\n var value;\n var isOverridePresent = typeof override === 'function';\n var overrides = {};\n var result = {};\n\n for (key in obj) {\n value = obj[key];\n\n if (isOverridePresent) {\n overrides = override(key, value);\n if (overrides && overrides.length === 2) {\n result[overrides[0]] = overrides[1];\n continue;\n }\n }\n\n if (typeof value === 'string') {\n result[value] = key;\n }\n }\n\n return result;\n}\n\n/**\n * Check if a given tag is a custom component.\n *\n * @see {@link https://github.com/facebook/react/blob/v16.6.3/packages/react-dom/src/shared/isCustomComponent.js}\n *\n * @param {string} tagName - The name of the html tag.\n * @param {Object} props - The props being passed to the element.\n * @return {boolean}\n */\nfunction isCustomComponent(tagName, props) {\n if (tagName.indexOf('-') === -1) {\n return props && typeof props.is === 'string';\n }\n\n switch (tagName) {\n // These are reserved SVG and MathML elements.\n // We don't mind this whitelist too much because we expect it to never grow.\n // The alternative is to track the namespace in a few places which is convoluted.\n // https://w3c.github.io/webcomponents/spec/custom/#custom-elements-core-concepts\n case 'annotation-xml':\n case 'color-profile':\n case 'font-face':\n case 'font-face-src':\n case 'font-face-uri':\n case 'font-face-format':\n case 'font-face-name':\n case 'missing-glyph':\n return false;\n default:\n return true;\n }\n}\n\n/**\n * @constant {Boolean}\n * @see {@link https://reactjs.org/blog/2017/09/08/dom-attributes-in-react-16.html}\n */\nvar PRESERVE_CUSTOM_ATTRIBUTES = React.version.split('.')[0] >= 16;\n\nmodule.exports = {\n PRESERVE_CUSTOM_ATTRIBUTES: PRESERVE_CUSTOM_ATTRIBUTES,\n camelCase: camelCase,\n invertObject: invertObject,\n isCustomComponent: isCustomComponent\n};\n\n\n//# sourceURL=webpack://HTMLReactParser/./lib/utilities.js?");
|
|
151
151
|
|
|
152
152
|
/***/ }),
|
|
153
153
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):"object"==typeof exports?exports.HTMLReactParser=t(require("react")):e.HTMLReactParser=t(e.React)}(window,function(e){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=4)}([function(e,t,r){var n=/-([a-z])/g,i=/^--[a-zA-Z-]+$|^[^-]+$/;var o=r(1).version.split(".")[0]>=16;e.exports={PRESERVE_CUSTOM_ATTRIBUTES:o,camelCase:function(e){if("string"!=typeof e)throw new TypeError("First argument must be a string");return i.test(e)?e:e.toLowerCase().replace(n,function(e,t){return t.toUpperCase()})},invertObject:function(e,t){if(!e||"object"!=typeof e)throw new TypeError("First argument must be an object");var r,n,i="function"==typeof t,o={},a={};for(r in e)n=e[r],i&&(o=t(r,n))&&2===o.length?a[o[0]]=o[1]:"string"==typeof n&&(a[n]=r);return a},isCustomComponent:function(e,t){if(-1===e.indexOf("-"))return t&&"string"==typeof t.is;switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}}},function(t,r){t.exports=e},function(e,t,r){"use strict";var n=r(7);r(8);function i(e,t){return(e&t)===t}var o={MUST_USE_PROPERTY:1,HAS_BOOLEAN_VALUE:4,HAS_NUMERIC_VALUE:8,HAS_POSITIVE_NUMERIC_VALUE:24,HAS_OVERLOADED_BOOLEAN_VALUE:32,injectDOMPropertyConfig:function(e){var t=o,r=e.Properties||{},a=e.DOMAttributeNamespaces||{},u=e.DOMAttributeNames||{},c=e.DOMPropertyNames||{},l=e.DOMMutationMethods||{};for(var p in e.isCustomAttribute&&s._isCustomAttributeFunctions.push(e.isCustomAttribute),r){s.properties.hasOwnProperty(p)&&n("48",p);var f=p.toLowerCase(),m=r[p],d={attributeName:f,attributeNamespace:null,propertyName:p,mutationMethod:null,mustUseProperty:i(m,t.MUST_USE_PROPERTY),hasBooleanValue:i(m,t.HAS_BOOLEAN_VALUE),hasNumericValue:i(m,t.HAS_NUMERIC_VALUE),hasPositiveNumericValue:i(m,t.HAS_POSITIVE_NUMERIC_VALUE),hasOverloadedBooleanValue:i(m,t.HAS_OVERLOADED_BOOLEAN_VALUE)};if(d.hasBooleanValue+d.hasNumericValue+d.hasOverloadedBooleanValue<=1||n("50",p),u.hasOwnProperty(p)){var h=u[p];d.attributeName=h}a.hasOwnProperty(p)&&(d.attributeNamespace=a[p]),c.hasOwnProperty(p)&&(d.propertyName=c[p]),l.hasOwnProperty(p)&&(d.mutationMethod=l[p]),s.properties[p]=d}}},a=":A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",s={ID_ATTRIBUTE_NAME:"data-reactid",ROOT_ATTRIBUTE_NAME:"data-reactroot",ATTRIBUTE_NAME_START_CHAR:a,ATTRIBUTE_NAME_CHAR:a+"\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040",properties:{},getPossibleStandardName:null,_isCustomAttributeFunctions:[],isCustomAttribute:function(e){for(var t=0;t<s._isCustomAttributeFunctions.length;t++){if((0,s._isCustomAttributeFunctions[t])(e))return!0}return!1},injection:o};e.exports=s},function(e,t,r){"use strict";function n(e){for(var t,r={},n=0,i=e.length;n<i;n++)r[(t=e[n]).name]=t.value;return r}e.exports={formatAttributes:n,formatDOM:function e(t,r,i){r=r||null;for(var o,a,s,u=[],c=0,l=t.length;c<l;c++){switch(o=t[c],s={next:null,prev:u[c-1]||null,parent:r},(a=u[c-1])&&(a.next=s),0!==o.nodeName.indexOf("#")&&(s.name=o.nodeName.toLowerCase(),s.attribs={},o.attributes&&o.attributes.length&&(s.attribs=n(o.attributes))),o.nodeType){case 1:"script"===s.name||"style"===s.name?s.type=s.name:s.type="tag",s.children=e(o.childNodes,s);break;case 3:s.type="text",s.data=o.nodeValue;break;case 8:s.type="comment",s.data=o.nodeValue}u.push(s)}return i&&(u.unshift({name:i.substring(0,i.indexOf(" ")).toLowerCase(),data:i,type:"directive",next:u[0]?u[0]:null,prev:null,parent:r}),u[1]&&(u[1].prev=u[0])),u},isIE:function(e){return e?document.documentMode===e:/(MSIE |Trident\/|Edge\/)/.test(navigator.userAgent)}}},function(e,t,r){var n=r(5),i=r(14),o={decodeEntities:!0,lowerCaseAttributeNames:!1};e.exports=function(e,t){if("string"!=typeof e)throw new TypeError("First argument must be a string");return n(i(e,o),t)}},function(e,t,r){var n=r(1),i=r(6),o=r(0);function a(e){return o.PRESERVE_CUSTOM_ATTRIBUTES&&"tag"===e.type&&o.isCustomComponent(e.name,e.attribs)}e.exports=function e(t,r){for(var o,s,u,c,l=[],p="function"==typeof(r=r||{}).replace,f=0,m=t.length;f<m;f++)if(o=t[f],p&&(s=r.replace(o),n.isValidElement(s)))m>1&&(s=n.cloneElement(s,{key:f})),l.push(s);else if("text"!==o.type){if(u=o.attribs,a(o)||(u=i(o.attribs)),c=null,"script"===o.type||"style"===o.type)o.children[0]&&(u.dangerouslySetInnerHTML={__html:o.children[0].data});else{if("tag"!==o.type)continue;"textarea"===o.name&&o.children[0]?u.defaultValue=o.children[0].data:o.children&&o.children.length&&(c=e(o.children,r))}m>1&&(u.key=f),l.push(n.createElement(o.name,u,c))}else l.push(o.data);return 1===l.length?l[0]:l}},function(e,t,r){var n=r(2),i=r(9),o=r(12),a=r(0),s=i.config,u=i.HTMLDOMPropertyConfig.isCustomAttribute;n.injection.injectDOMPropertyConfig(i.HTMLDOMPropertyConfig),e.exports=function(e){e=e||{};var t,r,i,c={};for(t in e)r=e[t],u(t)?c[t]=r:(i=s.html[t.toLowerCase()])?n.properties.hasOwnProperty(i)&&n.properties[i].hasBooleanValue?c[i]=!0:c[i]=r:(i=s.svg[t])?c[i]=r:a.PRESERVE_CUSTOM_ATTRIBUTES&&(c[t]=r);return null!=e.style&&(c.style=function(e){if("string"!=typeof e)throw new TypeError("First argument must be a string.");var t={};return o(e,function(e,r){e&&r&&(t[a.camelCase(e)]=r)}),t}(e.style)),c}},function(e,t,r){"use strict";e.exports=function(e){for(var t=arguments.length-1,r="Minified React error #"+e+"; visit http://facebook.github.io/react/docs/error-decoder.html?invariant="+e,n=0;n<t;n++)r+="&args[]="+encodeURIComponent(arguments[n+1]);r+=" for the full message or use the non-minified dev environment for full errors and additional helpful warnings.";var i=new Error(r);throw i.name="Invariant Violation",i.framesToPop=1,i}},function(e,t,r){"use strict";var n=function(e){};e.exports=function(e,t,r,i,o,a,s,u){if(n(t),!e){var c;if(void 0===t)c=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var l=[r,i,o,a,s,u],p=0;(c=new Error(t.replace(/%s/g,function(){return l[p++]}))).name="Invariant Violation"}throw c.framesToPop=1,c}}},function(e,t,r){var n,i=r(10),o=r(11),a=r(0),s={html:{},svg:{}};for(n in s.html=a.invertObject(i.DOMAttributeNames),i.Properties)s.html[n.toLowerCase()]=n;for(n in s.svg=a.invertObject(o.DOMAttributeNames),o.Properties)s.html[n]=n;e.exports={config:s,HTMLDOMPropertyConfig:i,SVGDOMPropertyConfig:o}},function(e,t,r){"use strict";var n=r(2),i=n.injection.MUST_USE_PROPERTY,o=n.injection.HAS_BOOLEAN_VALUE,a=n.injection.HAS_NUMERIC_VALUE,s=n.injection.HAS_POSITIVE_NUMERIC_VALUE,u=n.injection.HAS_OVERLOADED_BOOLEAN_VALUE,c={isCustomAttribute:RegExp.prototype.test.bind(new RegExp("^(data|aria)-["+n.ATTRIBUTE_NAME_CHAR+"]*$")),Properties:{accept:0,acceptCharset:0,accessKey:0,action:0,allowFullScreen:o,allowTransparency:0,alt:0,as:0,async:o,autoComplete:0,autoPlay:o,capture:o,cellPadding:0,cellSpacing:0,charSet:0,challenge:0,checked:i|o,cite:0,classID:0,className:0,cols:s,colSpan:0,content:0,contentEditable:0,contextMenu:0,controls:o,controlsList:0,coords:0,crossOrigin:0,data:0,dateTime:0,default:o,defer:o,dir:0,disabled:o,download:u,draggable:0,encType:0,form:0,formAction:0,formEncType:0,formMethod:0,formNoValidate:o,formTarget:0,frameBorder:0,headers:0,height:0,hidden:o,high:0,href:0,hrefLang:0,htmlFor:0,httpEquiv:0,icon:0,id:0,inputMode:0,integrity:0,is:0,keyParams:0,keyType:0,kind:0,label:0,lang:0,list:0,loop:o,low:0,manifest:0,marginHeight:0,marginWidth:0,max:0,maxLength:0,media:0,mediaGroup:0,method:0,min:0,minLength:0,multiple:i|o,muted:i|o,name:0,nonce:0,noValidate:o,open:o,optimum:0,pattern:0,placeholder:0,playsInline:o,poster:0,preload:0,profile:0,radioGroup:0,readOnly:o,referrerPolicy:0,rel:0,required:o,reversed:o,role:0,rows:s,rowSpan:a,sandbox:0,scope:0,scoped:o,scrolling:0,seamless:o,selected:i|o,shape:0,size:s,sizes:0,span:s,spellCheck:0,src:0,srcDoc:0,srcLang:0,srcSet:0,start:a,step:0,style:0,summary:0,tabIndex:0,target:0,title:0,type:0,useMap:0,value:0,width:0,wmode:0,wrap:0,about:0,datatype:0,inlist:0,prefix:0,property:0,resource:0,typeof:0,vocab:0,autoCapitalize:0,autoCorrect:0,autoSave:0,color:0,itemProp:0,itemScope:o,itemType:0,itemID:0,itemRef:0,results:0,security:0,unselectable:0},DOMAttributeNames:{acceptCharset:"accept-charset",className:"class",htmlFor:"for",httpEquiv:"http-equiv"},DOMPropertyNames:{},DOMMutationMethods:{value:function(e,t){if(null==t)return e.removeAttribute("value");"number"!==e.type||!1===e.hasAttribute("value")?e.setAttribute("value",""+t):e.validity&&!e.validity.badInput&&e.ownerDocument.activeElement!==e&&e.setAttribute("value",""+t)}}};e.exports=c},function(e,t,r){"use strict";var n="http://www.w3.org/1999/xlink",i="http://www.w3.org/XML/1998/namespace",o={accentHeight:"accent-height",accumulate:0,additive:0,alignmentBaseline:"alignment-baseline",allowReorder:"allowReorder",alphabetic:0,amplitude:0,arabicForm:"arabic-form",ascent:0,attributeName:"attributeName",attributeType:"attributeType",autoReverse:"autoReverse",azimuth:0,baseFrequency:"baseFrequency",baseProfile:"baseProfile",baselineShift:"baseline-shift",bbox:0,begin:0,bias:0,by:0,calcMode:"calcMode",capHeight:"cap-height",clip:0,clipPath:"clip-path",clipRule:"clip-rule",clipPathUnits:"clipPathUnits",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",contentScriptType:"contentScriptType",contentStyleType:"contentStyleType",cursor:0,cx:0,cy:0,d:0,decelerate:0,descent:0,diffuseConstant:"diffuseConstant",direction:0,display:0,divisor:0,dominantBaseline:"dominant-baseline",dur:0,dx:0,dy:0,edgeMode:"edgeMode",elevation:0,enableBackground:"enable-background",end:0,exponent:0,externalResourcesRequired:"externalResourcesRequired",fill:0,fillOpacity:"fill-opacity",fillRule:"fill-rule",filter:0,filterRes:"filterRes",filterUnits:"filterUnits",floodColor:"flood-color",floodOpacity:"flood-opacity",focusable:0,fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",format:0,from:0,fx:0,fy:0,g1:0,g2:0,glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",glyphRef:"glyphRef",gradientTransform:"gradientTransform",gradientUnits:"gradientUnits",hanging:0,horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",ideographic:0,imageRendering:"image-rendering",in:0,in2:0,intercept:0,k:0,k1:0,k2:0,k3:0,k4:0,kernelMatrix:"kernelMatrix",kernelUnitLength:"kernelUnitLength",kerning:0,keyPoints:"keyPoints",keySplines:"keySplines",keyTimes:"keyTimes",lengthAdjust:"lengthAdjust",letterSpacing:"letter-spacing",lightingColor:"lighting-color",limitingConeAngle:"limitingConeAngle",local:0,markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",markerHeight:"markerHeight",markerUnits:"markerUnits",markerWidth:"markerWidth",mask:0,maskContentUnits:"maskContentUnits",maskUnits:"maskUnits",mathematical:0,mode:0,numOctaves:"numOctaves",offset:0,opacity:0,operator:0,order:0,orient:0,orientation:0,origin:0,overflow:0,overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pathLength:"pathLength",patternContentUnits:"patternContentUnits",patternTransform:"patternTransform",patternUnits:"patternUnits",pointerEvents:"pointer-events",points:0,pointsAtX:"pointsAtX",pointsAtY:"pointsAtY",pointsAtZ:"pointsAtZ",preserveAlpha:"preserveAlpha",preserveAspectRatio:"preserveAspectRatio",primitiveUnits:"primitiveUnits",r:0,radius:0,refX:"refX",refY:"refY",renderingIntent:"rendering-intent",repeatCount:"repeatCount",repeatDur:"repeatDur",requiredExtensions:"requiredExtensions",requiredFeatures:"requiredFeatures",restart:0,result:0,rotate:0,rx:0,ry:0,scale:0,seed:0,shapeRendering:"shape-rendering",slope:0,spacing:0,specularConstant:"specularConstant",specularExponent:"specularExponent",speed:0,spreadMethod:"spreadMethod",startOffset:"startOffset",stdDeviation:"stdDeviation",stemh:0,stemv:0,stitchTiles:"stitchTiles",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",string:0,stroke:0,strokeDasharray:"stroke-dasharray",strokeDashoffset:"stroke-dashoffset",strokeLinecap:"stroke-linecap",strokeLinejoin:"stroke-linejoin",strokeMiterlimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",surfaceScale:"surfaceScale",systemLanguage:"systemLanguage",tableValues:"tableValues",targetX:"targetX",targetY:"targetY",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",textLength:"textLength",to:0,transform:0,u1:0,u2:0,underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicode:0,unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",values:0,vectorEffect:"vector-effect",version:0,vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",viewBox:"viewBox",viewTarget:"viewTarget",visibility:0,widths:0,wordSpacing:"word-spacing",writingMode:"writing-mode",x:0,xHeight:"x-height",x1:0,x2:0,xChannelSelector:"xChannelSelector",xlinkActuate:"xlink:actuate",xlinkArcrole:"xlink:arcrole",xlinkHref:"xlink:href",xlinkRole:"xlink:role",xlinkShow:"xlink:show",xlinkTitle:"xlink:title",xlinkType:"xlink:type",xmlBase:"xml:base",xmlns:0,xmlnsXlink:"xmlns:xlink",xmlLang:"xml:lang",xmlSpace:"xml:space",y:0,y1:0,y2:0,yChannelSelector:"yChannelSelector",z:0,zoomAndPan:"zoomAndPan"},a={Properties:{},DOMAttributeNamespaces:{xlinkActuate:n,xlinkArcrole:n,xlinkHref:n,xlinkRole:n,xlinkShow:n,xlinkTitle:n,xlinkType:n,xmlBase:i,xmlLang:i,xmlSpace:i},DOMAttributeNames:{}};Object.keys(o).forEach(function(e){a.Properties[e]=0,o[e]&&(a.DOMAttributeNames[e]=o[e])}),e.exports=a},function(e,t,r){var n=r(13);e.exports=function(e,t){if(!e||"string"!=typeof e)return null;for(var r,i,o,a=n("p{"+e+"}").stylesheet.rules[0].declarations,s=null,u="function"==typeof t,c=0,l=a.length;c<l;c++)i=(r=a[c]).property,o=r.value,u?t(i,o,r):o&&(s||(s={}),s[i]=o);return s}},function(e,t){var r=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g;function n(e){return e?e.replace(/^\s+|\s+$/g,""):""}e.exports=function(e,t){t=t||{};var i=1,o=1;function a(e){var t=e.match(/\n/g);t&&(i+=t.length);var r=e.lastIndexOf("\n");o=~r?e.length-r:o+e.length}function s(){var e={line:i,column:o};return function(t){return t.position=new u(e),h(),t}}function u(e){this.start=e,this.end={line:i,column:o},this.source=t.source}u.prototype.content=e;var c=[];function l(r){var n=new Error(t.source+":"+i+":"+o+": "+r);if(n.reason=r,n.filename=t.source,n.line=i,n.column=o,n.source=e,!t.silent)throw n;c.push(n)}function p(){return d(/^{\s*/)}function f(){return d(/^}/)}function m(){var t,r=[];for(h(),g(r);e.length&&"}"!=e.charAt(0)&&(t=w()||M());)!1!==t&&(r.push(t),g(r));return r}function d(t){var r=t.exec(e);if(r){var n=r[0];return a(n),e=e.slice(n.length),r}}function h(){d(/^\s*/)}function g(e){var t;for(e=e||[];t=y();)!1!==t&&e.push(t);return e}function y(){var t=s();if("/"==e.charAt(0)&&"*"==e.charAt(1)){for(var r=2;""!=e.charAt(r)&&("*"!=e.charAt(r)||"/"!=e.charAt(r+1));)++r;if(r+=2,""===e.charAt(r-1))return l("End of comment missing");var n=e.slice(2,r-2);return o+=2,a(n),e=e.slice(r),o+=2,t({type:"comment",comment:n})}}function v(){var e=d(/^([^{]+)/);if(e)return n(e[0]).replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*\/+/g,"").replace(/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'/g,function(e){return e.replace(/,/g,"")}).split(/\s*(?![^(]*\)),\s*/).map(function(e){return e.replace(/\u200C/g,",")})}function b(){var e=s(),t=d(/^(\*?[-#\/\*\\\w]+(\[[0-9a-z_-]+\])?)\s*/);if(t){if(t=n(t[0]),!d(/^:\s*/))return l("property missing ':'");var i=d(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)/),o=e({type:"declaration",property:t.replace(r,""),value:i?n(i[0]).replace(r,""):""});return d(/^[;\s]*/),o}}function x(){var e,t=[];if(!p())return l("missing '{'");for(g(t);e=b();)!1!==e&&(t.push(e),g(t));return f()?t:l("missing '}'")}function A(){for(var e,t=[],r=s();e=d(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/);)t.push(e[1]),d(/^,\s*/);if(t.length)return r({type:"keyframe",values:t,declarations:x()})}var E=O("import"),k=O("charset"),T=O("namespace");function O(e){var t=new RegExp("^@"+e+"\\s*([^;]+);");return function(){var r=s(),n=d(t);if(n){var i={type:e};return i[e]=n[1].trim(),r(i)}}}function w(){if("@"==e[0])return function(){var e=s();if(t=d(/^@([-\w]+)?keyframes\s*/)){var t,r=t[1];if(!(t=d(/^([-\w]+)\s*/)))return l("@keyframes missing name");var n,i=t[1];if(!p())return l("@keyframes missing '{'");for(var o=g();n=A();)o.push(n),o=o.concat(g());return f()?e({type:"keyframes",name:i,vendor:r,keyframes:o}):l("@keyframes missing '}'")}}()||function(){var e=s(),t=d(/^@media *([^{]+)/);if(t){var r=n(t[1]);if(!p())return l("@media missing '{'");var i=g().concat(m());return f()?e({type:"media",media:r,rules:i}):l("@media missing '}'")}}()||function(){var e=s(),t=d(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/);if(t)return e({type:"custom-media",name:n(t[1]),media:n(t[2])})}()||function(){var e=s(),t=d(/^@supports *([^{]+)/);if(t){var r=n(t[1]);if(!p())return l("@supports missing '{'");var i=g().concat(m());return f()?e({type:"supports",supports:r,rules:i}):l("@supports missing '}'")}}()||E()||k()||T()||function(){var e=s(),t=d(/^@([-\w]+)?document *([^{]+)/);if(t){var r=n(t[1]),i=n(t[2]);if(!p())return l("@document missing '{'");var o=g().concat(m());return f()?e({type:"document",document:i,vendor:r,rules:o}):l("@document missing '}'")}}()||function(){var e=s();if(d(/^@page */)){var t=v()||[];if(!p())return l("@page missing '{'");for(var r,n=g();r=b();)n.push(r),n=n.concat(g());return f()?e({type:"page",selectors:t,declarations:n}):l("@page missing '}'")}}()||function(){var e=s();if(d(/^@host\s*/)){if(!p())return l("@host missing '{'");var t=g().concat(m());return f()?e({type:"host",rules:t}):l("@host missing '}'")}}()||function(){var e=s();if(d(/^@font-face\s*/)){if(!p())return l("@font-face missing '{'");for(var t,r=g();t=b();)r.push(t),r=r.concat(g());return f()?e({type:"font-face",declarations:r}):l("@font-face missing '}'")}}()}function M(){var e=s(),t=v();return t?(g(),e({type:"rule",selectors:t,declarations:x()})):l("selector missing")}return function e(t,r){var n=t&&"string"==typeof t.type;var i=n?t:r;for(var o in t){var a=t[o];Array.isArray(a)?a.forEach(function(t){e(t,i)}):a&&"object"==typeof a&&e(a,i)}n&&Object.defineProperty(t,"parent",{configurable:!0,writable:!0,enumerable:!1,value:r||null});return t}(function(){var e=m();return{type:"stylesheet",stylesheet:{source:t.source,rules:e,parsingErrors:c}}}())}},function(e,t,r){"use strict";var n=r(15),i=r(3),o=i.formatDOM,a=i.isIE(9),s=/<(![a-zA-Z\s]+)>/;e.exports=function(e){if("string"!=typeof e)throw new TypeError("First argument must be a string.");if(!e)return[];var t,r=e.match(s);return r&&r[1]&&(t=r[1],a&&(e=e.replace(r[0],""))),o(n(e),null,t)}},function(e,t,r){"use strict";var n,i,o,a=r(3).isIE,s=/<([a-zA-Z]+[0-9]?)/,u=/<\/head>/i,c=/<\/body>/i,l=/<(area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)(.*?)\/?>/gi,p=a(),f=a(9);if("function"==typeof window.DOMParser){var m=new window.DOMParser,d=f?"text/xml":"text/html";n=function(e,t){return t&&(e=["<",t,">",e,"</",t,">"].join("")),f&&(e=e.replace(l,"<$1$2$3/>")),m.parseFromString(e,d)}}if("object"==typeof document.implementation){var h=document.implementation.createHTMLDocument(p?"HTML_DOM_PARSER_TITLE":void 0);i=function(e,t){if(t)return h.documentElement.getElementsByTagName(t)[0].innerHTML=e,h;try{return h.documentElement.innerHTML=e,h}catch(t){if(n)return n(e)}}}var g=document.createElement("template");g.content&&(o=function(e){return g.innerHTML=e,g.content.childNodes});var y=i||n;e.exports=function(e){var t,r,i,a,l=e.match(s);switch(l&&l[1]&&(t=l[1].toLowerCase()),t){case"html":if(n)return r=n(e),u.test(e)||(i=r.getElementsByTagName("head")[0])&&i.parentNode.removeChild(i),c.test(e)||(i=r.getElementsByTagName("body")[0])&&i.parentNode.removeChild(i),r.getElementsByTagName("html");break;case"head":if(y)return a=y(e).getElementsByTagName("head"),c.test(e)?a[0].parentNode.childNodes:a;break;case"body":if(y)return a=y(e).getElementsByTagName("body"),u.test(e)?a[0].parentNode.childNodes:a;break;default:if(o)return o(e);if(y)return y(e,"body").getElementsByTagName("body")[0].childNodes}return[]}}])});
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):"object"==typeof exports?exports.HTMLReactParser=t(require("react")):e.HTMLReactParser=t(e.React)}(window,function(e){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=4)}([function(e,t,r){var n=r(1),i=/-([a-z])/g,o=/^--[a-zA-Z0-9-]+$|^[^-]+$/;var a=n.version.split(".")[0]>=16;e.exports={PRESERVE_CUSTOM_ATTRIBUTES:a,camelCase:function(e){if("string"!=typeof e)throw new TypeError("First argument must be a string");return o.test(e)?e:e.toLowerCase().replace(i,function(e,t){return t.toUpperCase()})},invertObject:function(e,t){if(!e||"object"!=typeof e)throw new TypeError("First argument must be an object");var r,n,i="function"==typeof t,o={},a={};for(r in e)n=e[r],i&&(o=t(r,n))&&2===o.length?a[o[0]]=o[1]:"string"==typeof n&&(a[n]=r);return a},isCustomComponent:function(e,t){if(-1===e.indexOf("-"))return t&&"string"==typeof t.is;switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}}},function(t,r){t.exports=e},function(e,t,r){"use strict";var n=r(7);r(8);function i(e,t){return(e&t)===t}var o={MUST_USE_PROPERTY:1,HAS_BOOLEAN_VALUE:4,HAS_NUMERIC_VALUE:8,HAS_POSITIVE_NUMERIC_VALUE:24,HAS_OVERLOADED_BOOLEAN_VALUE:32,injectDOMPropertyConfig:function(e){var t=o,r=e.Properties||{},a=e.DOMAttributeNamespaces||{},u=e.DOMAttributeNames||{},l=e.DOMPropertyNames||{},c=e.DOMMutationMethods||{};for(var p in e.isCustomAttribute&&s._isCustomAttributeFunctions.push(e.isCustomAttribute),r){s.properties.hasOwnProperty(p)&&n("48",p);var f=p.toLowerCase(),m=r[p],d={attributeName:f,attributeNamespace:null,propertyName:p,mutationMethod:null,mustUseProperty:i(m,t.MUST_USE_PROPERTY),hasBooleanValue:i(m,t.HAS_BOOLEAN_VALUE),hasNumericValue:i(m,t.HAS_NUMERIC_VALUE),hasPositiveNumericValue:i(m,t.HAS_POSITIVE_NUMERIC_VALUE),hasOverloadedBooleanValue:i(m,t.HAS_OVERLOADED_BOOLEAN_VALUE)};if(d.hasBooleanValue+d.hasNumericValue+d.hasOverloadedBooleanValue<=1||n("50",p),u.hasOwnProperty(p)){var h=u[p];d.attributeName=h}a.hasOwnProperty(p)&&(d.attributeNamespace=a[p]),l.hasOwnProperty(p)&&(d.propertyName=l[p]),c.hasOwnProperty(p)&&(d.mutationMethod=c[p]),s.properties[p]=d}}},a=":A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",s={ID_ATTRIBUTE_NAME:"data-reactid",ROOT_ATTRIBUTE_NAME:"data-reactroot",ATTRIBUTE_NAME_START_CHAR:a,ATTRIBUTE_NAME_CHAR:a+"\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040",properties:{},getPossibleStandardName:null,_isCustomAttributeFunctions:[],isCustomAttribute:function(e){for(var t=0;t<s._isCustomAttributeFunctions.length;t++){if((0,s._isCustomAttributeFunctions[t])(e))return!0}return!1},injection:o};e.exports=s},function(e,t,r){"use strict";function n(e){for(var t,r={},n=0,i=e.length;n<i;n++)r[(t=e[n]).name]=t.value;return r}e.exports={formatAttributes:n,formatDOM:function e(t,r,i){r=r||null;for(var o,a,s,u=[],l=0,c=t.length;l<c;l++){switch(o=t[l],s={next:null,prev:u[l-1]||null,parent:r},(a=u[l-1])&&(a.next=s),0!==o.nodeName.indexOf("#")&&(s.name=o.nodeName.toLowerCase(),s.attribs={},o.attributes&&o.attributes.length&&(s.attribs=n(o.attributes))),o.nodeType){case 1:"script"===s.name||"style"===s.name?s.type=s.name:s.type="tag",s.children=e(o.childNodes,s);break;case 3:s.type="text",s.data=o.nodeValue;break;case 8:s.type="comment",s.data=o.nodeValue}u.push(s)}return i&&(u.unshift({name:i.substring(0,i.indexOf(" ")).toLowerCase(),data:i,type:"directive",next:u[0]?u[0]:null,prev:null,parent:r}),u[1]&&(u[1].prev=u[0])),u},isIE:function(e){return e?document.documentMode===e:/(MSIE |Trident\/|Edge\/)/.test(navigator.userAgent)}}},function(e,t,r){var n=r(5),i=r(14),o={decodeEntities:!0,lowerCaseAttributeNames:!1};e.exports=function(e,t){if("string"!=typeof e)throw new TypeError("First argument must be a string");return n(i(e,o),t)}},function(e,t,r){var n=r(1),i=r(6),o=r(0);function a(e){return o.PRESERVE_CUSTOM_ATTRIBUTES&&"tag"===e.type&&o.isCustomComponent(e.name,e.attribs)}e.exports=function e(t,r){for(var o,s,u,l,c=[],p="function"==typeof(r=r||{}).replace,f=0,m=t.length;f<m;f++)if(o=t[f],p&&(s=r.replace(o),n.isValidElement(s)))m>1&&(s=n.cloneElement(s,{key:s.key||f})),c.push(s);else if("text"!==o.type){if(u=o.attribs,a(o)||(u=i(o.attribs)),l=null,"script"===o.type||"style"===o.type)o.children[0]&&(u.dangerouslySetInnerHTML={__html:o.children[0].data});else{if("tag"!==o.type)continue;"textarea"===o.name&&o.children[0]?u.defaultValue=o.children[0].data:o.children&&o.children.length&&(l=e(o.children,r))}m>1&&(u.key=f),c.push(n.createElement(o.name,u,l))}else c.push(o.data);return 1===c.length?c[0]:c}},function(e,t,r){var n=r(2),i=r(9),o=r(12),a=r(0),s=i.config,u=i.HTMLDOMPropertyConfig.isCustomAttribute;n.injection.injectDOMPropertyConfig(i.HTMLDOMPropertyConfig),e.exports=function(e){e=e||{};var t,r,i,l={};for(t in e)r=e[t],u(t)?l[t]=r:(i=s.html[t.toLowerCase()])?n.properties.hasOwnProperty(i)&&n.properties[i].hasBooleanValue?l[i]=!0:l[i]=r:(i=s.svg[t])?l[i]=r:a.PRESERVE_CUSTOM_ATTRIBUTES&&(l[t]=r);return null!=e.style&&(l.style=function(e){if("string"!=typeof e)throw new TypeError("First argument must be a string.");var t={};return o(e,function(e,r){e&&r&&(t[a.camelCase(e)]=r)}),t}(e.style)),l}},function(e,t,r){"use strict";e.exports=function(e){for(var t=arguments.length-1,r="Minified React error #"+e+"; visit http://facebook.github.io/react/docs/error-decoder.html?invariant="+e,n=0;n<t;n++)r+="&args[]="+encodeURIComponent(arguments[n+1]);r+=" for the full message or use the non-minified dev environment for full errors and additional helpful warnings.";var i=new Error(r);throw i.name="Invariant Violation",i.framesToPop=1,i}},function(e,t,r){"use strict";var n=function(e){};e.exports=function(e,t,r,i,o,a,s,u){if(n(t),!e){var l;if(void 0===t)l=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var c=[r,i,o,a,s,u],p=0;(l=new Error(t.replace(/%s/g,function(){return c[p++]}))).name="Invariant Violation"}throw l.framesToPop=1,l}}},function(e,t,r){var n,i=r(10),o=r(11),a=r(0),s={html:{},svg:{}};for(n in s.html=a.invertObject(i.DOMAttributeNames),i.Properties)s.html[n.toLowerCase()]=n;for(n in s.svg=a.invertObject(o.DOMAttributeNames),o.Properties)s.html[n]=n;e.exports={config:s,HTMLDOMPropertyConfig:i,SVGDOMPropertyConfig:o}},function(e,t,r){"use strict";var n=r(2),i=n.injection.MUST_USE_PROPERTY,o=n.injection.HAS_BOOLEAN_VALUE,a=n.injection.HAS_NUMERIC_VALUE,s=n.injection.HAS_POSITIVE_NUMERIC_VALUE,u=n.injection.HAS_OVERLOADED_BOOLEAN_VALUE,l={isCustomAttribute:RegExp.prototype.test.bind(new RegExp("^(data|aria)-["+n.ATTRIBUTE_NAME_CHAR+"]*$")),Properties:{accept:0,acceptCharset:0,accessKey:0,action:0,allowFullScreen:o,allowTransparency:0,alt:0,as:0,async:o,autoComplete:0,autoPlay:o,capture:o,cellPadding:0,cellSpacing:0,charSet:0,challenge:0,checked:i|o,cite:0,classID:0,className:0,cols:s,colSpan:0,content:0,contentEditable:0,contextMenu:0,controls:o,controlsList:0,coords:0,crossOrigin:0,data:0,dateTime:0,default:o,defer:o,dir:0,disabled:o,download:u,draggable:0,encType:0,form:0,formAction:0,formEncType:0,formMethod:0,formNoValidate:o,formTarget:0,frameBorder:0,headers:0,height:0,hidden:o,high:0,href:0,hrefLang:0,htmlFor:0,httpEquiv:0,icon:0,id:0,inputMode:0,integrity:0,is:0,keyParams:0,keyType:0,kind:0,label:0,lang:0,list:0,loop:o,low:0,manifest:0,marginHeight:0,marginWidth:0,max:0,maxLength:0,media:0,mediaGroup:0,method:0,min:0,minLength:0,multiple:i|o,muted:i|o,name:0,nonce:0,noValidate:o,open:o,optimum:0,pattern:0,placeholder:0,playsInline:o,poster:0,preload:0,profile:0,radioGroup:0,readOnly:o,referrerPolicy:0,rel:0,required:o,reversed:o,role:0,rows:s,rowSpan:a,sandbox:0,scope:0,scoped:o,scrolling:0,seamless:o,selected:i|o,shape:0,size:s,sizes:0,span:s,spellCheck:0,src:0,srcDoc:0,srcLang:0,srcSet:0,start:a,step:0,style:0,summary:0,tabIndex:0,target:0,title:0,type:0,useMap:0,value:0,width:0,wmode:0,wrap:0,about:0,datatype:0,inlist:0,prefix:0,property:0,resource:0,typeof:0,vocab:0,autoCapitalize:0,autoCorrect:0,autoSave:0,color:0,itemProp:0,itemScope:o,itemType:0,itemID:0,itemRef:0,results:0,security:0,unselectable:0},DOMAttributeNames:{acceptCharset:"accept-charset",className:"class",htmlFor:"for",httpEquiv:"http-equiv"},DOMPropertyNames:{},DOMMutationMethods:{value:function(e,t){if(null==t)return e.removeAttribute("value");"number"!==e.type||!1===e.hasAttribute("value")?e.setAttribute("value",""+t):e.validity&&!e.validity.badInput&&e.ownerDocument.activeElement!==e&&e.setAttribute("value",""+t)}}};e.exports=l},function(e,t,r){"use strict";var n="http://www.w3.org/1999/xlink",i="http://www.w3.org/XML/1998/namespace",o={accentHeight:"accent-height",accumulate:0,additive:0,alignmentBaseline:"alignment-baseline",allowReorder:"allowReorder",alphabetic:0,amplitude:0,arabicForm:"arabic-form",ascent:0,attributeName:"attributeName",attributeType:"attributeType",autoReverse:"autoReverse",azimuth:0,baseFrequency:"baseFrequency",baseProfile:"baseProfile",baselineShift:"baseline-shift",bbox:0,begin:0,bias:0,by:0,calcMode:"calcMode",capHeight:"cap-height",clip:0,clipPath:"clip-path",clipRule:"clip-rule",clipPathUnits:"clipPathUnits",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",contentScriptType:"contentScriptType",contentStyleType:"contentStyleType",cursor:0,cx:0,cy:0,d:0,decelerate:0,descent:0,diffuseConstant:"diffuseConstant",direction:0,display:0,divisor:0,dominantBaseline:"dominant-baseline",dur:0,dx:0,dy:0,edgeMode:"edgeMode",elevation:0,enableBackground:"enable-background",end:0,exponent:0,externalResourcesRequired:"externalResourcesRequired",fill:0,fillOpacity:"fill-opacity",fillRule:"fill-rule",filter:0,filterRes:"filterRes",filterUnits:"filterUnits",floodColor:"flood-color",floodOpacity:"flood-opacity",focusable:0,fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",format:0,from:0,fx:0,fy:0,g1:0,g2:0,glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",glyphRef:"glyphRef",gradientTransform:"gradientTransform",gradientUnits:"gradientUnits",hanging:0,horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",ideographic:0,imageRendering:"image-rendering",in:0,in2:0,intercept:0,k:0,k1:0,k2:0,k3:0,k4:0,kernelMatrix:"kernelMatrix",kernelUnitLength:"kernelUnitLength",kerning:0,keyPoints:"keyPoints",keySplines:"keySplines",keyTimes:"keyTimes",lengthAdjust:"lengthAdjust",letterSpacing:"letter-spacing",lightingColor:"lighting-color",limitingConeAngle:"limitingConeAngle",local:0,markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",markerHeight:"markerHeight",markerUnits:"markerUnits",markerWidth:"markerWidth",mask:0,maskContentUnits:"maskContentUnits",maskUnits:"maskUnits",mathematical:0,mode:0,numOctaves:"numOctaves",offset:0,opacity:0,operator:0,order:0,orient:0,orientation:0,origin:0,overflow:0,overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pathLength:"pathLength",patternContentUnits:"patternContentUnits",patternTransform:"patternTransform",patternUnits:"patternUnits",pointerEvents:"pointer-events",points:0,pointsAtX:"pointsAtX",pointsAtY:"pointsAtY",pointsAtZ:"pointsAtZ",preserveAlpha:"preserveAlpha",preserveAspectRatio:"preserveAspectRatio",primitiveUnits:"primitiveUnits",r:0,radius:0,refX:"refX",refY:"refY",renderingIntent:"rendering-intent",repeatCount:"repeatCount",repeatDur:"repeatDur",requiredExtensions:"requiredExtensions",requiredFeatures:"requiredFeatures",restart:0,result:0,rotate:0,rx:0,ry:0,scale:0,seed:0,shapeRendering:"shape-rendering",slope:0,spacing:0,specularConstant:"specularConstant",specularExponent:"specularExponent",speed:0,spreadMethod:"spreadMethod",startOffset:"startOffset",stdDeviation:"stdDeviation",stemh:0,stemv:0,stitchTiles:"stitchTiles",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",string:0,stroke:0,strokeDasharray:"stroke-dasharray",strokeDashoffset:"stroke-dashoffset",strokeLinecap:"stroke-linecap",strokeLinejoin:"stroke-linejoin",strokeMiterlimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",surfaceScale:"surfaceScale",systemLanguage:"systemLanguage",tableValues:"tableValues",targetX:"targetX",targetY:"targetY",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",textLength:"textLength",to:0,transform:0,u1:0,u2:0,underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicode:0,unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",values:0,vectorEffect:"vector-effect",version:0,vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",viewBox:"viewBox",viewTarget:"viewTarget",visibility:0,widths:0,wordSpacing:"word-spacing",writingMode:"writing-mode",x:0,xHeight:"x-height",x1:0,x2:0,xChannelSelector:"xChannelSelector",xlinkActuate:"xlink:actuate",xlinkArcrole:"xlink:arcrole",xlinkHref:"xlink:href",xlinkRole:"xlink:role",xlinkShow:"xlink:show",xlinkTitle:"xlink:title",xlinkType:"xlink:type",xmlBase:"xml:base",xmlns:0,xmlnsXlink:"xmlns:xlink",xmlLang:"xml:lang",xmlSpace:"xml:space",y:0,y1:0,y2:0,yChannelSelector:"yChannelSelector",z:0,zoomAndPan:"zoomAndPan"},a={Properties:{},DOMAttributeNamespaces:{xlinkActuate:n,xlinkArcrole:n,xlinkHref:n,xlinkRole:n,xlinkShow:n,xlinkTitle:n,xlinkType:n,xmlBase:i,xmlLang:i,xmlSpace:i},DOMAttributeNames:{}};Object.keys(o).forEach(function(e){a.Properties[e]=0,o[e]&&(a.DOMAttributeNames[e]=o[e])}),e.exports=a},function(e,t,r){var n=r(13);e.exports=function(e,t){if(!e||"string"!=typeof e)return null;for(var r,i,o,a=n("p{"+e+"}").stylesheet.rules[0].declarations,s=null,u="function"==typeof t,l=0,c=a.length;l<c;l++)i=(r=a[l]).property,o=r.value,u?t(i,o,r):o&&(s||(s={}),s[i]=o);return s}},function(e,t){var r=/\/\*[^*]*\*+([^\/*][^*]*\*+)*\//g;function n(e){return e?e.replace(/^\s+|\s+$/g,""):""}e.exports=function(e,t){t=t||{};var i=1,o=1;function a(e){var t=e.match(/\n/g);t&&(i+=t.length);var r=e.lastIndexOf("\n");o=~r?e.length-r:o+e.length}function s(){var e={line:i,column:o};return function(t){return t.position=new u(e),h(),t}}function u(e){this.start=e,this.end={line:i,column:o},this.source=t.source}u.prototype.content=e;var l=[];function c(r){var n=new Error(t.source+":"+i+":"+o+": "+r);if(n.reason=r,n.filename=t.source,n.line=i,n.column=o,n.source=e,!t.silent)throw n;l.push(n)}function p(){return d(/^{\s*/)}function f(){return d(/^}/)}function m(){var t,r=[];for(h(),g(r);e.length&&"}"!=e.charAt(0)&&(t=M()||C());)!1!==t&&(r.push(t),g(r));return r}function d(t){var r=t.exec(e);if(r){var n=r[0];return a(n),e=e.slice(n.length),r}}function h(){d(/^\s*/)}function g(e){var t;for(e=e||[];t=y();)!1!==t&&e.push(t);return e}function y(){var t=s();if("/"==e.charAt(0)&&"*"==e.charAt(1)){for(var r=2;""!=e.charAt(r)&&("*"!=e.charAt(r)||"/"!=e.charAt(r+1));)++r;if(r+=2,""===e.charAt(r-1))return c("End of comment missing");var n=e.slice(2,r-2);return o+=2,a(n),e=e.slice(r),o+=2,t({type:"comment",comment:n})}}function v(){var e=d(/^([^{]+)/);if(e)return n(e[0]).replace(/\/\*([^*]|[\r\n]|(\*+([^*\/]|[\r\n])))*\*\/+/g,"").replace(/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'/g,function(e){return e.replace(/,/g,"")}).split(/\s*(?![^(]*\)),\s*/).map(function(e){return e.replace(/\u200C/g,",")})}function b(){var e=s(),t=d(/^(\*?[-#\/\*\\\w]+(\[[0-9a-z_-]+\])?)\s*/);if(t){if(t=n(t[0]),!d(/^:\s*/))return c("property missing ':'");var i=d(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)/),o=e({type:"declaration",property:t.replace(r,""),value:i?n(i[0]).replace(r,""):""});return d(/^[;\s]*/),o}}function x(){var e,t=[];if(!p())return c("missing '{'");for(g(t);e=b();)!1!==e&&(t.push(e),g(t));return f()?t:c("missing '}'")}function A(){for(var e,t=[],r=s();e=d(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/);)t.push(e[1]),d(/^,\s*/);if(t.length)return r({type:"keyframe",values:t,declarations:x()})}var E,k=w("import"),T=w("charset"),O=w("namespace");function w(e){var t=new RegExp("^@"+e+"\\s*([^;]+);");return function(){var r=s(),n=d(t);if(n){var i={type:e};return i[e]=n[1].trim(),r(i)}}}function M(){if("@"==e[0])return function(){var e=s();if(t=d(/^@([-\w]+)?keyframes\s*/)){var t,r=t[1];if(!(t=d(/^([-\w]+)\s*/)))return c("@keyframes missing name");var n,i=t[1];if(!p())return c("@keyframes missing '{'");for(var o=g();n=A();)o.push(n),o=o.concat(g());return f()?e({type:"keyframes",name:i,vendor:r,keyframes:o}):c("@keyframes missing '}'")}}()||function(){var e=s(),t=d(/^@media *([^{]+)/);if(t){var r=n(t[1]);if(!p())return c("@media missing '{'");var i=g().concat(m());return f()?e({type:"media",media:r,rules:i}):c("@media missing '}'")}}()||function(){var e=s(),t=d(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/);if(t)return e({type:"custom-media",name:n(t[1]),media:n(t[2])})}()||function(){var e=s(),t=d(/^@supports *([^{]+)/);if(t){var r=n(t[1]);if(!p())return c("@supports missing '{'");var i=g().concat(m());return f()?e({type:"supports",supports:r,rules:i}):c("@supports missing '}'")}}()||k()||T()||O()||function(){var e=s(),t=d(/^@([-\w]+)?document *([^{]+)/);if(t){var r=n(t[1]),i=n(t[2]);if(!p())return c("@document missing '{'");var o=g().concat(m());return f()?e({type:"document",document:i,vendor:r,rules:o}):c("@document missing '}'")}}()||function(){var e=s();if(d(/^@page */)){var t=v()||[];if(!p())return c("@page missing '{'");for(var r,n=g();r=b();)n.push(r),n=n.concat(g());return f()?e({type:"page",selectors:t,declarations:n}):c("@page missing '}'")}}()||function(){var e=s();if(d(/^@host\s*/)){if(!p())return c("@host missing '{'");var t=g().concat(m());return f()?e({type:"host",rules:t}):c("@host missing '}'")}}()||function(){var e=s();if(d(/^@font-face\s*/)){if(!p())return c("@font-face missing '{'");for(var t,r=g();t=b();)r.push(t),r=r.concat(g());return f()?e({type:"font-face",declarations:r}):c("@font-face missing '}'")}}()}function C(){var e=s(),t=v();return t?(g(),e({type:"rule",selectors:t,declarations:x()})):c("selector missing")}return function e(t,r){var n=t&&"string"==typeof t.type;var i=n?t:r;for(var o in t){var a=t[o];Array.isArray(a)?a.forEach(function(t){e(t,i)}):a&&"object"==typeof a&&e(a,i)}n&&Object.defineProperty(t,"parent",{configurable:!0,writable:!0,enumerable:!1,value:r||null});return t}((E=m(),{type:"stylesheet",stylesheet:{source:t.source,rules:E,parsingErrors:l}}))}},function(e,t,r){"use strict";var n=r(15),i=r(3),o=i.formatDOM,a=i.isIE(9),s=/<(![a-zA-Z\s]+)>/;e.exports=function(e){if("string"!=typeof e)throw new TypeError("First argument must be a string.");if(!e)return[];var t,r=e.match(s);return r&&r[1]&&(t=r[1],a&&(e=e.replace(r[0],""))),o(n(e),null,t)}},function(e,t,r){"use strict";var n,i,o,a=r(3).isIE,s=/<([a-zA-Z]+[0-9]?)/,u=/<\/head>/i,l=/<\/body>/i,c=/<(area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)(.*?)\/?>/gi,p=a(),f=a(9);if("function"==typeof window.DOMParser){var m=new window.DOMParser,d=f?"text/xml":"text/html";n=function(e,t){return t&&(e=["<",t,">",e,"</",t,">"].join("")),f&&(e=e.replace(c,"<$1$2$3/>")),m.parseFromString(e,d)}}if("object"==typeof document.implementation){var h=document.implementation.createHTMLDocument(p?"HTML_DOM_PARSER_TITLE":void 0);i=function(e,t){if(t)return h.documentElement.getElementsByTagName(t)[0].innerHTML=e,h;try{return h.documentElement.innerHTML=e,h}catch(t){if(n)return n(e)}}}var g=document.createElement("template");g.content&&(o=function(e){return g.innerHTML=e,g.content.childNodes});var y=i||n;e.exports=function(e){var t,r,i,a,c=e.match(s);switch(c&&c[1]&&(t=c[1].toLowerCase()),t){case"html":if(n)return r=n(e),u.test(e)||(i=r.getElementsByTagName("head")[0])&&i.parentNode.removeChild(i),l.test(e)||(i=r.getElementsByTagName("body")[0])&&i.parentNode.removeChild(i),r.getElementsByTagName("html");break;case"head":if(y)return a=y(e).getElementsByTagName("head"),l.test(e)?a[0].parentNode.childNodes:a;break;case"body":if(y)return a=y(e).getElementsByTagName("body"),u.test(e)?a[0].parentNode.childNodes:a;break;default:if(o)return o(e);if(y)return y(e,"body").getElementsByTagName("body")[0].childNodes}return[]}}])});
|
package/lib/dom-to-react.js
CHANGED
|
@@ -30,7 +30,9 @@ function domToReact(nodes, options) {
|
|
|
30
30
|
// specify a "key" prop if element has siblings
|
|
31
31
|
// https://fb.me/react-warning-keys
|
|
32
32
|
if (len > 1) {
|
|
33
|
-
replacement = React.cloneElement(replacement, {
|
|
33
|
+
replacement = React.cloneElement(replacement, {
|
|
34
|
+
key: replacement.key || i
|
|
35
|
+
});
|
|
34
36
|
}
|
|
35
37
|
result.push(replacement);
|
|
36
38
|
continue;
|
package/lib/utilities.js
CHANGED
package/package.json
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "html-react-parser",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.4",
|
|
4
4
|
"description": "An HTML to React parser.",
|
|
5
5
|
"author": "Mark <mark@remarkablemark.org>",
|
|
6
6
|
"main": "index.js",
|
|
7
|
+
"types": "types",
|
|
7
8
|
"scripts": {
|
|
8
9
|
"benchmark": "node benchmark",
|
|
9
10
|
"build": "npm run clean && npm run build:min && npm run build:unmin",
|
|
10
|
-
"build:min": "NODE_ENV=production webpack -o dist/html-react-parser.min.js",
|
|
11
|
-
"build:unmin": "NODE_ENV=development webpack -o dist/html-react-parser.js",
|
|
12
|
-
"clean": "
|
|
13
|
-
"commitmsg": "commitlint -e $GIT_PARAMS",
|
|
11
|
+
"build:min": "cross-env NODE_ENV=production webpack -o dist/html-react-parser.min.js",
|
|
12
|
+
"build:unmin": "cross-env NODE_ENV=development webpack -o dist/html-react-parser.js",
|
|
13
|
+
"clean": "rimraf dist",
|
|
14
14
|
"cover": "istanbul cover _mocha -- -R spec \"test/**/*\"",
|
|
15
15
|
"coveralls": "cat coverage/lcov.info | coveralls",
|
|
16
16
|
"lint": "eslint --ignore-path .gitignore .",
|
|
17
17
|
"lint:fix": "npm run lint -- --fix",
|
|
18
|
-
"
|
|
18
|
+
"dtslint": "dtslint types",
|
|
19
19
|
"prepublishOnly": "npm run build",
|
|
20
20
|
"release": "standard-version --no-verify",
|
|
21
21
|
"test": "mocha"
|
|
@@ -36,33 +36,38 @@
|
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"html-dom-parser": "0.1.3",
|
|
39
|
-
"react-dom-core": "0.0.
|
|
39
|
+
"react-dom-core": "0.0.4",
|
|
40
40
|
"style-to-object": "0.2.2"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@commitlint/cli": "^7.1
|
|
43
|
+
"@commitlint/cli": "^7.2.1",
|
|
44
44
|
"@commitlint/config-conventional": "^7.1.2",
|
|
45
|
+
"@types/react": "16.8.8",
|
|
45
46
|
"benchmark": "2.1.4",
|
|
46
|
-
"coveralls": "^3.0.
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
47
|
+
"coveralls": "^3.0.2",
|
|
48
|
+
"cross-env": "5.2.0",
|
|
49
|
+
"dtslint": "0.5.5",
|
|
50
|
+
"eslint": "^5.10.0",
|
|
51
|
+
"eslint-plugin-prettier": "^3.0.0",
|
|
52
|
+
"husky": "^1.3.0",
|
|
50
53
|
"istanbul": "^0.4.5",
|
|
51
|
-
"lint-staged": "^
|
|
52
|
-
"mocha": "^5.0
|
|
53
|
-
"prettier": "^1.
|
|
54
|
+
"lint-staged": "^8.1.0",
|
|
55
|
+
"mocha": "^5.2.0",
|
|
56
|
+
"prettier": "^1.15.3",
|
|
54
57
|
"react": "^16",
|
|
55
58
|
"react-dom": "^16",
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"webpack
|
|
59
|
+
"rimraf": "2.6.3",
|
|
60
|
+
"standard-version": "^4.4.0",
|
|
61
|
+
"webpack": "^4.27.1",
|
|
62
|
+
"webpack-cli": "^3.1.2"
|
|
59
63
|
},
|
|
60
64
|
"peerDependencies": {
|
|
61
65
|
"react": "^0.14 || ^15 || ^16"
|
|
62
66
|
},
|
|
63
67
|
"files": [
|
|
64
68
|
"dist",
|
|
65
|
-
"lib"
|
|
69
|
+
"lib",
|
|
70
|
+
"types/index.d.ts"
|
|
66
71
|
],
|
|
67
72
|
"license": "MIT"
|
|
68
73
|
}
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// TypeScript Version: 3.3
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
|
|
5
|
+
export as namespace HTMLReactParser;
|
|
6
|
+
|
|
7
|
+
export default HTMLReactParser;
|
|
8
|
+
|
|
9
|
+
type ReactElement = React.DetailedReactHTMLElement<{}, HTMLElement>;
|
|
10
|
+
|
|
11
|
+
export interface HTMLReactParserOptions {
|
|
12
|
+
// TODO: Replace `object` by type for objects like `{ type: 'h1', props: { children: 'Heading' } }`
|
|
13
|
+
replace(domNode: DomNode): React.ReactElement | object | undefined | false;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Convert HTML string to React elements.
|
|
18
|
+
* @returns ReactElement on successful parse or string when `html` cannot be
|
|
19
|
+
* parsed as HTML
|
|
20
|
+
*/
|
|
21
|
+
declare function HTMLReactParser(
|
|
22
|
+
html: string,
|
|
23
|
+
options?: HTMLReactParserOptions
|
|
24
|
+
): ReactElement | ReactElement[] | string;
|
|
25
|
+
|
|
26
|
+
/** domhandler node */
|
|
27
|
+
export interface DomNode {
|
|
28
|
+
type: 'tag' | 'text' | 'directive' | 'comment' | 'script' | 'style';
|
|
29
|
+
name: string;
|
|
30
|
+
data?: string;
|
|
31
|
+
attribs?: {
|
|
32
|
+
[attributeName: string]: string;
|
|
33
|
+
};
|
|
34
|
+
children?: DomNode[];
|
|
35
|
+
parent?: DomNode;
|
|
36
|
+
prev?: DomNode;
|
|
37
|
+
next?: DomNode;
|
|
38
|
+
startIndex?: number;
|
|
39
|
+
endIndex?: number;
|
|
40
|
+
}
|