html-react-parser 5.2.7 → 5.2.9
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/README.md
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://nodei.co/npm/html-react-parser/)
|
|
4
4
|
|
|
5
|
-
[](https://www.npmjs.com/package/html-react-parser)
|
|
6
|
+
[](https://bundlephobia.com/package/html-react-parser)
|
|
7
7
|
[](https://github.com/remarkablemark/html-react-parser/actions/workflows/build.yml)
|
|
8
8
|
[](https://codecov.io/gh/remarkablemark/html-react-parser)
|
|
9
|
-
[](https://www.npmjs.com/package/html-react-parser)
|
|
10
|
+
[](https://b.remarkabl.org/discord)
|
|
11
11
|
|
|
12
12
|
HTML to React parser that works on both the server (Node.js) and the client (browser):
|
|
13
13
|
|
|
@@ -40,9 +40,9 @@
|
|
|
40
40
|
function requireLib$3 () {
|
|
41
41
|
if (hasRequiredLib$3) return lib$1;
|
|
42
42
|
hasRequiredLib$3 = 1;
|
|
43
|
-
(function (exports) {
|
|
44
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
-
exports.Doctype = exports.CDATA = exports.Tag = exports.Style = exports.Script = exports.Comment = exports.Directive = exports.Text = exports.Root = exports.isTag = exports.ElementType = void 0;
|
|
43
|
+
(function (exports$1) {
|
|
44
|
+
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
45
|
+
exports$1.Doctype = exports$1.CDATA = exports$1.Tag = exports$1.Style = exports$1.Script = exports$1.Comment = exports$1.Directive = exports$1.Text = exports$1.Root = exports$1.isTag = exports$1.ElementType = void 0;
|
|
46
46
|
/** Types of elements found in htmlparser2's DOM */
|
|
47
47
|
var ElementType;
|
|
48
48
|
(function (ElementType) {
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
ElementType["CDATA"] = "cdata";
|
|
65
65
|
/** Type for <!doctype ...> */
|
|
66
66
|
ElementType["Doctype"] = "doctype";
|
|
67
|
-
})(ElementType = exports.ElementType || (exports.ElementType = {}));
|
|
67
|
+
})(ElementType = exports$1.ElementType || (exports$1.ElementType = {}));
|
|
68
68
|
/**
|
|
69
69
|
* Tests whether an element is a tag or not.
|
|
70
70
|
*
|
|
@@ -75,26 +75,26 @@
|
|
|
75
75
|
elem.type === ElementType.Script ||
|
|
76
76
|
elem.type === ElementType.Style);
|
|
77
77
|
}
|
|
78
|
-
exports.isTag = isTag;
|
|
78
|
+
exports$1.isTag = isTag;
|
|
79
79
|
// Exports for backwards compatibility
|
|
80
80
|
/** Type for the root element of a document */
|
|
81
|
-
exports.Root = ElementType.Root;
|
|
81
|
+
exports$1.Root = ElementType.Root;
|
|
82
82
|
/** Type for Text */
|
|
83
|
-
exports.Text = ElementType.Text;
|
|
83
|
+
exports$1.Text = ElementType.Text;
|
|
84
84
|
/** Type for <? ... ?> */
|
|
85
|
-
exports.Directive = ElementType.Directive;
|
|
85
|
+
exports$1.Directive = ElementType.Directive;
|
|
86
86
|
/** Type for <!-- ... --> */
|
|
87
|
-
exports.Comment = ElementType.Comment;
|
|
87
|
+
exports$1.Comment = ElementType.Comment;
|
|
88
88
|
/** Type for <script> tags */
|
|
89
|
-
exports.Script = ElementType.Script;
|
|
89
|
+
exports$1.Script = ElementType.Script;
|
|
90
90
|
/** Type for <style> tags */
|
|
91
|
-
exports.Style = ElementType.Style;
|
|
91
|
+
exports$1.Style = ElementType.Style;
|
|
92
92
|
/** Type for Any tag */
|
|
93
|
-
exports.Tag = ElementType.Tag;
|
|
93
|
+
exports$1.Tag = ElementType.Tag;
|
|
94
94
|
/** Type for <![CDATA[ ... ]]> */
|
|
95
|
-
exports.CDATA = ElementType.CDATA;
|
|
95
|
+
exports$1.CDATA = ElementType.CDATA;
|
|
96
96
|
/** Type for <!doctype ...> */
|
|
97
|
-
exports.Doctype = ElementType.Doctype;
|
|
97
|
+
exports$1.Doctype = ElementType.Doctype;
|
|
98
98
|
} (lib$1));
|
|
99
99
|
return lib$1;
|
|
100
100
|
}
|
|
@@ -587,7 +587,7 @@
|
|
|
587
587
|
function requireLib$2 () {
|
|
588
588
|
if (hasRequiredLib$2) return lib$2;
|
|
589
589
|
hasRequiredLib$2 = 1;
|
|
590
|
-
(function (exports) {
|
|
590
|
+
(function (exports$1) {
|
|
591
591
|
var __createBinding = (lib$2 && lib$2.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
592
592
|
if (k2 === undefined) k2 = k;
|
|
593
593
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -599,14 +599,14 @@
|
|
|
599
599
|
if (k2 === undefined) k2 = k;
|
|
600
600
|
o[k2] = m[k];
|
|
601
601
|
}));
|
|
602
|
-
var __exportStar = (lib$2 && lib$2.__exportStar) || function(m, exports) {
|
|
603
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
602
|
+
var __exportStar = (lib$2 && lib$2.__exportStar) || function(m, exports$1) {
|
|
603
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports$1, p)) __createBinding(exports$1, m, p);
|
|
604
604
|
};
|
|
605
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
606
|
-
exports.DomHandler = void 0;
|
|
605
|
+
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
606
|
+
exports$1.DomHandler = void 0;
|
|
607
607
|
var domelementtype_1 = /*@__PURE__*/ requireLib$3();
|
|
608
608
|
var node_js_1 = /*@__PURE__*/ requireNode();
|
|
609
|
-
__exportStar(/*@__PURE__*/ requireNode(), exports);
|
|
609
|
+
__exportStar(/*@__PURE__*/ requireNode(), exports$1);
|
|
610
610
|
// Default options
|
|
611
611
|
var defaultOpts = {
|
|
612
612
|
withStartIndices: false,
|
|
@@ -750,8 +750,8 @@
|
|
|
750
750
|
};
|
|
751
751
|
return DomHandler;
|
|
752
752
|
}());
|
|
753
|
-
exports.DomHandler = DomHandler;
|
|
754
|
-
exports.default = DomHandler;
|
|
753
|
+
exports$1.DomHandler = DomHandler;
|
|
754
|
+
exports$1.default = DomHandler;
|
|
755
755
|
} (lib$2));
|
|
756
756
|
return lib$2;
|
|
757
757
|
}
|
|
@@ -763,15 +763,15 @@
|
|
|
763
763
|
function requireConstants () {
|
|
764
764
|
if (hasRequiredConstants) return constants;
|
|
765
765
|
hasRequiredConstants = 1;
|
|
766
|
-
(function (exports) {
|
|
767
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
768
|
-
exports.CARRIAGE_RETURN_PLACEHOLDER_REGEX = exports.CARRIAGE_RETURN_PLACEHOLDER = exports.CARRIAGE_RETURN_REGEX = exports.CARRIAGE_RETURN = exports.CASE_SENSITIVE_TAG_NAMES_MAP = exports.CASE_SENSITIVE_TAG_NAMES = void 0;
|
|
766
|
+
(function (exports$1) {
|
|
767
|
+
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
768
|
+
exports$1.CARRIAGE_RETURN_PLACEHOLDER_REGEX = exports$1.CARRIAGE_RETURN_PLACEHOLDER = exports$1.CARRIAGE_RETURN_REGEX = exports$1.CARRIAGE_RETURN = exports$1.CASE_SENSITIVE_TAG_NAMES_MAP = exports$1.CASE_SENSITIVE_TAG_NAMES = void 0;
|
|
769
769
|
/**
|
|
770
770
|
* SVG elements are case-sensitive.
|
|
771
771
|
*
|
|
772
772
|
* @see https://developer.mozilla.org/docs/Web/SVG/Element#svg_elements_a_to_z
|
|
773
773
|
*/
|
|
774
|
-
exports.CASE_SENSITIVE_TAG_NAMES = [
|
|
774
|
+
exports$1.CASE_SENSITIVE_TAG_NAMES = [
|
|
775
775
|
'animateMotion',
|
|
776
776
|
'animateTransform',
|
|
777
777
|
'clipPath',
|
|
@@ -804,14 +804,14 @@
|
|
|
804
804
|
'radialGradient',
|
|
805
805
|
'textPath',
|
|
806
806
|
];
|
|
807
|
-
exports.CASE_SENSITIVE_TAG_NAMES_MAP = exports.CASE_SENSITIVE_TAG_NAMES.reduce(function (accumulator, tagName) {
|
|
807
|
+
exports$1.CASE_SENSITIVE_TAG_NAMES_MAP = exports$1.CASE_SENSITIVE_TAG_NAMES.reduce(function (accumulator, tagName) {
|
|
808
808
|
accumulator[tagName.toLowerCase()] = tagName;
|
|
809
809
|
return accumulator;
|
|
810
810
|
}, {});
|
|
811
|
-
exports.CARRIAGE_RETURN = '\r';
|
|
812
|
-
exports.CARRIAGE_RETURN_REGEX = new RegExp(exports.CARRIAGE_RETURN, 'g');
|
|
813
|
-
exports.CARRIAGE_RETURN_PLACEHOLDER = "__HTML_DOM_PARSER_CARRIAGE_RETURN_PLACEHOLDER_".concat(Date.now(), "__");
|
|
814
|
-
exports.CARRIAGE_RETURN_PLACEHOLDER_REGEX = new RegExp(exports.CARRIAGE_RETURN_PLACEHOLDER, 'g');
|
|
811
|
+
exports$1.CARRIAGE_RETURN = '\r';
|
|
812
|
+
exports$1.CARRIAGE_RETURN_REGEX = new RegExp(exports$1.CARRIAGE_RETURN, 'g');
|
|
813
|
+
exports$1.CARRIAGE_RETURN_PLACEHOLDER = "__HTML_DOM_PARSER_CARRIAGE_RETURN_PLACEHOLDER_".concat(Date.now(), "__");
|
|
814
|
+
exports$1.CARRIAGE_RETURN_PLACEHOLDER_REGEX = new RegExp(exports$1.CARRIAGE_RETURN_PLACEHOLDER, 'g');
|
|
815
815
|
|
|
816
816
|
} (constants));
|
|
817
817
|
return constants;
|
|
@@ -2170,14 +2170,15 @@
|
|
|
2170
2170
|
|
|
2171
2171
|
var utilities$1 = {};
|
|
2172
2172
|
|
|
2173
|
-
var cjs$
|
|
2173
|
+
var cjs$2 = {};
|
|
2174
2174
|
|
|
2175
|
-
var
|
|
2176
|
-
var
|
|
2175
|
+
var cjs$1;
|
|
2176
|
+
var hasRequiredCjs$2;
|
|
2177
|
+
|
|
2178
|
+
function requireCjs$2 () {
|
|
2179
|
+
if (hasRequiredCjs$2) return cjs$1;
|
|
2180
|
+
hasRequiredCjs$2 = 1;
|
|
2177
2181
|
|
|
2178
|
-
function requireInlineStyleParser () {
|
|
2179
|
-
if (hasRequiredInlineStyleParser) return inlineStyleParser;
|
|
2180
|
-
hasRequiredInlineStyleParser = 1;
|
|
2181
2182
|
// http://www.w3.org/TR/CSS21/grammar.html
|
|
2182
2183
|
// https://github.com/visionmedia/css-parse/pull/49#issuecomment-30088027
|
|
2183
2184
|
var COMMENT_REGEX = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//g;
|
|
@@ -2211,7 +2212,7 @@
|
|
|
2211
2212
|
* @throws {TypeError}
|
|
2212
2213
|
* @throws {Error}
|
|
2213
2214
|
*/
|
|
2214
|
-
|
|
2215
|
+
function index (style, options) {
|
|
2215
2216
|
if (typeof style !== 'string') {
|
|
2216
2217
|
throw new TypeError('First argument must be a string');
|
|
2217
2218
|
}
|
|
@@ -2424,7 +2425,7 @@
|
|
|
2424
2425
|
|
|
2425
2426
|
whitespace();
|
|
2426
2427
|
return declarations();
|
|
2427
|
-
}
|
|
2428
|
+
}
|
|
2428
2429
|
|
|
2429
2430
|
/**
|
|
2430
2431
|
* Trim `str`.
|
|
@@ -2435,20 +2436,23 @@
|
|
|
2435
2436
|
function trim(str) {
|
|
2436
2437
|
return str ? str.replace(TRIM_REGEX, EMPTY_STRING) : EMPTY_STRING;
|
|
2437
2438
|
}
|
|
2438
|
-
|
|
2439
|
+
|
|
2440
|
+
cjs$1 = index;
|
|
2441
|
+
|
|
2442
|
+
return cjs$1;
|
|
2439
2443
|
}
|
|
2440
2444
|
|
|
2441
2445
|
var hasRequiredCjs$1;
|
|
2442
2446
|
|
|
2443
2447
|
function requireCjs$1 () {
|
|
2444
|
-
if (hasRequiredCjs$1) return cjs$
|
|
2448
|
+
if (hasRequiredCjs$1) return cjs$2;
|
|
2445
2449
|
hasRequiredCjs$1 = 1;
|
|
2446
|
-
var __importDefault = (cjs$
|
|
2450
|
+
var __importDefault = (cjs$2 && cjs$2.__importDefault) || function (mod) {
|
|
2447
2451
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
2448
2452
|
};
|
|
2449
|
-
Object.defineProperty(cjs$
|
|
2450
|
-
cjs$
|
|
2451
|
-
const inline_style_parser_1 = __importDefault(
|
|
2453
|
+
Object.defineProperty(cjs$2, "__esModule", { value: true });
|
|
2454
|
+
cjs$2.default = StyleToObject;
|
|
2455
|
+
const inline_style_parser_1 = __importDefault(requireCjs$2());
|
|
2452
2456
|
/**
|
|
2453
2457
|
* Parses inline style to object.
|
|
2454
2458
|
*
|
|
@@ -2486,7 +2490,7 @@
|
|
|
2486
2490
|
return styleObject;
|
|
2487
2491
|
}
|
|
2488
2492
|
|
|
2489
|
-
return cjs$
|
|
2493
|
+
return cjs$2;
|
|
2490
2494
|
}
|
|
2491
2495
|
|
|
2492
2496
|
var utilities = {};
|
|
@@ -2583,14 +2587,14 @@
|
|
|
2583
2587
|
function requireUtilities () {
|
|
2584
2588
|
if (hasRequiredUtilities) return utilities$1;
|
|
2585
2589
|
hasRequiredUtilities = 1;
|
|
2586
|
-
(function (exports) {
|
|
2590
|
+
(function (exports$1) {
|
|
2587
2591
|
var __importDefault = (utilities$1 && utilities$1.__importDefault) || function (mod) {
|
|
2588
2592
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
2589
2593
|
};
|
|
2590
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2591
|
-
exports.returnFirstArg = exports.canTextBeChildOfNode = exports.ELEMENTS_WITH_NO_TEXT_CHILDREN = exports.PRESERVE_CUSTOM_ATTRIBUTES = void 0;
|
|
2592
|
-
exports.isCustomComponent = isCustomComponent;
|
|
2593
|
-
exports.setStyleProp = setStyleProp;
|
|
2594
|
+
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
2595
|
+
exports$1.returnFirstArg = exports$1.canTextBeChildOfNode = exports$1.ELEMENTS_WITH_NO_TEXT_CHILDREN = exports$1.PRESERVE_CUSTOM_ATTRIBUTES = void 0;
|
|
2596
|
+
exports$1.isCustomComponent = isCustomComponent;
|
|
2597
|
+
exports$1.setStyleProp = setStyleProp;
|
|
2594
2598
|
var react_1 = require$$0;
|
|
2595
2599
|
var style_to_js_1 = __importDefault(requireCjs());
|
|
2596
2600
|
var RESERVED_SVG_MATHML_ELEMENTS = new Set([
|
|
@@ -2653,11 +2657,11 @@
|
|
|
2653
2657
|
/**
|
|
2654
2658
|
* @see https://reactjs.org/blog/2017/09/08/dom-attributes-in-react-16.html
|
|
2655
2659
|
*/
|
|
2656
|
-
exports.PRESERVE_CUSTOM_ATTRIBUTES = Number(react_1.version.split('.')[0]) >= 16;
|
|
2660
|
+
exports$1.PRESERVE_CUSTOM_ATTRIBUTES = Number(react_1.version.split('.')[0]) >= 16;
|
|
2657
2661
|
/**
|
|
2658
2662
|
* @see https://github.com/facebook/react/blob/cae635054e17a6f107a39d328649137b83f25972/packages/react-dom/src/client/validateDOMNesting.js#L213
|
|
2659
2663
|
*/
|
|
2660
|
-
exports.ELEMENTS_WITH_NO_TEXT_CHILDREN = new Set([
|
|
2664
|
+
exports$1.ELEMENTS_WITH_NO_TEXT_CHILDREN = new Set([
|
|
2661
2665
|
'tr',
|
|
2662
2666
|
'tbody',
|
|
2663
2667
|
'thead',
|
|
@@ -2675,9 +2679,9 @@
|
|
|
2675
2679
|
* @returns - Whether the node can contain text nodes.
|
|
2676
2680
|
*/
|
|
2677
2681
|
var canTextBeChildOfNode = function (node) {
|
|
2678
|
-
return !exports.ELEMENTS_WITH_NO_TEXT_CHILDREN.has(node.name);
|
|
2682
|
+
return !exports$1.ELEMENTS_WITH_NO_TEXT_CHILDREN.has(node.name);
|
|
2679
2683
|
};
|
|
2680
|
-
exports.canTextBeChildOfNode = canTextBeChildOfNode;
|
|
2684
|
+
exports$1.canTextBeChildOfNode = canTextBeChildOfNode;
|
|
2681
2685
|
/**
|
|
2682
2686
|
* Returns the first argument as is.
|
|
2683
2687
|
*
|
|
@@ -2685,7 +2689,7 @@
|
|
|
2685
2689
|
* @returns - The input argument `arg`.
|
|
2686
2690
|
*/
|
|
2687
2691
|
var returnFirstArg = function (arg) { return arg; }; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
2688
|
-
exports.returnFirstArg = returnFirstArg;
|
|
2692
|
+
exports$1.returnFirstArg = returnFirstArg;
|
|
2689
2693
|
|
|
2690
2694
|
} (utilities$1));
|
|
2691
2695
|
return utilities$1;
|
|
@@ -2908,24 +2912,24 @@
|
|
|
2908
2912
|
function requireLib () {
|
|
2909
2913
|
if (hasRequiredLib) return lib$3;
|
|
2910
2914
|
hasRequiredLib = 1;
|
|
2911
|
-
(function (exports) {
|
|
2915
|
+
(function (exports$1) {
|
|
2912
2916
|
var __importDefault = (lib$3 && lib$3.__importDefault) || function (mod) {
|
|
2913
2917
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
2914
2918
|
};
|
|
2915
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2916
|
-
exports.htmlToDOM = exports.domToReact = exports.attributesToProps = exports.Text = exports.ProcessingInstruction = exports.Element = exports.Comment = void 0;
|
|
2917
|
-
exports.default = HTMLReactParser;
|
|
2919
|
+
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
2920
|
+
exports$1.htmlToDOM = exports$1.domToReact = exports$1.attributesToProps = exports$1.Text = exports$1.ProcessingInstruction = exports$1.Element = exports$1.Comment = void 0;
|
|
2921
|
+
exports$1.default = HTMLReactParser;
|
|
2918
2922
|
var html_dom_parser_1 = __importDefault(requireHtmlToDom());
|
|
2919
|
-
exports.htmlToDOM = html_dom_parser_1.default;
|
|
2923
|
+
exports$1.htmlToDOM = html_dom_parser_1.default;
|
|
2920
2924
|
var attributes_to_props_1 = __importDefault(requireAttributesToProps());
|
|
2921
|
-
exports.attributesToProps = attributes_to_props_1.default;
|
|
2925
|
+
exports$1.attributesToProps = attributes_to_props_1.default;
|
|
2922
2926
|
var dom_to_react_1 = __importDefault(requireDomToReact());
|
|
2923
|
-
exports.domToReact = dom_to_react_1.default;
|
|
2927
|
+
exports$1.domToReact = dom_to_react_1.default;
|
|
2924
2928
|
var domhandler_1 = /*@__PURE__*/ requireLib$2();
|
|
2925
|
-
Object.defineProperty(exports, "Comment", { enumerable: true, get: function () { return domhandler_1.Comment; } });
|
|
2926
|
-
Object.defineProperty(exports, "Element", { enumerable: true, get: function () { return domhandler_1.Element; } });
|
|
2927
|
-
Object.defineProperty(exports, "ProcessingInstruction", { enumerable: true, get: function () { return domhandler_1.ProcessingInstruction; } });
|
|
2928
|
-
Object.defineProperty(exports, "Text", { enumerable: true, get: function () { return domhandler_1.Text; } });
|
|
2929
|
+
Object.defineProperty(exports$1, "Comment", { enumerable: true, get: function () { return domhandler_1.Comment; } });
|
|
2930
|
+
Object.defineProperty(exports$1, "Element", { enumerable: true, get: function () { return domhandler_1.Element; } });
|
|
2931
|
+
Object.defineProperty(exports$1, "ProcessingInstruction", { enumerable: true, get: function () { return domhandler_1.ProcessingInstruction; } });
|
|
2932
|
+
Object.defineProperty(exports$1, "Text", { enumerable: true, get: function () { return domhandler_1.Text; } });
|
|
2929
2933
|
var domParserOptions = { lowerCaseAttributeNames: false };
|
|
2930
2934
|
/**
|
|
2931
2935
|
* Converts HTML string to React elements.
|