html-react-parser
Advanced tools
Comparing version 0.0.7 to 0.1.0
@@ -57,3 +57,3 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
/* WEBPACK VAR INJECTION */(function(process) {'use strict'; | ||
'use strict'; | ||
@@ -64,7 +64,3 @@ /** | ||
var domToReact = __webpack_require__(4); | ||
var htmlToDOM = ( | ||
process.browser && process.title === 'browser' ? | ||
__webpack_require__(5) : | ||
__webpack_require__(13) | ||
); | ||
var htmlToDOM = __webpack_require__(7); | ||
@@ -74,3 +70,3 @@ /** | ||
* | ||
* @param {String} html - The HTML. | ||
* @param {String} html - The HTML string. | ||
* @param {Object} [options] - The additional options. | ||
@@ -82,3 +78,3 @@ * @param {Function} [options.replace] - The replace method. | ||
if (typeof html !== 'string') { | ||
throw new Error('`HTMLReactParser`: The first argument must be a string.'); | ||
throw new TypeError('First argument must be a string'); | ||
} | ||
@@ -93,3 +89,2 @@ return domToReact(htmlToDOM(html), options); | ||
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(8))) | ||
@@ -110,3 +105,3 @@ /***/ }, | ||
if (typeof string !== 'string') { | ||
throw new Error('`camelCase`: first argument must be a string.'); | ||
throw new TypeError('First argument must be a string'); | ||
} | ||
@@ -138,3 +133,3 @@ | ||
if (typeof obj !== 'object' || !obj) { // null is an object | ||
throw new Error('`invert`: First argument must be an object.'); | ||
throw new TypeError('First argument must be an object'); | ||
} | ||
@@ -401,3 +396,3 @@ | ||
var utilities = __webpack_require__(1); | ||
var propertyConfig = __webpack_require__(6); | ||
var propertyConfig = __webpack_require__(5); | ||
@@ -603,158 +598,2 @@ /** | ||
/* 5 */ | ||
/***/ function(module, exports) { | ||
'use strict'; | ||
/** | ||
* Format the browser DOM attributes. | ||
* | ||
* @param {NamedNodeMap} - The attributes. | ||
* @return {Object} | ||
*/ | ||
function formatAttributes(attributes) { | ||
var result = {}; | ||
var attribute; | ||
// NamedNodeMap is array-like | ||
for (var i = 0, len = attributes.length; i < len; i++) { | ||
attribute = attributes[i]; | ||
result[attribute.name] = attribute.value; | ||
} | ||
return result; | ||
} | ||
/** | ||
* Format the browser DOM nodes to match that of `htmlparser2.parseDOM`. | ||
* | ||
* @param {NodeList} nodes - The DOM nodes. | ||
* @param {Object} [parentNode] - The parent node that's already formatted. | ||
* @return {Object} | ||
*/ | ||
function formatDOM(nodes, parentNode) { | ||
var result = []; | ||
var node; | ||
var prevNode; | ||
var nodeObj; | ||
// 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: parentNode || null | ||
}; | ||
// 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.indexOf('#') !== 0) { | ||
nodeObj.name = node.nodeName.toLowerCase(); | ||
// also, type "tag" nodes 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 | ||
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); | ||
break; | ||
// 2 = attribute | ||
// 3 = text | ||
case 3: | ||
nodeObj.type = 'text'; | ||
nodeObj.data = node.nodeValue; | ||
break; | ||
// 8 = comment | ||
case 8: | ||
nodeObj.type = 'comment'; | ||
nodeObj.data = node.nodeValue; | ||
break; | ||
default: | ||
break; | ||
} | ||
result.push(nodeObj); | ||
} | ||
return result; | ||
} | ||
/** | ||
* Parse HTML string to DOM nodes. | ||
* This uses the browser DOM API. | ||
* | ||
* @param {String} html - The HTML. | ||
* @return {Object} - The DOM nodes. | ||
*/ | ||
function htmlToDOMClient(html) { | ||
// from `<p>` or `<p style="">` get `p` | ||
var match = typeof html === 'string' ? html.match(/<(.+?)[>\s]/) : null; | ||
var tagName; | ||
var parentNode; | ||
var nodes; | ||
if (match && typeof match[1] === 'string') { | ||
tagName = match[1].trim().toLowerCase(); | ||
} | ||
// `DOMParser` can parse full HTML | ||
// https://developer.mozilla.org/en-US/docs/Web/API/DOMParser | ||
if (tagName && window.DOMParser) { | ||
var parser = new window.DOMParser(); | ||
var doc = parser.parseFromString(html, 'text/html'); | ||
// <head> and <body> are siblings | ||
if (tagName === 'head' || tagName === 'body') { | ||
nodes = doc.getElementsByTagName(tagName); | ||
// document's child nodes | ||
} else if (tagName === 'html') { | ||
nodes = doc.childNodes; | ||
// get the element's parent's child nodes | ||
// do this in case of adjacent elements | ||
} else { | ||
parentNode = doc.getElementsByTagName(tagName)[0].parentNode; | ||
nodes = parentNode.childNodes; | ||
} | ||
// otherwise, use `innerHTML` | ||
// but this will strip out tags like <html> and <body> | ||
} else { | ||
parentNode = document.createElement('div'); | ||
parentNode.innerHTML = html; | ||
nodes = parentNode.childNodes; | ||
} | ||
return formatDOM(nodes); | ||
} | ||
/** | ||
* Export HTML to DOM parser (client). | ||
*/ | ||
module.exports = htmlToDOMClient; | ||
/***/ }, | ||
/* 6 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
@@ -823,3 +662,3 @@ | ||
/***/ }, | ||
/* 7 */ | ||
/* 6 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
@@ -878,187 +717,234 @@ | ||
/***/ }, | ||
/* 8 */ | ||
/***/ function(module, exports) { | ||
/* 7 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
// shim for using process in browser | ||
var process = module.exports = {}; | ||
'use strict'; | ||
// cached from whatever global is present so that test runners that stub it | ||
// don't break things. But we need to wrap it in a try catch in case it is | ||
// wrapped in strict mode code which doesn't define any globals. It's inside a | ||
// function because try/catches deoptimize in certain engines. | ||
/** | ||
* Module dependencies. | ||
*/ | ||
var utilities = __webpack_require__(8); | ||
var formatDOM = utilities.formatDOM; | ||
var cachedSetTimeout; | ||
var cachedClearTimeout; | ||
/** | ||
* Parse HTML string to DOM nodes. | ||
* This uses the browser DOM API. | ||
* | ||
* @param {String} html - The HTML. | ||
* @return {Object} - The DOM nodes. | ||
*/ | ||
function parseDOM(html) { | ||
if (typeof html !== 'string') { | ||
throw new TypeError('First argument must be a string.'); | ||
} | ||
function defaultSetTimout() { | ||
throw new Error('setTimeout has not been defined'); | ||
} | ||
function defaultClearTimeout () { | ||
throw new Error('clearTimeout has not been defined'); | ||
} | ||
(function () { | ||
try { | ||
if (typeof setTimeout === 'function') { | ||
cachedSetTimeout = setTimeout; | ||
} else { | ||
cachedSetTimeout = defaultSetTimout; | ||
// try to match the tags | ||
var match = html.match(/<[^\/](.+?)>/g); | ||
var nodes; | ||
if (match && match.length) { | ||
var tagMatch = match[0]; | ||
// directive matched | ||
if (/<![^-]/.test(tagMatch)) { | ||
var directive = ( | ||
// remove angle brackets | ||
tagMatch | ||
.substring(1, tagMatch.length - 1) | ||
.trim() | ||
); | ||
// tag name can no longer be first match item | ||
tagMatch = match[1]; | ||
// remove directive from html | ||
html = html.substring(html.indexOf('>') + 1); | ||
} | ||
} catch (e) { | ||
cachedSetTimeout = defaultSetTimout; | ||
} | ||
try { | ||
if (typeof clearTimeout === 'function') { | ||
cachedClearTimeout = clearTimeout; | ||
} else { | ||
cachedClearTimeout = defaultClearTimeout; | ||
// first tag name matched | ||
if (tagMatch) { | ||
var tagName = ( | ||
// keep only tag name | ||
tagMatch | ||
.substring(1, tagMatch.indexOf(' ')) | ||
.trim() | ||
.toLowerCase() | ||
) | ||
} | ||
} catch (e) { | ||
cachedClearTimeout = defaultClearTimeout; | ||
} | ||
} ()) | ||
function runTimeout(fun) { | ||
if (cachedSetTimeout === setTimeout) { | ||
//normal enviroments in sane situations | ||
return setTimeout(fun, 0); | ||
} | ||
// if setTimeout wasn't available but was latter defined | ||
if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { | ||
cachedSetTimeout = setTimeout; | ||
return setTimeout(fun, 0); | ||
} | ||
try { | ||
// when when somebody has screwed with setTimeout but no I.E. maddness | ||
return cachedSetTimeout(fun, 0); | ||
} catch(e){ | ||
try { | ||
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally | ||
return cachedSetTimeout.call(null, fun, 0); | ||
} catch(e){ | ||
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error | ||
return cachedSetTimeout.call(this, fun, 0); | ||
} | ||
} | ||
// create html document to parse top-level nodes | ||
if (['html', 'head', 'body'].indexOf(tagName) > -1) { | ||
var doc; | ||
} | ||
function runClearTimeout(marker) { | ||
if (cachedClearTimeout === clearTimeout) { | ||
//normal enviroments in sane situations | ||
return clearTimeout(marker); | ||
} | ||
// if clearTimeout wasn't available but was latter defined | ||
if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { | ||
cachedClearTimeout = clearTimeout; | ||
return clearTimeout(marker); | ||
} | ||
try { | ||
// when when somebody has screwed with setTimeout but no I.E. maddness | ||
return cachedClearTimeout(marker); | ||
} catch (e){ | ||
try { | ||
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally | ||
return cachedClearTimeout.call(null, marker); | ||
} catch (e){ | ||
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. | ||
// Some versions of I.E. have different rules for clearTimeout vs setTimeout | ||
return cachedClearTimeout.call(this, marker); | ||
// `new DOMParser().parseFromString()` | ||
// https://developer.mozilla.org/en-US/docs/Web/API/DOMParser#Parsing_an_SVG_or_HTML_document | ||
if (window.DOMParser) { | ||
doc = new window.DOMParser().parseFromString(html, 'text/html'); | ||
// `DOMImplementation.createHTMLDocument()` | ||
// https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createHTMLDocument | ||
} else if (document.implementation.createHTMLDocument) { | ||
doc = document.implementation.createHTMLDocument(); | ||
doc.documentElement.innerHTML = html; | ||
doc.removeChild(doc.childNodes[0]); // remove doctype | ||
} | ||
} | ||
// html | ||
if (tagName === 'html') { | ||
nodes = doc.childNodes; | ||
// head and body | ||
} else { | ||
nodes = ( | ||
// do this so attributes are kept | ||
// but there may be an extra head/body node | ||
doc.getElementsByTagName(tagName)[0] | ||
.parentNode | ||
.childNodes | ||
); | ||
} | ||
// `innerHTML` approach | ||
} else { | ||
var container = document.createElement('body'); | ||
container.innerHTML = html; | ||
nodes = container.childNodes; | ||
} | ||
return formatDOM(nodes, null, directive); | ||
} | ||
var queue = []; | ||
var draining = false; | ||
var currentQueue; | ||
var queueIndex = -1; | ||
function cleanUpNextTick() { | ||
if (!draining || !currentQueue) { | ||
return; | ||
/** | ||
* Export HTML to DOM parser (client). | ||
*/ | ||
module.exports = parseDOM; | ||
/***/ }, | ||
/* 8 */ | ||
/***/ function(module, exports) { | ||
'use strict'; | ||
/** | ||
* Format DOM attributes to an associative array. | ||
* | ||
* @param {NamedNodeMap} - The list of attributes. | ||
* @return {Object} - The object of attributes. | ||
*/ | ||
function formatAttributes(attributes) { | ||
var result = {}; | ||
var attribute; | ||
// NamedNodeMap is array-like | ||
for (var i = 0, len = attributes.length; i < len; i++) { | ||
attribute = attributes[i]; | ||
result[attribute.name] = attribute.value; | ||
} | ||
draining = false; | ||
if (currentQueue.length) { | ||
queue = currentQueue.concat(queue); | ||
} else { | ||
queueIndex = -1; | ||
} | ||
if (queue.length) { | ||
drainQueue(); | ||
} | ||
return result; | ||
} | ||
function drainQueue() { | ||
if (draining) { | ||
return; | ||
} | ||
var timeout = runTimeout(cleanUpNextTick); | ||
draining = true; | ||
/** | ||
* Format the browser DOM nodes to mimic the output of `htmlparser2.parseDOM()`. | ||
* | ||
* @param {NodeList} nodes - The DOM nodes. | ||
* @param {Object} [parentObj] - The formatted parent node. | ||
* @param {String} [directive] - The directive. | ||
* @return {Object} - The formatted DOM object. | ||
*/ | ||
function formatDOM(nodes, parentObj, directive) { | ||
parentObj = parentObj || null; | ||
var len = queue.length; | ||
while(len) { | ||
currentQueue = queue; | ||
queue = []; | ||
while (++queueIndex < len) { | ||
if (currentQueue) { | ||
currentQueue[queueIndex].run(); | ||
var result = []; | ||
var node; | ||
var prevNode; | ||
var nodeObj; | ||
// 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 | ||
}; | ||
// 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.indexOf('#') !== 0) { | ||
nodeObj.name = node.nodeName.toLowerCase(); | ||
// also, nodes of type "tag" have "attribs" | ||
nodeObj.attribs = {}; // default | ||
if (node.attributes && node.attributes.length) { | ||
nodeObj.attribs = formatAttributes(node.attributes); | ||
} | ||
} | ||
queueIndex = -1; | ||
len = queue.length; | ||
// set the node type | ||
// e.g., "tag" | ||
switch (node.nodeType) { | ||
// 1 = element | ||
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); | ||
break; | ||
// 2 = attribute | ||
// 3 = text | ||
case 3: | ||
nodeObj.type = 'text'; | ||
nodeObj.data = node.nodeValue; | ||
break; | ||
// 8 = comment | ||
case 8: | ||
nodeObj.type = 'comment'; | ||
nodeObj.data = node.nodeValue; | ||
break; | ||
default: | ||
break; | ||
} | ||
result.push(nodeObj); | ||
} | ||
currentQueue = null; | ||
draining = false; | ||
runClearTimeout(timeout); | ||
} | ||
process.nextTick = function (fun) { | ||
var args = new Array(arguments.length - 1); | ||
if (arguments.length > 1) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
args[i - 1] = arguments[i]; | ||
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 | ||
}); | ||
if (result[1]) { | ||
result[1].prev = result[0]; | ||
} | ||
} | ||
queue.push(new Item(fun, args)); | ||
if (queue.length === 1 && !draining) { | ||
runTimeout(drainQueue); | ||
} | ||
}; | ||
// v8 likes predictible objects | ||
function Item(fun, array) { | ||
this.fun = fun; | ||
this.array = array; | ||
return result; | ||
} | ||
Item.prototype.run = function () { | ||
this.fun.apply(null, this.array); | ||
}; | ||
process.title = 'browser'; | ||
process.browser = true; | ||
process.env = {}; | ||
process.argv = []; | ||
process.version = ''; // empty string to avoid regexp issues | ||
process.versions = {}; | ||
function noop() {} | ||
process.on = noop; | ||
process.addListener = noop; | ||
process.once = noop; | ||
process.off = noop; | ||
process.removeListener = noop; | ||
process.removeAllListeners = noop; | ||
process.emit = noop; | ||
process.binding = function (name) { | ||
throw new Error('process.binding is not supported'); | ||
/** | ||
* Export utilities. | ||
*/ | ||
module.exports = { | ||
formatAttributes: formatAttributes, | ||
formatDOM: formatDOM | ||
}; | ||
process.cwd = function () { return '/' }; | ||
process.chdir = function (dir) { | ||
throw new Error('process.chdir is not supported'); | ||
}; | ||
process.umask = function() { return 0; }; | ||
/***/ }, | ||
@@ -1083,3 +969,3 @@ /* 9 */ | ||
var invariant = __webpack_require__(7); | ||
var invariant = __webpack_require__(6); | ||
@@ -1633,8 +1519,2 @@ function checkMask(value, bitmask) { | ||
/***/ }, | ||
/* 13 */ | ||
/***/ function(module, exports) { | ||
/* (ignored) */ | ||
/***/ } | ||
@@ -1641,0 +1521,0 @@ /******/ ]) |
@@ -1,1 +0,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)}(this,function(e){return function(e){function t(n){if(r[n])return r[n].exports;var i=r[n]={exports:{},id:n,loaded:!1};return e[n].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){(function(t){"use strict";function n(e,t){if("string"!=typeof e)throw new Error("`HTMLReactParser`: The first argument must be a string.");return i(o(e),t)}var i=r(4),o=r(t.browser&&"browser"===t.title?5:13);e.exports=n}).call(t,r(8))},function(e,t){"use strict";function r(e){if("string"!=typeof e)throw new Error("`camelCase`: first argument must be a string.");if(e.indexOf("-")>0){for(var t=e.toLowerCase().split("-"),r=1,n=t.length;r<n;r++)t[r]=t[r].charAt(0).toUpperCase()+t[r].slice(1);return t.join("")}return e}function n(e,t){if("object"!=typeof e||!e)throw new Error("`invert`: 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),o&&2===o.length)?a[o[0]]=o[1]:"string"==typeof n&&(a[n]=r);return a}e.exports={camelCase:r,invertObject:n}},function(e,t,r){"use strict";var n=r(9),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,l=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,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,coords:0,crossOrigin:0,data:0,dateTime:0,"default":o,defer:o,dir:0,disabled:o,download:l,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,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:{}};e.exports=c},function(e,t,r){"use strict";function n(e){e=e||{};var t,r,n,a={};for(t in e)r=e[t],o.isCustomAttribute(t)?a[t]=r:(n=s.html[t.toLowerCase()],n?a[n]=r:(n=s.svg[t],n&&(a[n]=r)));return e.style&&(a.style=i(e.style)),a}function i(e){if("string"!=typeof e)throw new Error("`cssToJs`: first argument must be a string. ");for(var t,r,n,i={},o=e.split(";"),s=0,l=o.length;s<l;s++)if(t=o[s].trim().split(":"),2===t.length&&(t[0]=t[0].trim(),t[1]=t[1].trim(),t[0]&&t[1]))for(r=0,n=t.length;r<n;r++)i[a.camelCase(t[0])]=t[1];return i}var o=r(2),a=r(1),s=r(6);e.exports=n},function(e,t,r){"use strict";function n(e,t){t=t||{};for(var r,a,s,l,c=[],u="function"==typeof t.replace,p=0,d=e.length;p<d;p++)if(r=e[p],u&&(a=t.replace(r),i.isValidElement(a)))d>1&&(a=i.cloneElement(a,{key:p})),c.push(a);else if("text"!==r.type){if(s=o(r.attribs),l=null,"script"===r.type||"style"===r.type)r.children[0]&&(s.dangerouslySetInnerHTML={__html:r.children[0].data});else{if("tag"!==r.type)continue;"textarea"===r.name&&r.children[0]?s.defaultValue=r.children[0].data:r.children&&r.children.length&&(l=n(r.children,t))}d>1&&(s.key=p),c.push(i.createElement(r.name,s,l))}else c.push(r.data);return 1===c.length?c[0]:c}var i=r(12),o=r(3);e.exports=n},function(e,t){"use strict";function r(e){for(var t,r={},n=0,i=e.length;n<i;n++)t=e[n],r[t.name]=t.value;return r}function n(e,t){for(var i,o,a,s=[],l=0,c=e.length;l<c;l++){switch(i=e[l],a={next:null,prev:s[l-1]||null,parent:t||null},o=s[l-1],o&&(o.next=a),0!==i.nodeName.indexOf("#")&&(a.name=i.nodeName.toLowerCase(),a.attribs={},i.attributes&&i.attributes.length&&(a.attribs=r(i.attributes))),i.nodeType){case 1:"script"===a.name||"style"===a.name?a.type=a.name:a.type="tag",a.children=n(i.childNodes,a);break;case 3:a.type="text",a.data=i.nodeValue;break;case 8:a.type="comment",a.data=i.nodeValue}s.push(a)}return s}function i(e){var t,r,i,o="string"==typeof e?e.match(/<(.+?)[>\s]/):null;if(o&&"string"==typeof o[1]&&(t=o[1].trim().toLowerCase()),t&&window.DOMParser){var a=new window.DOMParser,s=a.parseFromString(e,"text/html");"head"===t||"body"===t?i=s.getElementsByTagName(t):"html"===t?i=s.childNodes:(r=s.getElementsByTagName(t)[0].parentNode,i=r.childNodes)}else r=document.createElement("div"),r.innerHTML=e,i=r.childNodes;return n(i)}e.exports=i},function(e,t,r){"use strict";var n,i=r(1),o=r(2),a=r(10),s={html:{},svg:{}};s.html=i.invertObject(o.DOMAttributeNames);for(n in o.Properties)s.html[n.toLowerCase()]=n;s.svg=i.invertObject(a.DOMAttributeNames);for(n in a.Properties)s.html[n]=n;e.exports=s},function(e,t,r){"use strict";function n(e,t,r,n,i,o,a,s){if(!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,n,i,o,a,s],u=0;l=new Error(t.replace(/%s/g,function(){return c[u++]})),l.name="Invariant Violation"}throw l.framesToPop=1,l}}e.exports=n},function(e,t){function r(){throw new Error("setTimeout has not been defined")}function n(){throw new Error("clearTimeout has not been defined")}function i(e){if(u===setTimeout)return setTimeout(e,0);if((u===r||!u)&&setTimeout)return u=setTimeout,setTimeout(e,0);try{return u(e,0)}catch(t){try{return u.call(null,e,0)}catch(t){return u.call(this,e,0)}}}function o(e){if(p===clearTimeout)return clearTimeout(e);if((p===n||!p)&&clearTimeout)return p=clearTimeout,clearTimeout(e);try{return p(e)}catch(t){try{return p.call(null,e)}catch(t){return p.call(this,e)}}}function a(){h&&m&&(h=!1,m.length?f=m.concat(f):g=-1,f.length&&s())}function s(){if(!h){var e=i(a);h=!0;for(var t=f.length;t;){for(m=f,f=[];++g<t;)m&&m[g].run();g=-1,t=f.length}m=null,h=!1,o(e)}}function l(e,t){this.fun=e,this.array=t}function c(){}var u,p,d=e.exports={};!function(){try{u="function"==typeof setTimeout?setTimeout:r}catch(e){u=r}try{p="function"==typeof clearTimeout?clearTimeout:n}catch(e){p=n}}();var m,f=[],h=!1,g=-1;d.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];f.push(new l(e,t)),1!==f.length||h||i(s)},l.prototype.run=function(){this.fun.apply(null,this.array)},d.title="browser",d.browser=!0,d.env={},d.argv=[],d.version="",d.versions={},d.on=c,d.addListener=c,d.once=c,d.off=c,d.removeListener=c,d.removeAllListeners=c,d.emit=c,d.binding=function(e){throw new Error("process.binding is not supported")},d.cwd=function(){return"/"},d.chdir=function(e){throw new Error("process.chdir is not supported")},d.umask=function(){return 0}},function(e,t,r){"use strict";function n(e,t){return(e&t)===t}var i=r(11),o=(r(7),{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||{},l=e.DOMAttributeNames||{},c=e.DOMPropertyNames||{},u=e.DOMMutationMethods||{};e.isCustomAttribute&&s._isCustomAttributeFunctions.push(e.isCustomAttribute);for(var p in r){s.properties.hasOwnProperty(p)?i("48",p):void 0;var d=p.toLowerCase(),m=r[p],f={attributeName:d,attributeNamespace:null,propertyName:p,mutationMethod:null,mustUseProperty:n(m,t.MUST_USE_PROPERTY),hasBooleanValue:n(m,t.HAS_BOOLEAN_VALUE),hasNumericValue:n(m,t.HAS_NUMERIC_VALUE),hasPositiveNumericValue:n(m,t.HAS_POSITIVE_NUMERIC_VALUE),hasOverloadedBooleanValue:n(m,t.HAS_OVERLOADED_BOOLEAN_VALUE)};if(f.hasBooleanValue+f.hasNumericValue+f.hasOverloadedBooleanValue<=1?void 0:i("50",p),l.hasOwnProperty(p)){var h=l[p];f.attributeName=h}a.hasOwnProperty(p)&&(f.attributeNamespace=a[p]),c.hasOwnProperty(p)&&(f.propertyName=c[p]),u.hasOwnProperty(p)&&(f.mutationMethod=u[p]),s.properties[p]=f}}}),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++){var r=s._isCustomAttributeFunctions[t];if(r(e))return!0}return!1},injection:o};e.exports=s},function(e,t){"use strict";var r={xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace"},n={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"},i={Properties:{},DOMAttributeNamespaces:{xlinkActuate:r.xlink,xlinkArcrole:r.xlink,xlinkHref:r.xlink,xlinkRole:r.xlink,xlinkShow:r.xlink,xlinkTitle:r.xlink,xlinkType:r.xlink,xmlBase:r.xml,xmlLang:r.xml,xmlSpace:r.xml},DOMAttributeNames:{}};Object.keys(n).forEach(function(e){i.Properties[e]=0,n[e]&&(i.DOMAttributeNames[e]=n[e])}),e.exports=i},function(e,t){"use strict";function r(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}e.exports=r},function(t,r){t.exports=e},function(e,t){}])}); | ||
!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)}(this,function(e){return function(e){function t(n){if(r[n])return r[n].exports;var i=r[n]={exports:{},id:n,loaded:!1};return e[n].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){"use strict";function n(e,t){if("string"!=typeof e)throw new TypeError("First argument must be a string");return i(o(e),t)}var i=r(4),o=r(7);e.exports=n},function(e,t){"use strict";function r(e){if("string"!=typeof e)throw new TypeError("First argument must be a string");if(e.indexOf("-")>0){for(var t=e.toLowerCase().split("-"),r=1,n=t.length;r<n;r++)t[r]=t[r].charAt(0).toUpperCase()+t[r].slice(1);return t.join("")}return e}function n(e,t){if("object"!=typeof e||!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),o&&2===o.length)?a[o[0]]=o[1]:"string"==typeof n&&(a[n]=r);return a}e.exports={camelCase:r,invertObject:n}},function(e,t,r){"use strict";var n=r(9),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,l=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,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,coords:0,crossOrigin:0,data:0,dateTime:0,"default":o,defer:o,dir:0,disabled:o,download:l,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,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:{}};e.exports=c},function(e,t,r){"use strict";function n(e){e=e||{};var t,r,n,a={};for(t in e)r=e[t],o.isCustomAttribute(t)?a[t]=r:(n=s.html[t.toLowerCase()],n?a[n]=r:(n=s.svg[t],n&&(a[n]=r)));return e.style&&(a.style=i(e.style)),a}function i(e){if("string"!=typeof e)throw new Error("`cssToJs`: first argument must be a string. ");for(var t,r,n,i={},o=e.split(";"),s=0,l=o.length;s<l;s++)if(t=o[s].trim().split(":"),2===t.length&&(t[0]=t[0].trim(),t[1]=t[1].trim(),t[0]&&t[1]))for(r=0,n=t.length;r<n;r++)i[a.camelCase(t[0])]=t[1];return i}var o=r(2),a=r(1),s=r(5);e.exports=n},function(e,t,r){"use strict";function n(e,t){t=t||{};for(var r,a,s,l,c=[],u="function"==typeof t.replace,p=0,d=e.length;p<d;p++)if(r=e[p],u&&(a=t.replace(r),i.isValidElement(a)))d>1&&(a=i.cloneElement(a,{key:p})),c.push(a);else if("text"!==r.type){if(s=o(r.attribs),l=null,"script"===r.type||"style"===r.type)r.children[0]&&(s.dangerouslySetInnerHTML={__html:r.children[0].data});else{if("tag"!==r.type)continue;"textarea"===r.name&&r.children[0]?s.defaultValue=r.children[0].data:r.children&&r.children.length&&(l=n(r.children,t))}d>1&&(s.key=p),c.push(i.createElement(r.name,s,l))}else c.push(r.data);return 1===c.length?c[0]:c}var i=r(12),o=r(3);e.exports=n},function(e,t,r){"use strict";var n,i=r(1),o=r(2),a=r(10),s={html:{},svg:{}};s.html=i.invertObject(o.DOMAttributeNames);for(n in o.Properties)s.html[n.toLowerCase()]=n;s.svg=i.invertObject(a.DOMAttributeNames);for(n in a.Properties)s.html[n]=n;e.exports=s},function(e,t,r){"use strict";function n(e,t,r,n,i,o,a,s){if(!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,n,i,o,a,s],u=0;l=new Error(t.replace(/%s/g,function(){return c[u++]})),l.name="Invariant Violation"}throw l.framesToPop=1,l}}e.exports=n},function(e,t,r){"use strict";function n(e){if("string"!=typeof e)throw new TypeError("First argument must be a string.");var t,r=e.match(/<[^\/](.+?)>/g);if(r&&r.length){var n=r[0];if(/<![^-]/.test(n)){var i=n.substring(1,n.length-1).trim();n=r[1],e=e.substring(e.indexOf(">")+1)}if(n)var a=n.substring(1,n.indexOf(" ")).trim().toLowerCase()}if(["html","head","body"].indexOf(a)>-1){var s;window.DOMParser?s=(new window.DOMParser).parseFromString(e,"text/html"):document.implementation.createHTMLDocument&&(s=document.implementation.createHTMLDocument(),s.documentElement.innerHTML=e,s.removeChild(s.childNodes[0])),t="html"===a?s.childNodes:s.getElementsByTagName(a)[0].parentNode.childNodes}else{var l=document.createElement("body");l.innerHTML=e,t=l.childNodes}return o(t,null,i)}var i=r(8),o=i.formatDOM;e.exports=n},function(e,t){"use strict";function r(e){for(var t,r={},n=0,i=e.length;n<i;n++)t=e[n],r[t.name]=t.value;return r}function n(e,t,i){t=t||null;for(var o,a,s,l=[],c=0,u=e.length;c<u;c++){switch(o=e[c],s={next:null,prev:l[c-1]||null,parent:t},a=l[c-1],a&&(a.next=s),0!==o.nodeName.indexOf("#")&&(s.name=o.nodeName.toLowerCase(),s.attribs={},o.attributes&&o.attributes.length&&(s.attribs=r(o.attributes))),o.nodeType){case 1:"script"===s.name||"style"===s.name?s.type=s.name:s.type="tag",s.children=n(o.childNodes,s);break;case 3:s.type="text",s.data=o.nodeValue;break;case 8:s.type="comment",s.data=o.nodeValue}l.push(s)}return i&&(l.unshift({name:i.substring(0,i.indexOf(" ")).toLowerCase(),data:i,type:"directive",next:l[0]?l[0]:null,prev:null,parent:t}),l[1]&&(l[1].prev=l[0])),l}e.exports={formatAttributes:r,formatDOM:n}},function(e,t,r){"use strict";function n(e,t){return(e&t)===t}var i=r(11),o=(r(6),{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||{},l=e.DOMAttributeNames||{},c=e.DOMPropertyNames||{},u=e.DOMMutationMethods||{};e.isCustomAttribute&&s._isCustomAttributeFunctions.push(e.isCustomAttribute);for(var p in r){s.properties.hasOwnProperty(p)?i("48",p):void 0;var d=p.toLowerCase(),m=r[p],h={attributeName:d,attributeNamespace:null,propertyName:p,mutationMethod:null,mustUseProperty:n(m,t.MUST_USE_PROPERTY),hasBooleanValue:n(m,t.HAS_BOOLEAN_VALUE),hasNumericValue:n(m,t.HAS_NUMERIC_VALUE),hasPositiveNumericValue:n(m,t.HAS_POSITIVE_NUMERIC_VALUE),hasOverloadedBooleanValue:n(m,t.HAS_OVERLOADED_BOOLEAN_VALUE)};if(h.hasBooleanValue+h.hasNumericValue+h.hasOverloadedBooleanValue<=1?void 0:i("50",p),l.hasOwnProperty(p)){var f=l[p];h.attributeName=f}a.hasOwnProperty(p)&&(h.attributeNamespace=a[p]),c.hasOwnProperty(p)&&(h.propertyName=c[p]),u.hasOwnProperty(p)&&(h.mutationMethod=u[p]),s.properties[p]=h}}}),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++){var r=s._isCustomAttributeFunctions[t];if(r(e))return!0}return!1},injection:o};e.exports=s},function(e,t){"use strict";var r={xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace"},n={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"},i={Properties:{},DOMAttributeNamespaces:{xlinkActuate:r.xlink,xlinkArcrole:r.xlink,xlinkHref:r.xlink,xlinkRole:r.xlink,xlinkShow:r.xlink,xlinkTitle:r.xlink,xlinkType:r.xlink,xmlBase:r.xml,xmlLang:r.xml,xmlSpace:r.xml},DOMAttributeNames:{}};Object.keys(n).forEach(function(e){i.Properties[e]=0,n[e]&&(i.DOMAttributeNames[e]=n[e])}),e.exports=i},function(e,t){"use strict";function r(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}e.exports=r},function(t,r){t.exports=e}])}); |
10
index.js
@@ -7,7 +7,3 @@ 'use strict'; | ||
var domToReact = require('./lib/dom-to-react'); | ||
var htmlToDOM = ( | ||
process.browser && process.title === 'browser' ? | ||
require('./lib/html-to-dom-client') : | ||
require('./lib/html-to-dom-server') | ||
); | ||
var htmlToDOM = require('html-dom-parser'); | ||
@@ -17,3 +13,3 @@ /** | ||
* | ||
* @param {String} html - The HTML. | ||
* @param {String} html - The HTML string. | ||
* @param {Object} [options] - The additional options. | ||
@@ -25,3 +21,3 @@ * @param {Function} [options.replace] - The replace method. | ||
if (typeof html !== 'string') { | ||
throw new Error('`HTMLReactParser`: The first argument must be a string.'); | ||
throw new TypeError('First argument must be a string'); | ||
} | ||
@@ -28,0 +24,0 @@ return domToReact(htmlToDOM(html), options); |
@@ -11,3 +11,3 @@ 'use strict'; | ||
if (typeof string !== 'string') { | ||
throw new Error('`camelCase`: first argument must be a string.'); | ||
throw new TypeError('First argument must be a string'); | ||
} | ||
@@ -39,3 +39,3 @@ | ||
if (typeof obj !== 'object' || !obj) { // null is an object | ||
throw new Error('`invert`: First argument must be an object.'); | ||
throw new TypeError('First argument must be an object'); | ||
} | ||
@@ -42,0 +42,0 @@ |
{ | ||
"name": "html-react-parser", | ||
"version": "0.0.7", | ||
"version": "0.1.0", | ||
"description": "An HTML to React parser.", | ||
@@ -31,4 +31,3 @@ "author": "Mark <mark@remarkablemark.org>", | ||
"dependencies": { | ||
"domhandler": "^2.3.0", | ||
"htmlparser2": "^3.9.1" | ||
"html-dom-parser": "0.0.2" | ||
}, | ||
@@ -35,0 +34,0 @@ "devDependencies": { |
@@ -30,2 +30,4 @@ # html-react-parser | ||
[NPM](https://www.npmjs.com/package/html-react-parser): | ||
```sh | ||
@@ -35,3 +37,3 @@ $ npm install html-react-parser | ||
Or you can download the script from a CDN: | ||
[CDN](https://unpkg.com/html-react-parser/): | ||
@@ -118,3 +120,3 @@ ```html | ||
Parser('<p id="replace">text</p>', { | ||
replace: (domNode) => { | ||
replace: function(domNode) { | ||
if (domNode.attribs && domNode.attribs.id === 'replace') { | ||
@@ -195,5 +197,4 @@ return <span>replaced</span>; | ||
- To [htmlparser2](https://github.com/fb55/htmlparser2). | ||
- To all the [contributors](https://github.com/remarkablemark/html-react-parser/graphs/contributors). | ||
- To [benox3](https://github.com/benox3) and [tdlm](https://github.com/tdlm) for their feedback and review. | ||
- [html-dom-parser](https://github.com/remarkablemark/html-dom-parser) | ||
- [Contributors](https://github.com/remarkablemark/html-react-parser/graphs/contributors) | ||
@@ -200,0 +201,0 @@ ## License |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
2
200
0
0
74828
10
1626
+ Addedhtml-dom-parser@0.0.2
+ Addedhtml-dom-parser@0.0.2(transitive)
- Removeddomhandler@^2.3.0
- Removedhtmlparser2@^3.9.1