html-react-parser
Advanced tools
Comparing version 0.14.3 to 1.0.0
@@ -5,2 +5,16 @@ # Change Log | ||
# [1.0.0](https://github.com/remarkablemark/html-react-parser/compare/v0.14.3...v1.0.0) (2020-12-14) | ||
### Build System | ||
* **package:** upgrade dependency `html-dom-parser` to 0.5.0 ([5568ed7](https://github.com/remarkablemark/html-react-parser/commit/5568ed72fb2c31c1924eac114f38d6294c3ba342)) | ||
### BREAKING CHANGES | ||
* **package:** upgrade dependency `html-dom-parser` to 0.5.0 | ||
## [0.14.3](https://github.com/remarkablemark/html-react-parser/compare/v0.14.2...v0.14.3) (2020-12-12) | ||
@@ -7,0 +21,0 @@ |
@@ -1135,3 +1135,3 @@ (function (global, factory) { | ||
/** | ||
* Converts DOM nodes to React elements. | ||
* Converts DOM nodes to JSX element(s). | ||
* | ||
@@ -1142,3 +1142,3 @@ * @param {DomElement[]} nodes - DOM nodes. | ||
* @param {object} [options.library] - Library (React/Preact/etc.). | ||
* @return {string|ReactElement|ReactElement[]} | ||
* @return {string|JSX.Element|JSX.Element[]} | ||
*/ | ||
@@ -1304,6 +1304,310 @@ function domToReact(nodes, options) { | ||
var node = createCommonjsModule(function (module, exports) { | ||
var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () { | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
var __assign = (commonjsGlobal && commonjsGlobal.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.cloneNode = exports.Element = exports.NodeWithChildren = exports.ProcessingInstruction = exports.Comment = exports.Text = exports.DataNode = exports.Node = void 0; | ||
var nodeTypes = new Map([ | ||
["tag" /* Tag */, 1], | ||
["script" /* Script */, 1], | ||
["style" /* Style */, 1], | ||
["directive" /* Directive */, 1], | ||
["text" /* Text */, 3], | ||
["cdata" /* CDATA */, 4], | ||
["comment" /* Comment */, 8], | ||
]); | ||
/** | ||
* This object will be used as the prototype for Nodes when creating a | ||
* DOM-Level-1-compliant structure. | ||
*/ | ||
var Node = /** @class */ (function () { | ||
/** | ||
* | ||
* @param type The type of the node. | ||
*/ | ||
function Node(type) { | ||
this.type = type; | ||
/** Parent of the node */ | ||
this.parent = null; | ||
/** Previous sibling */ | ||
this.prev = null; | ||
/** Next sibling */ | ||
this.next = null; | ||
/** The start index of the node. Requires `withStartIndices` on the handler to be `true. */ | ||
this.startIndex = null; | ||
/** The end index of the node. Requires `withEndIndices` on the handler to be `true. */ | ||
this.endIndex = null; | ||
} | ||
Object.defineProperty(Node.prototype, "nodeType", { | ||
// Read-only aliases | ||
get: function () { | ||
var _a; | ||
return (_a = nodeTypes.get(this.type)) !== null && _a !== void 0 ? _a : 1; | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
Object.defineProperty(Node.prototype, "parentNode", { | ||
// Read-write aliases for properties | ||
get: function () { | ||
return this.parent; | ||
}, | ||
set: function (parent) { | ||
this.parent = parent; | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
Object.defineProperty(Node.prototype, "previousSibling", { | ||
get: function () { | ||
return this.prev; | ||
}, | ||
set: function (prev) { | ||
this.prev = prev; | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
Object.defineProperty(Node.prototype, "nextSibling", { | ||
get: function () { | ||
return this.next; | ||
}, | ||
set: function (next) { | ||
this.next = next; | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
/** | ||
* Clone this node, and optionally its children. | ||
* | ||
* @param recursive Clone child nodes as well. | ||
* @returns A clone of the node. | ||
*/ | ||
Node.prototype.cloneNode = function (recursive) { | ||
if (recursive === void 0) { recursive = false; } | ||
return cloneNode(this, recursive); | ||
}; | ||
return Node; | ||
}()); | ||
exports.Node = Node; | ||
var DataNode = /** @class */ (function (_super) { | ||
__extends(DataNode, _super); | ||
/** | ||
* @param type The type of the node | ||
* @param data The content of the data node | ||
*/ | ||
function DataNode(type, data) { | ||
var _this = _super.call(this, type) || this; | ||
_this.data = data; | ||
return _this; | ||
} | ||
Object.defineProperty(DataNode.prototype, "nodeValue", { | ||
get: function () { | ||
return this.data; | ||
}, | ||
set: function (data) { | ||
this.data = data; | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
return DataNode; | ||
}(Node)); | ||
exports.DataNode = DataNode; | ||
var Text = /** @class */ (function (_super) { | ||
__extends(Text, _super); | ||
function Text(data) { | ||
return _super.call(this, "text" /* Text */, data) || this; | ||
} | ||
return Text; | ||
}(DataNode)); | ||
exports.Text = Text; | ||
var Comment = /** @class */ (function (_super) { | ||
__extends(Comment, _super); | ||
function Comment(data) { | ||
return _super.call(this, "comment" /* Comment */, data) || this; | ||
} | ||
return Comment; | ||
}(DataNode)); | ||
exports.Comment = Comment; | ||
var ProcessingInstruction = /** @class */ (function (_super) { | ||
__extends(ProcessingInstruction, _super); | ||
function ProcessingInstruction(name, data) { | ||
var _this = _super.call(this, "directive" /* Directive */, data) || this; | ||
_this.name = name; | ||
return _this; | ||
} | ||
return ProcessingInstruction; | ||
}(DataNode)); | ||
exports.ProcessingInstruction = ProcessingInstruction; | ||
var NodeWithChildren = /** @class */ (function (_super) { | ||
__extends(NodeWithChildren, _super); | ||
/** | ||
* | ||
* @param type Type of the node. | ||
* @param children Children of the node. Only certain node types can have children. | ||
*/ | ||
function NodeWithChildren(type, children) { | ||
var _this = _super.call(this, type) || this; | ||
_this.children = children; | ||
return _this; | ||
} | ||
Object.defineProperty(NodeWithChildren.prototype, "firstChild", { | ||
// Aliases | ||
get: function () { | ||
var _a; | ||
return (_a = this.children[0]) !== null && _a !== void 0 ? _a : null; | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
Object.defineProperty(NodeWithChildren.prototype, "lastChild", { | ||
get: function () { | ||
return this.children.length > 0 | ||
? this.children[this.children.length - 1] | ||
: null; | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
Object.defineProperty(NodeWithChildren.prototype, "childNodes", { | ||
get: function () { | ||
return this.children; | ||
}, | ||
set: function (children) { | ||
this.children = children; | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
return NodeWithChildren; | ||
}(Node)); | ||
exports.NodeWithChildren = NodeWithChildren; | ||
var Element = /** @class */ (function (_super) { | ||
__extends(Element, _super); | ||
/** | ||
* @param name Name of the tag, eg. `div`, `span`. | ||
* @param attribs Object mapping attribute names to attribute values. | ||
* @param children Children of the node. | ||
*/ | ||
function Element(name, attribs, children) { | ||
if (children === void 0) { children = []; } | ||
var _this = _super.call(this, name === "script" | ||
? "script" /* Script */ | ||
: name === "style" | ||
? "style" /* Style */ | ||
: "tag" /* Tag */, children) || this; | ||
_this.name = name; | ||
_this.attribs = attribs; | ||
_this.attribs = attribs; | ||
return _this; | ||
} | ||
Object.defineProperty(Element.prototype, "tagName", { | ||
// DOM Level 1 aliases | ||
get: function () { | ||
return this.name; | ||
}, | ||
set: function (name) { | ||
this.name = name; | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
Object.defineProperty(Element.prototype, "attributes", { | ||
get: function () { | ||
var _this = this; | ||
return Object.keys(this.attribs).map(function (name) { return ({ | ||
name: name, | ||
value: _this.attribs[name], | ||
}); }); | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
return Element; | ||
}(NodeWithChildren)); | ||
exports.Element = Element; | ||
/** | ||
* Clone a node, and optionally its children. | ||
* | ||
* @param recursive Clone child nodes as well. | ||
* @returns A clone of the node. | ||
*/ | ||
function cloneNode(node, recursive) { | ||
if (recursive === void 0) { recursive = false; } | ||
switch (node.type) { | ||
case "text" /* Text */: | ||
return new Text(node.data); | ||
case "directive" /* Directive */: { | ||
var instr = node; | ||
return new ProcessingInstruction(instr.name, instr.data); | ||
} | ||
case "comment" /* Comment */: | ||
return new Comment(node.data); | ||
case "tag" /* Tag */: | ||
case "script" /* Script */: | ||
case "style" /* Style */: { | ||
var elem = node; | ||
var children = recursive ? cloneChildren(elem.children) : []; | ||
var clone_1 = new Element(elem.name, __assign({}, elem.attribs), children); | ||
children.forEach(function (child) { return (child.parent = clone_1); }); | ||
return clone_1; | ||
} | ||
case "cdata" /* CDATA */: { | ||
var cdata = node; | ||
var children = recursive ? cloneChildren(cdata.children) : []; | ||
var clone_2 = new NodeWithChildren("cdata" /* CDATA */, children); | ||
children.forEach(function (child) { return (child.parent = clone_2); }); | ||
return clone_2; | ||
} | ||
case "doctype" /* Doctype */: { | ||
// This type isn't used yet. | ||
throw new Error("Not implemented yet: ElementType.Doctype case"); | ||
} | ||
} | ||
} | ||
exports.cloneNode = cloneNode; | ||
function cloneChildren(childs) { | ||
var children = childs.map(function (child) { return cloneNode(child, true); }); | ||
for (var i = 1; i < children.length; i++) { | ||
children[i].prev = children[i - 1]; | ||
children[i - 1].next = children[i]; | ||
} | ||
return children; | ||
} | ||
}); | ||
var CASE_SENSITIVE_TAG_NAMES$1 = constants.CASE_SENSITIVE_TAG_NAMES; | ||
var Comment = node.Comment; | ||
var Element = node.Element; | ||
var ProcessingInstruction = node.ProcessingInstruction; | ||
var Text = node.Text; | ||
var caseSensitiveTagNamesMap = {}; | ||
var tagName; | ||
for (var i = 0, len = CASE_SENSITIVE_TAG_NAMES$1.length; i < len; i++) { | ||
@@ -1317,4 +1621,4 @@ tagName = CASE_SENSITIVE_TAG_NAMES$1[i]; | ||
* | ||
* @param {String} tagName - The lowercase tag name. | ||
* @return {String|undefined} | ||
* @param {string} tagName - Tag name in lowercase. | ||
* @return {string|undefined} - Case-sensitive tag name. | ||
*/ | ||
@@ -1328,4 +1632,4 @@ function getCaseSensitiveTagName(tagName) { | ||
* | ||
* @param {NamedNodeMap} attributes - The list of attributes. | ||
* @return {Object} - A map of attribute name to value. | ||
* @param {NamedNodeMap} attributes - List of attributes. | ||
* @return {object} - Map of attribute name to value. | ||
*/ | ||
@@ -1347,4 +1651,4 @@ function formatAttributes(attributes) { | ||
* | ||
* @param {String} tagName - The lowercase tag name. | ||
* @return {String} - The formatted tag name. | ||
* @param {string} tagName - Lowercase tag name. | ||
* @return {string} - Formatted tag name. | ||
*/ | ||
@@ -1363,94 +1667,74 @@ function formatTagName(tagName) { | ||
* | ||
* @param {NodeList} nodes - The DOM nodes. | ||
* @param {Object} [parentObj] - The formatted parent node. | ||
* @param {String} [directive] - The directive. | ||
* @return {Object[]} - The formatted DOM object. | ||
* @param {NodeList} nodes - DOM nodes. | ||
* @param {Element} [parentNode] - Formatted parent node. | ||
* @param {string} [directive] - Directive. | ||
* @return {Array<Comment|Element|ProcessingInstruction|Text>} | ||
*/ | ||
function formatDOM(nodes, parentObj, directive) { | ||
parentObj = parentObj || null; | ||
function formatDOM(domNodes, parentNode, directive) { | ||
parentNode = parentNode || null; | ||
var result = []; | ||
var domNode; | ||
var node; | ||
var prevNode; | ||
var nodeObj; | ||
var output = []; | ||
// `NodeList` is array-like | ||
for (var i = 0, len = nodes.length; i < len; i++) { | ||
node = nodes[i]; | ||
// reset | ||
nodeObj = { | ||
next: null, | ||
prev: result[i - 1] || null, | ||
parent: parentObj | ||
}; | ||
for (var i = 0, len = domNodes.length; i < len; i++) { | ||
domNode = domNodes[i]; | ||
// set the next node for the previous node (if applicable) | ||
prevNode = result[i - 1]; | ||
if (prevNode) { | ||
prevNode.next = nodeObj; | ||
} | ||
// set the node name if it's not "#text" or "#comment" | ||
// e.g., "div" | ||
if (node.nodeName[0] !== '#') { | ||
nodeObj.name = formatTagName(node.nodeName); | ||
// also, nodes of type "tag" have "attribs" | ||
nodeObj.attribs = {}; // default | ||
if (node.attributes && node.attributes.length) { | ||
nodeObj.attribs = formatAttributes(node.attributes); | ||
} | ||
} | ||
// set the node type | ||
// e.g., "tag" | ||
switch (node.nodeType) { | ||
// 1 = element | ||
// set the node data given the type | ||
switch (domNode.nodeType) { | ||
case 1: | ||
if (nodeObj.name === 'script' || nodeObj.name === 'style') { | ||
nodeObj.type = nodeObj.name; | ||
} else { | ||
nodeObj.type = 'tag'; | ||
} | ||
// recursively format the children | ||
nodeObj.children = formatDOM(node.childNodes, nodeObj); | ||
// script, style, or tag | ||
node = new Element( | ||
formatTagName(domNode.nodeName), | ||
formatAttributes(domNode.attributes) | ||
); | ||
node.children = formatDOM(domNode.childNodes, node); | ||
break; | ||
// 2 = attribute | ||
// 3 = text | ||
case 3: | ||
nodeObj.type = 'text'; | ||
nodeObj.data = node.nodeValue; | ||
node = new Text(domNode.nodeValue); | ||
break; | ||
// 8 = comment | ||
case 8: | ||
nodeObj.type = 'comment'; | ||
nodeObj.data = node.nodeValue; | ||
node = new Comment(domNode.nodeValue); | ||
break; | ||
} | ||
result.push(nodeObj); | ||
// set next for previous node | ||
prevNode = output[i - 1] || null; | ||
if (prevNode) { | ||
prevNode.next = node; | ||
} | ||
// set properties for current node | ||
node.parent = parentNode; | ||
node.prev = prevNode; | ||
node.next = null; | ||
output.push(node); | ||
} | ||
if (directive) { | ||
result.unshift({ | ||
name: directive.substring(0, directive.indexOf(' ')).toLowerCase(), | ||
data: directive, | ||
type: 'directive', | ||
next: result[0] ? result[0] : null, | ||
prev: null, | ||
parent: parentObj | ||
}); | ||
node = new ProcessingInstruction( | ||
directive.substring(0, directive.indexOf(' ')).toLowerCase(), | ||
directive | ||
); | ||
node.next = output[0] || null; | ||
node.parent = parentNode; | ||
output.unshift(node); | ||
if (result[1]) { | ||
result[1].prev = result[0]; | ||
if (output[1]) { | ||
output[1].prev = output[0]; | ||
} | ||
} | ||
return result; | ||
return output; | ||
} | ||
/** | ||
* Detects IE with or without version. | ||
* Detects if browser is Internet Explorer. | ||
* | ||
* @param {Number} [version] - The IE version to detect. | ||
* @return {Boolean} - Whether IE or the version has been detected. | ||
* @param {number} [version] - IE version to detect. | ||
* @return {boolean} - Whether IE or the version is detected. | ||
*/ | ||
@@ -1593,4 +1877,4 @@ function isIE(version) { | ||
* | ||
* @param {string} html - The HTML string. | ||
* @return {NodeList|Array} | ||
* @param {string} html - HTML markup. | ||
* @return {NodeList} | ||
*/ | ||
@@ -1660,8 +1944,8 @@ function domparser(html) { | ||
/** | ||
* Parses HTML and reformats DOM nodes output. | ||
* Parses HTML string to DOM nodes in browser. | ||
* | ||
* @param {String} html - The HTML string. | ||
* @return {Array} - The formatted DOM nodes. | ||
* @param {String} html - HTML markup. | ||
* @return {DomElement[]} - DOM elements. | ||
*/ | ||
function parseDOM(html) { | ||
function HTMLDOMParser(html) { | ||
if (typeof html !== 'string') { | ||
@@ -1692,3 +1976,3 @@ throw new TypeError('First argument must be a string'); | ||
var htmlToDomClient = parseDOM; | ||
var htmlToDomClient = HTMLDOMParser; | ||
@@ -1695,0 +1979,0 @@ // decode HTML entities by default for `htmlparser2` |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).HTMLReactParser=t(e.React)}(this,(function(e){"use strict";function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=t(e),n={Properties:{autoFocus:4,accept:0,acceptCharset:0,accessKey:0,action:0,allowFullScreen:4,allowTransparency:0,alt:0,as:0,async:4,autoComplete:0,autoPlay:4,capture:4,cellPadding:0,cellSpacing:0,charSet:0,challenge:0,checked:5,cite:0,classID:0,className:0,cols:24,colSpan:0,content:0,contentEditable:0,contextMenu:0,controls:4,controlsList:0,coords:0,crossOrigin:0,data:0,dateTime:0,default:4,defer:4,dir:0,disabled:4,download:32,draggable:0,encType:0,form:0,formAction:0,formEncType:0,formMethod:0,formNoValidate:4,formTarget:0,frameBorder:0,headers:0,height:0,hidden:4,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:4,low:0,manifest:0,marginHeight:0,marginWidth:0,max:0,maxLength:0,media:0,mediaGroup:0,method:0,min:0,minLength:0,multiple:5,muted:5,name:0,nonce:0,noValidate:4,open:4,optimum:0,pattern:0,placeholder:0,playsInline:4,poster:0,preload:0,profile:0,radioGroup:0,readOnly:4,referrerPolicy:0,rel:0,required:4,reversed:4,role:0,rows:24,rowSpan:8,sandbox:0,scope:0,scoped:4,scrolling:0,seamless:4,selected:5,shape:0,size:24,sizes:0,span:24,spellCheck:0,src:0,srcDoc:0,srcLang:0,srcSet:0,start:8,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:4,itemType:0,itemID:0,itemRef:0,results:0,security:0,unselectable:0},DOMAttributeNames:{acceptCharset:"accept-charset",className:"class",htmlFor:"for",httpEquiv:"http-equiv"}},i={Properties:{accentHeight:0,accumulate:0,additive:0,alignmentBaseline:0,allowReorder:0,alphabetic:0,amplitude:0,arabicForm:0,ascent:0,attributeName:0,attributeType:0,autoReverse:0,azimuth:0,baseFrequency:0,baseProfile:0,baselineShift:0,bbox:0,begin:0,bias:0,by:0,calcMode:0,capHeight:0,clip:0,clipPath:0,clipRule:0,clipPathUnits:0,colorInterpolation:0,colorInterpolationFilters:0,colorProfile:0,colorRendering:0,contentScriptType:0,contentStyleType:0,cursor:0,cx:0,cy:0,d:0,decelerate:0,descent:0,diffuseConstant:0,direction:0,display:0,divisor:0,dominantBaseline:0,dur:0,dx:0,dy:0,edgeMode:0,elevation:0,enableBackground:0,end:0,exponent:0,externalResourcesRequired:0,fill:0,fillOpacity:0,fillRule:0,filter:0,filterRes:0,filterUnits:0,floodColor:0,floodOpacity:0,focusable:0,fontFamily:0,fontSize:0,fontSizeAdjust:0,fontStretch:0,fontStyle:0,fontVariant:0,fontWeight:0,format:0,from:0,fx:0,fy:0,g1:0,g2:0,glyphName:0,glyphOrientationHorizontal:0,glyphOrientationVertical:0,glyphRef:0,gradientTransform:0,gradientUnits:0,hanging:0,horizAdvX:0,horizOriginX:0,ideographic:0,imageRendering:0,in:0,in2:0,intercept:0,k:0,k1:0,k2:0,k3:0,k4:0,kernelMatrix:0,kernelUnitLength:0,kerning:0,keyPoints:0,keySplines:0,keyTimes:0,lengthAdjust:0,letterSpacing:0,lightingColor:0,limitingConeAngle:0,local:0,markerEnd:0,markerMid:0,markerStart:0,markerHeight:0,markerUnits:0,markerWidth:0,mask:0,maskContentUnits:0,maskUnits:0,mathematical:0,mode:0,numOctaves:0,offset:0,opacity:0,operator:0,order:0,orient:0,orientation:0,origin:0,overflow:0,overlinePosition:0,overlineThickness:0,paintOrder:0,panose1:0,pathLength:0,patternContentUnits:0,patternTransform:0,patternUnits:0,pointerEvents:0,points:0,pointsAtX:0,pointsAtY:0,pointsAtZ:0,preserveAlpha:0,preserveAspectRatio:0,primitiveUnits:0,r:0,radius:0,refX:0,refY:0,renderingIntent:0,repeatCount:0,repeatDur:0,requiredExtensions:0,requiredFeatures:0,restart:0,result:0,rotate:0,rx:0,ry:0,scale:0,seed:0,shapeRendering:0,slope:0,spacing:0,specularConstant:0,specularExponent:0,speed:0,spreadMethod:0,startOffset:0,stdDeviation:0,stemh:0,stemv:0,stitchTiles:0,stopColor:0,stopOpacity:0,strikethroughPosition:0,strikethroughThickness:0,string:0,stroke:0,strokeDasharray:0,strokeDashoffset:0,strokeLinecap:0,strokeLinejoin:0,strokeMiterlimit:0,strokeOpacity:0,strokeWidth:0,surfaceScale:0,systemLanguage:0,tableValues:0,targetX:0,targetY:0,textAnchor:0,textDecoration:0,textRendering:0,textLength:0,to:0,transform:0,u1:0,u2:0,underlinePosition:0,underlineThickness:0,unicode:0,unicodeBidi:0,unicodeRange:0,unitsPerEm:0,vAlphabetic:0,vHanging:0,vIdeographic:0,vMathematical:0,values:0,vectorEffect:0,version:0,vertAdvY:0,vertOriginX:0,vertOriginY:0,viewBox:0,viewTarget:0,visibility:0,widths:0,wordSpacing:0,writingMode:0,x:0,xHeight:0,x1:0,x2:0,xChannelSelector:0,xlinkActuate:0,xlinkArcrole:0,xlinkHref:0,xlinkRole:0,xlinkShow:0,xlinkTitle:0,xlinkType:0,xmlBase:0,xmlns:0,xmlnsXlink:0,xmlLang:0,xmlSpace:0,y:0,y1:0,y2:0,yChannelSelector:0,z:0,zoomAndPan:0},DOMAttributeNames:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDasharray:"stroke-dasharray",strokeDashoffset:"stroke-dashoffset",strokeLinecap:"stroke-linecap",strokeLinejoin:"stroke-linejoin",strokeMiterlimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",xlinkActuate:"xlink:actuate",xlinkArcrole:"xlink:arcrole",xlinkHref:"xlink:href",xlinkRole:"xlink:role",xlinkShow:"xlink:show",xlinkTitle:"xlink:title",xlinkType:"xlink:type",xmlBase:"xml:base",xmlnsXlink:"xmlns:xlink",xmlLang:"xml:lang",xmlSpace:"xml:space"}},o=1,a=4,l=8,s=24,c=32;function u(e,t){return(e&t)===t}function p(e,t,r){var n,i,p,f=e.Properties,d=e.DOMAttributeNames;for(i in f)n=d[i]||(r?i:i.toLowerCase()),p=f[i],t[n]={attributeName:n,propertyName:i,mustUseProperty:u(p,o),hasBooleanValue:u(p,a),hasNumericValue:u(p,l),hasPositiveNumericValue:u(p,s),hasOverloadedBooleanValue:u(p,c)}}var f={};p(n,f);var d={};p(i,d,!0);var m={};p(n,m),p(i,m,!0);var h={html:f,svg:d,properties:m,isCustomAttribute:RegExp.prototype.test.bind(new RegExp("^(data|aria)-[: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\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"))},g="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function y(e){var t={exports:{}};return e(t,t.exports),t.exports}var v=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,k=/\n/g,x=/^\s*/,b=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,w=/^:\s*/,T=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,E=/^[;\s]*/,C=/^\s+|\s+$/g,S="";function M(e){return e?e.replace(C,S):S}var F=function(e,t){var r,n=null;if(!e||"string"!=typeof e)return n;for(var i,o,a=function(e,t){if("string"!=typeof e)throw new TypeError("First argument must be a string");if(!e)return[];t=t||{};var r=1,n=1;function i(e){var t=e.match(k);t&&(r+=t.length);var i=e.lastIndexOf("\n");n=~i?e.length-i:n+e.length}function o(){var e={line:r,column:n};return function(t){return t.position=new a(e),c(),t}}function a(e){this.start=e,this.end={line:r,column:n},this.source=t.source}function l(i){var o=new Error(t.source+":"+r+":"+n+": "+i);if(o.reason=i,o.filename=t.source,o.line=r,o.column=n,o.source=e,!t.silent)throw o}function s(t){var r=t.exec(e);if(r){var n=r[0];return i(n),e=e.slice(n.length),r}}function c(){s(x)}function u(e){var t;for(e=e||[];t=p();)!1!==t&&e.push(t);return e}function p(){var t=o();if("/"==e.charAt(0)&&"*"==e.charAt(1)){for(var r=2;S!=e.charAt(r)&&("*"!=e.charAt(r)||"/"!=e.charAt(r+1));)++r;if(r+=2,S===e.charAt(r-1))return l("End of comment missing");var a=e.slice(2,r-2);return n+=2,i(a),e=e.slice(r),n+=2,t({type:"comment",comment:a})}}function f(){var e=o(),t=s(b);if(t){if(p(),!s(w))return l("property missing ':'");var r=s(T),n=e({type:"declaration",property:M(t[0].replace(v,S)),value:r?M(r[0].replace(v,S)):S});return s(E),n}}return a.prototype.content=e,c(),function(){var e,t=[];for(u(t);e=f();)!1!==e&&(t.push(e),u(t));return t}()}(e),l="function"==typeof t,s=0,c=a.length;s<c;s++)i=(r=a[s]).property,o=r.value,l?t(i,o,r):o&&(n||(n={}),n[i]=o);return n},O=y((function(e,t){t.__esModule=!0,t.camelCase=void 0;var r=/^--[a-zA-Z0-9-]+$/,n=/-([a-z])/g,i=/^[^-]+$/,o=/^-(webkit|moz|ms|o|khtml)-/,a=function(e,t){return t.toUpperCase()},l=function(e,t){return t+"-"};t.camelCase=function(e,t){return void 0===t&&(t={}),function(e){return!e||i.test(e)||r.test(e)}(e)?e:(e=e.toLowerCase(),t.reactCompat||(e=e.replace(o,l)),e.replace(n,a))}})),A=y((function(e,t){var r=g&&g.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};t.__esModule=!0;var n=r(F);t.default=function(e,t){var r={};return e&&"string"==typeof e?(n.default(e,(function(e,n){e&&n&&(r[O.camelCase(e,t)]=n)})),r):r}})).default;var P={reactCompat:!0};var R={PRESERVE_CUSTOM_ATTRIBUTES:r.default.version.split(".")[0]>=16,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}},setStyleProp:function(e,t){null!=e&&(t.style=A(e,P))}},D=R.setStyleProp,L=h.html,N=h.svg,B=h.isCustomAttribute,z=Object.prototype.hasOwnProperty;var I=function(e){var t,r,n,i;e=e||{};var o={};for(t in e)n=e[t],B(t)?o[t]=n:(r=t.toLowerCase(),z.call(L,r)?o[(i=L[r]).propertyName]=!!(i.hasBooleanValue||i.hasOverloadedBooleanValue&&!n)||n:z.call(N,t)?o[(i=N[t]).propertyName]=n:R.PRESERVE_CUSTOM_ATTRIBUTES&&(o[t]=n));return D(e.style,o),o},H=R.setStyleProp;function V(e){return R.PRESERVE_CUSTOM_ATTRIBUTES&&"tag"===e.type&&R.isCustomComponent(e.name,e.attribs)}for(var U,_=function e(t,n){for(var i,o,a,l,s=(n=n||{}).library||r.default,c=s.cloneElement,u=s.createElement,p=s.isValidElement,f=[],d="function"==typeof n.replace,m=n.trim,h=0,g=t.length;h<g;h++)if(i=t[h],d&&p(o=n.replace(i)))g>1&&(o=c(o,{key:o.key||h})),f.push(o);else if("text"!==i.type){switch(a=i.attribs,V(i)?H(a.style,a):a&&(a=I(a)),l=null,i.type){case"script":case"style":i.children[0]&&(a.dangerouslySetInnerHTML={__html:i.children[0].data});break;case"tag":"textarea"===i.name&&i.children[0]?a.defaultValue=i.children[0].data:i.children&&i.children.length&&(l=e(i.children,n));break;default:continue}g>1&&(a.key=h),f.push(u(i.name,a,l))}else m?i.data.trim()&&f.push(i.data):f.push(i.data);return 1===f.length?f[0]:f},j=["animateMotion","animateTransform","clipPath","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussainBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","foreignObject","linearGradient","radialGradient","textPath"],X={},q=0,Y=j.length;q<Y;q++)X[(U=j[q]).toLowerCase()]=U;function $(e){for(var t,r={},n=0,i=e.length;n<i;n++)r[(t=e[n]).name]=t.value;return r}function G(e){var t=function(e){return X[e]}(e=e.toLowerCase());return t||e}var W={formatAttributes:$,formatDOM:function e(t,r,n){r=r||null;for(var i,o,a,l=[],s=0,c=t.length;s<c;s++){switch(i=t[s],a={next:null,prev:l[s-1]||null,parent:r},(o=l[s-1])&&(o.next=a),"#"!==i.nodeName[0]&&(a.name=G(i.nodeName),a.attribs={},i.attributes&&i.attributes.length&&(a.attribs=$(i.attributes))),i.nodeType){case 1:"script"===a.name||"style"===a.name?a.type=a.name:a.type="tag",a.children=e(i.childNodes,a);break;case 3:a.type="text",a.data=i.nodeValue;break;case 8:a.type="comment",a.data=i.nodeValue}l.push(a)}return n&&(l.unshift({name:n.substring(0,n.indexOf(" ")).toLowerCase(),data:n,type:"directive",next:l[0]?l[0]:null,prev:null,parent:r}),l[1]&&(l[1].prev=l[0])),l},isIE:function(e){return e?document.documentMode===e:/(MSIE |Trident\/|Edge\/)/.test(navigator.userAgent)}},Z="html",K="head",J="body",Q=/<([a-zA-Z]+[0-9]?)/,ee=/<head.*>/i,te=/<body.*>/i,re=/<(area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)(.*?)\/?>/gi,ne=W.isIE(9),ie=ne||W.isIE(),oe=function(){throw new Error("This browser does not support `document.implementation.createHTMLDocument`")},ae=function(){throw new Error("This browser does not support `DOMParser.prototype.parseFromString`")};if("function"==typeof window.DOMParser){var le=new window.DOMParser,se=ne?"text/xml":"text/html";oe=ae=function(e,t){return t&&(e="<"+t+">"+e+"</"+t+">"),ne&&(e=e.replace(re,"<$1$2$3/>")),le.parseFromString(e,se)}}if(document.implementation){var ce=document.implementation.createHTMLDocument(ie?"html-dom-parser":void 0);oe=function(e,t){if(t)return ce.documentElement.getElementsByTagName(t)[0].innerHTML=e,ce;try{return ce.documentElement.innerHTML=e,ce}catch(t){if(ae)return ae(e)}}}var ue,pe=document.createElement("template");pe.content&&(ue=function(e){return pe.innerHTML=e,pe.content.childNodes});var fe=function(e){var t,r,n,i,o=e.match(Q);switch(o&&o[1]&&(t=o[1].toLowerCase()),t){case Z:return r=ae(e),ee.test(e)||(n=r.getElementsByTagName(K)[0])&&n.parentNode.removeChild(n),te.test(e)||(n=r.getElementsByTagName(J)[0])&&n.parentNode.removeChild(n),r.getElementsByTagName(Z);case K:case J:return i=oe(e).getElementsByTagName(t),te.test(e)&&ee.test(e)?i[0].parentNode.childNodes:i;default:return ue?ue(e):oe(e,J).getElementsByTagName(J)[0].childNodes}},de=W.formatDOM,me=W.isIE(9),he=/<(![a-zA-Z\s]+)>/;var ge=function(e){if("string"!=typeof e)throw new TypeError("First argument must be a string");if(!e)return[];var t,r=e.match(he);return r&&r[1]&&(t=r[1],me&&(e=e.replace(r[0],""))),de(fe(e),null,t)},ye={decodeEntities:!0,lowerCaseAttributeNames:!1};function ve(e,t){if("string"!=typeof e)throw new TypeError("First argument must be a string");return""===e?[]:_(ge(e,(t=t||{}).htmlparser2||ye),t)}ve.domToReact=_,ve.htmlToDOM=ge,ve.attributesToProps=I;var ke=ve,xe=ve;return ke.default=xe,ke})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).HTMLReactParser=t(e.React)}(this,(function(e){"use strict";function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=t(e),r={Properties:{autoFocus:4,accept:0,acceptCharset:0,accessKey:0,action:0,allowFullScreen:4,allowTransparency:0,alt:0,as:0,async:4,autoComplete:0,autoPlay:4,capture:4,cellPadding:0,cellSpacing:0,charSet:0,challenge:0,checked:5,cite:0,classID:0,className:0,cols:24,colSpan:0,content:0,contentEditable:0,contextMenu:0,controls:4,controlsList:0,coords:0,crossOrigin:0,data:0,dateTime:0,default:4,defer:4,dir:0,disabled:4,download:32,draggable:0,encType:0,form:0,formAction:0,formEncType:0,formMethod:0,formNoValidate:4,formTarget:0,frameBorder:0,headers:0,height:0,hidden:4,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:4,low:0,manifest:0,marginHeight:0,marginWidth:0,max:0,maxLength:0,media:0,mediaGroup:0,method:0,min:0,minLength:0,multiple:5,muted:5,name:0,nonce:0,noValidate:4,open:4,optimum:0,pattern:0,placeholder:0,playsInline:4,poster:0,preload:0,profile:0,radioGroup:0,readOnly:4,referrerPolicy:0,rel:0,required:4,reversed:4,role:0,rows:24,rowSpan:8,sandbox:0,scope:0,scoped:4,scrolling:0,seamless:4,selected:5,shape:0,size:24,sizes:0,span:24,spellCheck:0,src:0,srcDoc:0,srcLang:0,srcSet:0,start:8,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:4,itemType:0,itemID:0,itemRef:0,results:0,security:0,unselectable:0},DOMAttributeNames:{acceptCharset:"accept-charset",className:"class",htmlFor:"for",httpEquiv:"http-equiv"}},i={Properties:{accentHeight:0,accumulate:0,additive:0,alignmentBaseline:0,allowReorder:0,alphabetic:0,amplitude:0,arabicForm:0,ascent:0,attributeName:0,attributeType:0,autoReverse:0,azimuth:0,baseFrequency:0,baseProfile:0,baselineShift:0,bbox:0,begin:0,bias:0,by:0,calcMode:0,capHeight:0,clip:0,clipPath:0,clipRule:0,clipPathUnits:0,colorInterpolation:0,colorInterpolationFilters:0,colorProfile:0,colorRendering:0,contentScriptType:0,contentStyleType:0,cursor:0,cx:0,cy:0,d:0,decelerate:0,descent:0,diffuseConstant:0,direction:0,display:0,divisor:0,dominantBaseline:0,dur:0,dx:0,dy:0,edgeMode:0,elevation:0,enableBackground:0,end:0,exponent:0,externalResourcesRequired:0,fill:0,fillOpacity:0,fillRule:0,filter:0,filterRes:0,filterUnits:0,floodColor:0,floodOpacity:0,focusable:0,fontFamily:0,fontSize:0,fontSizeAdjust:0,fontStretch:0,fontStyle:0,fontVariant:0,fontWeight:0,format:0,from:0,fx:0,fy:0,g1:0,g2:0,glyphName:0,glyphOrientationHorizontal:0,glyphOrientationVertical:0,glyphRef:0,gradientTransform:0,gradientUnits:0,hanging:0,horizAdvX:0,horizOriginX:0,ideographic:0,imageRendering:0,in:0,in2:0,intercept:0,k:0,k1:0,k2:0,k3:0,k4:0,kernelMatrix:0,kernelUnitLength:0,kerning:0,keyPoints:0,keySplines:0,keyTimes:0,lengthAdjust:0,letterSpacing:0,lightingColor:0,limitingConeAngle:0,local:0,markerEnd:0,markerMid:0,markerStart:0,markerHeight:0,markerUnits:0,markerWidth:0,mask:0,maskContentUnits:0,maskUnits:0,mathematical:0,mode:0,numOctaves:0,offset:0,opacity:0,operator:0,order:0,orient:0,orientation:0,origin:0,overflow:0,overlinePosition:0,overlineThickness:0,paintOrder:0,panose1:0,pathLength:0,patternContentUnits:0,patternTransform:0,patternUnits:0,pointerEvents:0,points:0,pointsAtX:0,pointsAtY:0,pointsAtZ:0,preserveAlpha:0,preserveAspectRatio:0,primitiveUnits:0,r:0,radius:0,refX:0,refY:0,renderingIntent:0,repeatCount:0,repeatDur:0,requiredExtensions:0,requiredFeatures:0,restart:0,result:0,rotate:0,rx:0,ry:0,scale:0,seed:0,shapeRendering:0,slope:0,spacing:0,specularConstant:0,specularExponent:0,speed:0,spreadMethod:0,startOffset:0,stdDeviation:0,stemh:0,stemv:0,stitchTiles:0,stopColor:0,stopOpacity:0,strikethroughPosition:0,strikethroughThickness:0,string:0,stroke:0,strokeDasharray:0,strokeDashoffset:0,strokeLinecap:0,strokeLinejoin:0,strokeMiterlimit:0,strokeOpacity:0,strokeWidth:0,surfaceScale:0,systemLanguage:0,tableValues:0,targetX:0,targetY:0,textAnchor:0,textDecoration:0,textRendering:0,textLength:0,to:0,transform:0,u1:0,u2:0,underlinePosition:0,underlineThickness:0,unicode:0,unicodeBidi:0,unicodeRange:0,unitsPerEm:0,vAlphabetic:0,vHanging:0,vIdeographic:0,vMathematical:0,values:0,vectorEffect:0,version:0,vertAdvY:0,vertOriginX:0,vertOriginY:0,viewBox:0,viewTarget:0,visibility:0,widths:0,wordSpacing:0,writingMode:0,x:0,xHeight:0,x1:0,x2:0,xChannelSelector:0,xlinkActuate:0,xlinkArcrole:0,xlinkHref:0,xlinkRole:0,xlinkShow:0,xlinkTitle:0,xlinkType:0,xmlBase:0,xmlns:0,xmlnsXlink:0,xmlLang:0,xmlSpace:0,y:0,y1:0,y2:0,yChannelSelector:0,z:0,zoomAndPan:0},DOMAttributeNames:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDasharray:"stroke-dasharray",strokeDashoffset:"stroke-dashoffset",strokeLinecap:"stroke-linecap",strokeLinejoin:"stroke-linejoin",strokeMiterlimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",xlinkActuate:"xlink:actuate",xlinkArcrole:"xlink:arcrole",xlinkHref:"xlink:href",xlinkRole:"xlink:role",xlinkShow:"xlink:show",xlinkTitle:"xlink:title",xlinkType:"xlink:type",xmlBase:"xml:base",xmlnsXlink:"xmlns:xlink",xmlLang:"xml:lang",xmlSpace:"xml:space"}},o=1,a=4,l=8,s=24,c=32;function u(e,t){return(e&t)===t}function p(e,t,n){var r,i,p,f=e.Properties,d=e.DOMAttributeNames;for(i in f)r=d[i]||(n?i:i.toLowerCase()),p=f[i],t[r]={attributeName:r,propertyName:i,mustUseProperty:u(p,o),hasBooleanValue:u(p,a),hasNumericValue:u(p,l),hasPositiveNumericValue:u(p,s),hasOverloadedBooleanValue:u(p,c)}}var f={};p(r,f);var d={};p(i,d,!0);var h={};p(r,h),p(i,h,!0);var m={html:f,svg:d,properties:h,isCustomAttribute:RegExp.prototype.test.bind(new RegExp("^(data|aria)-[: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\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"))},g="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function y(e){var t={exports:{}};return e(t,t.exports),t.exports}var v=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,b=/\n/g,x=/^\s*/,k=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,w=/^:\s*/,T=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,O=/^[;\s]*/,E=/^\s+|\s+$/g,C="";function P(e){return e?e.replace(E,C):C}var S=function(e,t){var n,r=null;if(!e||"string"!=typeof e)return r;for(var i,o,a=function(e,t){if("string"!=typeof e)throw new TypeError("First argument must be a string");if(!e)return[];t=t||{};var n=1,r=1;function i(e){var t=e.match(b);t&&(n+=t.length);var i=e.lastIndexOf("\n");r=~i?e.length-i:r+e.length}function o(){var e={line:n,column:r};return function(t){return t.position=new a(e),c(),t}}function a(e){this.start=e,this.end={line:n,column:r},this.source=t.source}function l(i){var o=new Error(t.source+":"+n+":"+r+": "+i);if(o.reason=i,o.filename=t.source,o.line=n,o.column=r,o.source=e,!t.silent)throw o}function s(t){var n=t.exec(e);if(n){var r=n[0];return i(r),e=e.slice(r.length),n}}function c(){s(x)}function u(e){var t;for(e=e||[];t=p();)!1!==t&&e.push(t);return e}function p(){var t=o();if("/"==e.charAt(0)&&"*"==e.charAt(1)){for(var n=2;C!=e.charAt(n)&&("*"!=e.charAt(n)||"/"!=e.charAt(n+1));)++n;if(n+=2,C===e.charAt(n-1))return l("End of comment missing");var a=e.slice(2,n-2);return r+=2,i(a),e=e.slice(n),r+=2,t({type:"comment",comment:a})}}function f(){var e=o(),t=s(k);if(t){if(p(),!s(w))return l("property missing ':'");var n=s(T),r=e({type:"declaration",property:P(t[0].replace(v,C)),value:n?P(n[0].replace(v,C)):C});return s(O),r}}return a.prototype.content=e,c(),function(){var e,t=[];for(u(t);e=f();)!1!==e&&(t.push(e),u(t));return t}()}(e),l="function"==typeof t,s=0,c=a.length;s<c;s++)i=(n=a[s]).property,o=n.value,l?t(i,o,n):o&&(r||(r={}),r[i]=o);return r},M=y((function(e,t){t.__esModule=!0,t.camelCase=void 0;var n=/^--[a-zA-Z0-9-]+$/,r=/-([a-z])/g,i=/^[^-]+$/,o=/^-(webkit|moz|ms|o|khtml)-/,a=function(e,t){return t.toUpperCase()},l=function(e,t){return t+"-"};t.camelCase=function(e,t){return void 0===t&&(t={}),function(e){return!e||i.test(e)||n.test(e)}(e)?e:(e=e.toLowerCase(),t.reactCompat||(e=e.replace(o,l)),e.replace(r,a))}})),A=y((function(e,t){var n=g&&g.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};t.__esModule=!0;var r=n(S);t.default=function(e,t){var n={};return e&&"string"==typeof e?(r.default(e,(function(e,r){e&&r&&(n[M.camelCase(e,t)]=r)})),n):n}})).default;var F={reactCompat:!0};var N={PRESERVE_CUSTOM_ATTRIBUTES:n.default.version.split(".")[0]>=16,invertObject:function(e,t){if(!e||"object"!=typeof e)throw new TypeError("First argument must be an object");var n,r,i="function"==typeof t,o={},a={};for(n in e)r=e[n],i&&(o=t(n,r))&&2===o.length?a[o[0]]=o[1]:"string"==typeof r&&(a[r]=n);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}},setStyleProp:function(e,t){null!=e&&(t.style=A(e,F))}},R=N.setStyleProp,D=m.html,L=m.svg,_=m.isCustomAttribute,j=Object.prototype.hasOwnProperty;var B=function(e){var t,n,r,i;e=e||{};var o={};for(t in e)r=e[t],_(t)?o[t]=r:(n=t.toLowerCase(),j.call(D,n)?o[(i=D[n]).propertyName]=!!(i.hasBooleanValue||i.hasOverloadedBooleanValue&&!r)||r:j.call(L,t)?o[(i=L[t]).propertyName]=r:N.PRESERVE_CUSTOM_ATTRIBUTES&&(o[t]=r));return R(e.style,o),o},z=N.setStyleProp;function I(e){return N.PRESERVE_CUSTOM_ATTRIBUTES&&"tag"===e.type&&N.isCustomComponent(e.name,e.attribs)}for(var H,V=function e(t,r){for(var i,o,a,l,s=(r=r||{}).library||n.default,c=s.cloneElement,u=s.createElement,p=s.isValidElement,f=[],d="function"==typeof r.replace,h=r.trim,m=0,g=t.length;m<g;m++)if(i=t[m],d&&p(o=r.replace(i)))g>1&&(o=c(o,{key:o.key||m})),f.push(o);else if("text"!==i.type){switch(a=i.attribs,I(i)?z(a.style,a):a&&(a=B(a)),l=null,i.type){case"script":case"style":i.children[0]&&(a.dangerouslySetInnerHTML={__html:i.children[0].data});break;case"tag":"textarea"===i.name&&i.children[0]?a.defaultValue=i.children[0].data:i.children&&i.children.length&&(l=e(i.children,r));break;default:continue}g>1&&(a.key=m),f.push(u(i.name,a,l))}else h?i.data.trim()&&f.push(i.data):f.push(i.data);return 1===f.length?f[0]:f},U=["animateMotion","animateTransform","clipPath","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussainBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","foreignObject","linearGradient","radialGradient","textPath"],X=y((function(e,t){var n,r=g&&g.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),i=g&&g.__assign||function(){return(i=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0}),t.cloneNode=t.Element=t.NodeWithChildren=t.ProcessingInstruction=t.Comment=t.Text=t.DataNode=t.Node=void 0;var o=new Map([["tag",1],["script",1],["style",1],["directive",1],["text",3],["cdata",4],["comment",8]]),a=function(){function e(e){this.type=e,this.parent=null,this.prev=null,this.next=null,this.startIndex=null,this.endIndex=null}return Object.defineProperty(e.prototype,"nodeType",{get:function(){var e;return null!==(e=o.get(this.type))&&void 0!==e?e:1},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"parentNode",{get:function(){return this.parent},set:function(e){this.parent=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"previousSibling",{get:function(){return this.prev},set:function(e){this.prev=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"nextSibling",{get:function(){return this.next},set:function(e){this.next=e},enumerable:!1,configurable:!0}),e.prototype.cloneNode=function(e){return void 0===e&&(e=!1),d(this,e)},e}();t.Node=a;var l=function(e){function t(t,n){var r=e.call(this,t)||this;return r.data=n,r}return r(t,e),Object.defineProperty(t.prototype,"nodeValue",{get:function(){return this.data},set:function(e){this.data=e},enumerable:!1,configurable:!0}),t}(a);t.DataNode=l;var s=function(e){function t(t){return e.call(this,"text",t)||this}return r(t,e),t}(l);t.Text=s;var c=function(e){function t(t){return e.call(this,"comment",t)||this}return r(t,e),t}(l);t.Comment=c;var u=function(e){function t(t,n){var r=e.call(this,"directive",n)||this;return r.name=t,r}return r(t,e),t}(l);t.ProcessingInstruction=u;var p=function(e){function t(t,n){var r=e.call(this,t)||this;return r.children=n,r}return r(t,e),Object.defineProperty(t.prototype,"firstChild",{get:function(){var e;return null!==(e=this.children[0])&&void 0!==e?e:null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"lastChild",{get:function(){return this.children.length>0?this.children[this.children.length-1]:null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"childNodes",{get:function(){return this.children},set:function(e){this.children=e},enumerable:!1,configurable:!0}),t}(a);t.NodeWithChildren=p;var f=function(e){function t(t,n,r){void 0===r&&(r=[]);var i=e.call(this,"script"===t?"script":"style"===t?"style":"tag",r)||this;return i.name=t,i.attribs=n,i.attribs=n,i}return r(t,e),Object.defineProperty(t.prototype,"tagName",{get:function(){return this.name},set:function(e){this.name=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"attributes",{get:function(){var e=this;return Object.keys(this.attribs).map((function(t){return{name:t,value:e.attribs[t]}}))},enumerable:!1,configurable:!0}),t}(p);function d(e,t){switch(void 0===t&&(t=!1),e.type){case"text":return new s(e.data);case"directive":var n=e;return new u(n.name,n.data);case"comment":return new c(e.data);case"tag":case"script":case"style":var r=e,o=t?h(r.children):[],a=new f(r.name,i({},r.attribs),o);return o.forEach((function(e){return e.parent=a})),a;case"cdata":o=t?h(e.children):[];var l=new p("cdata",o);return o.forEach((function(e){return e.parent=l})),l;case"doctype":throw new Error("Not implemented yet: ElementType.Doctype case")}}function h(e){for(var t=e.map((function(e){return d(e,!0)})),n=1;n<t.length;n++)t[n].prev=t[n-1],t[n-1].next=t[n];return t}t.Element=f,t.cloneNode=d})),q=U,W=X.Comment,Y=X.Element,$=X.ProcessingInstruction,G=X.Text,Z={},K=0,J=q.length;K<J;K++)H=q[K],Z[H.toLowerCase()]=H;function Q(e){for(var t,n={},r=0,i=e.length;r<i;r++)n[(t=e[r]).name]=t.value;return n}function ee(e){var t=function(e){return Z[e]}(e=e.toLowerCase());return t||e}var te={formatAttributes:Q,formatDOM:function e(t,n,r){var i,o,a;n=n||null;for(var l=[],s=0,c=t.length;s<c;s++){switch((i=t[s]).nodeType){case 1:(o=new Y(ee(i.nodeName),Q(i.attributes))).children=e(i.childNodes,o);break;case 3:o=new G(i.nodeValue);break;case 8:o=new W(i.nodeValue)}(a=l[s-1]||null)&&(a.next=o),o.parent=n,o.prev=a,o.next=null,l.push(o)}return r&&((o=new $(r.substring(0,r.indexOf(" ")).toLowerCase(),r)).next=l[0]||null,o.parent=n,l.unshift(o),l[1]&&(l[1].prev=l[0])),l},isIE:function(e){return e?document.documentMode===e:/(MSIE |Trident\/|Edge\/)/.test(navigator.userAgent)}},ne="html",re="head",ie="body",oe=/<([a-zA-Z]+[0-9]?)/,ae=/<head.*>/i,le=/<body.*>/i,se=/<(area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)(.*?)\/?>/gi,ce=te.isIE(9),ue=ce||te.isIE(),pe=function(){throw new Error("This browser does not support `document.implementation.createHTMLDocument`")},fe=function(){throw new Error("This browser does not support `DOMParser.prototype.parseFromString`")};if("function"==typeof window.DOMParser){var de=new window.DOMParser,he=ce?"text/xml":"text/html";pe=fe=function(e,t){return t&&(e="<"+t+">"+e+"</"+t+">"),ce&&(e=e.replace(se,"<$1$2$3/>")),de.parseFromString(e,he)}}if(document.implementation){var me=document.implementation.createHTMLDocument(ue?"html-dom-parser":void 0);pe=function(e,t){if(t)return me.documentElement.getElementsByTagName(t)[0].innerHTML=e,me;try{return me.documentElement.innerHTML=e,me}catch(t){if(fe)return fe(e)}}}var ge,ye=document.createElement("template");ye.content&&(ge=function(e){return ye.innerHTML=e,ye.content.childNodes});var ve=function(e){var t,n,r,i,o=e.match(oe);switch(o&&o[1]&&(t=o[1].toLowerCase()),t){case ne:return n=fe(e),ae.test(e)||(r=n.getElementsByTagName(re)[0])&&r.parentNode.removeChild(r),le.test(e)||(r=n.getElementsByTagName(ie)[0])&&r.parentNode.removeChild(r),n.getElementsByTagName(ne);case re:case ie:return i=pe(e).getElementsByTagName(t),le.test(e)&&ae.test(e)?i[0].parentNode.childNodes:i;default:return ge?ge(e):pe(e,ie).getElementsByTagName(ie)[0].childNodes}},be=te.formatDOM,xe=te.isIE(9),ke=/<(![a-zA-Z\s]+)>/;var we=function(e){if("string"!=typeof e)throw new TypeError("First argument must be a string");if(!e)return[];var t,n=e.match(ke);return n&&n[1]&&(t=n[1],xe&&(e=e.replace(n[0],""))),be(ve(e),null,t)},Te={decodeEntities:!0,lowerCaseAttributeNames:!1};function Oe(e,t){if("string"!=typeof e)throw new TypeError("First argument must be a string");return""===e?[]:V(we(e,(t=t||{}).htmlparser2||Te),t)}Oe.domToReact=V,Oe.htmlToDOM=we,Oe.attributesToProps=B;var Ee=Oe,Ce=Oe;return Ee.default=Ce,Ee})); | ||
//# sourceMappingURL=html-react-parser.min.js.map |
@@ -1,10 +0,22 @@ | ||
// TypeScript Version: 3.3 | ||
// TypeScript Version: 4.1 | ||
import { DomElement, ParserOptions } from 'htmlparser2'; | ||
import domToReact from './lib/dom-to-react'; | ||
import attributesToProps from './lib/attributes-to-props'; | ||
import { ParserOptions } from 'htmlparser2'; | ||
import { | ||
Comment, | ||
DomHandlerOptions, | ||
Element, | ||
ProcessingInstruction, | ||
Text | ||
} from 'domhandler'; | ||
import htmlToDOM from 'html-dom-parser'; | ||
import attributesToProps from './lib/attributes-to-props'; | ||
import domToReact from './lib/dom-to-react'; | ||
export { attributesToProps, domToReact, htmlToDOM }; | ||
export type HTMLParser2Options = ParserOptions & DomHandlerOptions; | ||
export type DOMNode = Comment | Element | ProcessingInstruction | Text; | ||
export interface HTMLReactParserOptions { | ||
htmlparser2?: ParserOptions; | ||
htmlparser2?: HTMLParser2Options; | ||
@@ -23,3 +35,3 @@ library?: { | ||
replace?: ( | ||
domNode: DomElement | ||
domNode: DOMNode | ||
) => JSX.Element | object | void | undefined | null | false; | ||
@@ -37,9 +49,5 @@ | ||
*/ | ||
declare function HTMLReactParser( | ||
export default function HTMLReactParser( | ||
html: string, | ||
options?: HTMLReactParserOptions | ||
): ReturnType<typeof domToReact>; | ||
export { DomElement, ParserOptions, domToReact, htmlToDOM, attributesToProps }; | ||
export default HTMLReactParser; |
@@ -1,11 +0,12 @@ | ||
// TypeScript Version: 3.3 | ||
// TypeScript Version: 4.1 | ||
export type Attributes = Record<string, string>; | ||
export type Props = Attributes; | ||
/** | ||
* Converts HTML/SVG DOM attributes to React props. | ||
* | ||
* @param attributes - The HTML/SVG DOM attributes. | ||
* @returns - The React props. | ||
* @param attributes - HTML/SVG DOM attributes. | ||
* @return - React props. | ||
*/ | ||
export default function attributesToProps( | ||
attributes: { [key: string]: string } | ||
): { [key: string]: string }; | ||
export default function attributesToProps(attributes: Attributes): Props; |
@@ -1,16 +0,17 @@ | ||
// TypeScript Version: 3.3 | ||
// TypeScript Version: 4.1 | ||
import { HTMLReactParserOptions } from '..'; | ||
import { DomElement } from 'domhandler'; | ||
import { DOMNode, HTMLReactParserOptions } from '..'; | ||
export { DOMNode, HTMLReactParserOptions }; | ||
/** | ||
* Converts DOM nodes to JSX element(s). | ||
* | ||
* @param nodes - DOM nodes. | ||
* @param options - Parser options. | ||
* @returns - JSX element(s). | ||
* @param nodes - DOM nodes. | ||
* @param options - Parser options. | ||
* @return - JSX element(s). | ||
*/ | ||
export default function domToReact( | ||
nodes: DomElement[], | ||
nodes: DOMNode[], | ||
options?: HTMLReactParserOptions | ||
): JSX.Element | JSX.Element[]; | ||
): string | JSX.Element | JSX.Element[]; |
@@ -8,3 +8,3 @@ var React = require('react'); | ||
/** | ||
* Converts DOM nodes to React elements. | ||
* Converts DOM nodes to JSX element(s). | ||
* | ||
@@ -15,3 +15,3 @@ * @param {DomElement[]} nodes - DOM nodes. | ||
* @param {object} [options.library] - Library (React/Preact/etc.). | ||
* @return {string|ReactElement|ReactElement[]} | ||
* @return {string|JSX.Element|JSX.Element[]} | ||
*/ | ||
@@ -18,0 +18,0 @@ function domToReact(nodes, options) { |
{ | ||
"name": "html-react-parser", | ||
"version": "0.14.3", | ||
"version": "1.0.0", | ||
"description": "HTML to React parser.", | ||
@@ -35,4 +35,3 @@ "author": "Mark <mark@remarkablemark.org>", | ||
"dependencies": { | ||
"@types/htmlparser2": "3.10.2", | ||
"html-dom-parser": "0.3.0", | ||
"html-dom-parser": "0.5.0", | ||
"react-property": "1.0.1", | ||
@@ -39,0 +38,0 @@ "style-to-js": "1.1.0" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
311661
4
2268
2
+ Addeddom-serializer@1.4.1(transitive)
+ Addeddomhandler@3.3.04.3.1(transitive)
+ Addeddomutils@2.8.0(transitive)
+ Addedhtml-dom-parser@0.5.0(transitive)
+ Addedhtmlparser2@4.1.0(transitive)
- Removed@types/htmlparser2@3.10.2
- Removed@types/domhandler@2.4.12.4.5(transitive)
- Removed@types/domutils@1.7.8(transitive)
- Removed@types/htmlparser2@3.10.2(transitive)
- Removed@types/node@22.13.8(transitive)
- Removeddom-serializer@0.2.2(transitive)
- Removeddomelementtype@1.3.1(transitive)
- Removeddomhandler@2.4.2(transitive)
- Removeddomutils@1.7.0(transitive)
- Removedentities@1.1.2(transitive)
- Removedhtml-dom-parser@0.3.0(transitive)
- Removedhtmlparser2@3.10.1(transitive)
- Removedinherits@2.0.4(transitive)
- Removedreadable-stream@3.6.2(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedstring_decoder@1.3.0(transitive)
- Removedundici-types@6.20.0(transitive)
- Removedutil-deprecate@1.0.2(transitive)
Updatedhtml-dom-parser@0.5.0