html-react-parser 5.2.8 → 5.2.10
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;
|
|
@@ -2587,14 +2587,14 @@
|
|
|
2587
2587
|
function requireUtilities () {
|
|
2588
2588
|
if (hasRequiredUtilities) return utilities$1;
|
|
2589
2589
|
hasRequiredUtilities = 1;
|
|
2590
|
-
(function (exports) {
|
|
2590
|
+
(function (exports$1) {
|
|
2591
2591
|
var __importDefault = (utilities$1 && utilities$1.__importDefault) || function (mod) {
|
|
2592
2592
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
2593
2593
|
};
|
|
2594
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2595
|
-
exports.returnFirstArg = exports.canTextBeChildOfNode = exports.ELEMENTS_WITH_NO_TEXT_CHILDREN = exports.PRESERVE_CUSTOM_ATTRIBUTES = void 0;
|
|
2596
|
-
exports.isCustomComponent = isCustomComponent;
|
|
2597
|
-
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;
|
|
2598
2598
|
var react_1 = require$$0;
|
|
2599
2599
|
var style_to_js_1 = __importDefault(requireCjs());
|
|
2600
2600
|
var RESERVED_SVG_MATHML_ELEMENTS = new Set([
|
|
@@ -2657,11 +2657,11 @@
|
|
|
2657
2657
|
/**
|
|
2658
2658
|
* @see https://reactjs.org/blog/2017/09/08/dom-attributes-in-react-16.html
|
|
2659
2659
|
*/
|
|
2660
|
-
exports.PRESERVE_CUSTOM_ATTRIBUTES = Number(react_1.version.split('.')[0]) >= 16;
|
|
2660
|
+
exports$1.PRESERVE_CUSTOM_ATTRIBUTES = Number(react_1.version.split('.')[0]) >= 16;
|
|
2661
2661
|
/**
|
|
2662
2662
|
* @see https://github.com/facebook/react/blob/cae635054e17a6f107a39d328649137b83f25972/packages/react-dom/src/client/validateDOMNesting.js#L213
|
|
2663
2663
|
*/
|
|
2664
|
-
exports.ELEMENTS_WITH_NO_TEXT_CHILDREN = new Set([
|
|
2664
|
+
exports$1.ELEMENTS_WITH_NO_TEXT_CHILDREN = new Set([
|
|
2665
2665
|
'tr',
|
|
2666
2666
|
'tbody',
|
|
2667
2667
|
'thead',
|
|
@@ -2679,9 +2679,9 @@
|
|
|
2679
2679
|
* @returns - Whether the node can contain text nodes.
|
|
2680
2680
|
*/
|
|
2681
2681
|
var canTextBeChildOfNode = function (node) {
|
|
2682
|
-
return !exports.ELEMENTS_WITH_NO_TEXT_CHILDREN.has(node.name);
|
|
2682
|
+
return !exports$1.ELEMENTS_WITH_NO_TEXT_CHILDREN.has(node.name);
|
|
2683
2683
|
};
|
|
2684
|
-
exports.canTextBeChildOfNode = canTextBeChildOfNode;
|
|
2684
|
+
exports$1.canTextBeChildOfNode = canTextBeChildOfNode;
|
|
2685
2685
|
/**
|
|
2686
2686
|
* Returns the first argument as is.
|
|
2687
2687
|
*
|
|
@@ -2689,7 +2689,7 @@
|
|
|
2689
2689
|
* @returns - The input argument `arg`.
|
|
2690
2690
|
*/
|
|
2691
2691
|
var returnFirstArg = function (arg) { return arg; }; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
2692
|
-
exports.returnFirstArg = returnFirstArg;
|
|
2692
|
+
exports$1.returnFirstArg = returnFirstArg;
|
|
2693
2693
|
|
|
2694
2694
|
} (utilities$1));
|
|
2695
2695
|
return utilities$1;
|
|
@@ -2912,24 +2912,24 @@
|
|
|
2912
2912
|
function requireLib () {
|
|
2913
2913
|
if (hasRequiredLib) return lib$3;
|
|
2914
2914
|
hasRequiredLib = 1;
|
|
2915
|
-
(function (exports) {
|
|
2915
|
+
(function (exports$1) {
|
|
2916
2916
|
var __importDefault = (lib$3 && lib$3.__importDefault) || function (mod) {
|
|
2917
2917
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
2918
2918
|
};
|
|
2919
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2920
|
-
exports.htmlToDOM = exports.domToReact = exports.attributesToProps = exports.Text = exports.ProcessingInstruction = exports.Element = exports.Comment = void 0;
|
|
2921
|
-
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;
|
|
2922
2922
|
var html_dom_parser_1 = __importDefault(requireHtmlToDom());
|
|
2923
|
-
exports.htmlToDOM = html_dom_parser_1.default;
|
|
2923
|
+
exports$1.htmlToDOM = html_dom_parser_1.default;
|
|
2924
2924
|
var attributes_to_props_1 = __importDefault(requireAttributesToProps());
|
|
2925
|
-
exports.attributesToProps = attributes_to_props_1.default;
|
|
2925
|
+
exports$1.attributesToProps = attributes_to_props_1.default;
|
|
2926
2926
|
var dom_to_react_1 = __importDefault(requireDomToReact());
|
|
2927
|
-
exports.domToReact = dom_to_react_1.default;
|
|
2927
|
+
exports$1.domToReact = dom_to_react_1.default;
|
|
2928
2928
|
var domhandler_1 = /*@__PURE__*/ requireLib$2();
|
|
2929
|
-
Object.defineProperty(exports, "Comment", { enumerable: true, get: function () { return domhandler_1.Comment; } });
|
|
2930
|
-
Object.defineProperty(exports, "Element", { enumerable: true, get: function () { return domhandler_1.Element; } });
|
|
2931
|
-
Object.defineProperty(exports, "ProcessingInstruction", { enumerable: true, get: function () { return domhandler_1.ProcessingInstruction; } });
|
|
2932
|
-
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; } });
|
|
2933
2933
|
var domParserOptions = { lowerCaseAttributeNames: false };
|
|
2934
2934
|
/**
|
|
2935
2935
|
* Converts HTML string to React elements.
|