preact-parser
Advanced tools
Comparing version 1.3.2 to 1.3.3
declare function parse(htmlValue: string): string | import("preact").VNode<any>; | ||
export { parse }; |
@@ -1,1 +0,1 @@ | ||
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(this,(function(){return function(){"use strict";var e={611:function(e,t){var n,r=this&&this.__assign||function(){return(r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var a in t=arguments[n])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e}).apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0}),t.isIgnored=t.isBlockText=t.createRange=t.createText=t.createElement=t.frameflag=t.closedByClosing=t.closedByOpening=t.blockTextElements=t.selfClosingTags=t.attrRegex=t.htmlRegex=t.NodeType=void 0,function(e){e[e.Element=1]="Element",e[e.Text=3]="Text"}(n||(n={})),t.NodeType=n,t.htmlRegex=/<!--[\s\S]*?-->|<(\/?)([a-zA-Z][-.:0-9_a-zA-Z]*)((?:\s+[^>]*?(?:(?:'[^']*')|(?:"[^"]*"))?)*)\s*(\/?)>/g,t.attrRegex=/(\S+)\s*=\s*(\"?)([^"]*)(\2|\s|$)/gi;var a="documentfragmentcontainer";t.frameflag=a,t.selfClosingTags=["area","base","br","col","hr","img","input","link","meta","source","embed","param","track","wbr"];var o=["script","noscript","style","pre"];function i(e){var t=e.nodeName,a=void 0===t?e.tagName:t,o={nodeName:"BODY",nodeType:n.Element,tagName:"body",tagRange:[],attributes:[],childNodes:[]};return e&&(o=r(r(r({},o),e),{nodeName:a})),o}t.blockTextElements=o,t.closedByOpening={li:{li:!0},p:{p:!0,div:!0},b:{div:!0},td:{td:!0,th:!0},th:{td:!0,th:!0},h1:{h1:!0},h2:{h2:!0},h3:{h3:!0},h4:{h4:!0},h5:{h5:!0},h6:{h6:!0}},t.closedByClosing={li:{ul:!0,ol:!0},a:{div:!0},b:{div:!0},i:{div:!0},p:{div:!0},td:{tr:!0,table:!0},th:{tr:!0,table:!0}},t.createElement=i,t.createText=function(e,t){return i({nodeType:n.Text,textContent:e,nodeName:"#text",tagName:void 0,tagRange:t})},t.createRange=function(e,t){return[e-a.length+2,t-a.length+2]},t.isBlockText=function(e){return o.map((function(e){return new RegExp("^"+e+"$","i")})).some((function(t){return t.test(e)}))},t.isIgnored=function(e){return o.map((function(e){return new RegExp("^"+e+"$","i")})).some((function(t){return t.test(e)}))}},49:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.parseString=t.parseHtml=void 0;var r=n(611);function a(e){for(var t=[],n=void 0;n=r.attrRegex.exec(e);){var a=n[1],o=n[3],i="'"===o[0]||'"'===o[0],l={name:a.toLowerCase(),value:i?o.slice(1,o.length-1):o};t.push(l)}return t}function o(e){return(null==e?void 0:e.replace(/\r?\n|\r/g,"").replace(/\s{2,}/g," "))||null}t.parseHtml=function(e){for(var t,n=r.createElement({tagName:"body",tagRange:[0,e.length]}),i=[n],l=-1,s=void 0,c=e.length;t=r.htmlRegex.exec(e);){var d=t[0],g=t[3],u=t[4],p=t[1],f=t[2];f=f.toLowerCase();var h=d.length,m=r.htmlRegex.lastIndex-h,v=r.htmlRegex.lastIndex,x=r.selfClosingTags.includes(f);if(l>-1&&l+h<v){var y=o(e.substring(l,m));y&&n.childNodes.push(r.createText(y,r.createRange(m,v)))}if(l=r.htmlRegex.lastIndex,!p){var b=a(g),R=n.tagName;!u&&r.closedByOpening[R]&&r.closedByOpening[R][f]&&(i.pop(),n=i[i.length-1]),"a"===f&&(void 0!==s&&(i.splice(s),n=i[i.length-1]),s=i.length);var T=r.htmlRegex.lastIndex,N=T-h,O=r.createElement({tagName:f,nodeType:1,attributes:b,tagRange:r.createRange(N,T)});if(n.childNodes.push(O),n=O,i.push(n),r.isBlockText(f)){var C="</"+f+">",E=f?e.toLocaleLowerCase().indexOf(C,r.htmlRegex.lastIndex):e.indexOf(C,r.htmlRegex.lastIndex),B=-1===E?c:E;if(r.isIgnored(f)){var w=e.substring(T,B).replace(/^\s+|\s+$/g,"");w.length>0&&/\S/.test(w)&&n.childNodes.push(r.createText(w,r.createRange(N,T)))}-1===E?l=r.htmlRegex.lastIndex=e.length+1:(l=r.htmlRegex.lastIndex=E+C.length,p="/")}}if(p||u||x)for(;;){if("a"===f&&(s=void 0),n.tagName===f){n.tagRange[1]=r.createRange(-1,Math.max(l,v))[1],i.pop(),n=i[i.length-1];break}if(R=n.tagName,!r.closedByClosing[R]||!r.closedByClosing[R][f])break;i.pop(),n=i[i.length-1]}}return i},t.parseString=o},642:function(e){e.exports=require("preact")}},t={};function n(r){var a=t[r];if(void 0!==a)return a.exports;var o=t[r]={exports:{}};return e[r].call(o.exports,o,o.exports,n),o.exports}var r={};return function(){var e=r;Object.defineProperty(e,"__esModule",{value:!0}),e.parse=void 0;var t=n(642),a=n(611),o=n(49);function i(e){var n=e.children,r=void 0===n?[]:n;return t.h(t.Fragment,{},r)}function l(e){var n=this;if(e.nodeType===a.NodeType.Text)return o.parseString(e.textContent);if(e.nodeType!==a.NodeType.Element)return null;var r=String(e.nodeName).toLowerCase(),s=Array.from(e.childNodes),c=function(){return s.map((function(e){return l.call(n,e)}))},d=function(e){var t={};if(!(null==e?void 0:e.length))return t;for(var n=e.length-1;n>=0;n--){var r=e[n];t[r.name]=r.value}return t}(e.attributes);return"script"===r?null:"body"===r?t.h(i,{},c()):t.h(r,d,c())}e.parse=function(e){var t,n="<!DOCTYPE html>\n<html><body>"+e+"</body></html>";if("undefined"==typeof window)return l(o.parseHtml(e)[0]);try{t=(new DOMParser).parseFromString(n,"text/html")}catch(e){}return t?l(t.body):void 0}}(),r}()})); | ||
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(this,(function(){return function(){"use strict";var e={611:function(e,t){var n,r=this&&this.__assign||function(){return(r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var a in t=arguments[n])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e}).apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0}),t.isIgnored=t.isBlockText=t.createRange=t.createText=t.createElement=t.frameflag=t.closedByClosing=t.closedByOpening=t.blockTextElements=t.selfClosingTags=t.attrRegex=t.htmlRegex=t.NodeType=void 0,function(e){e[e.Element=1]="Element",e[e.Text=3]="Text"}(n||(n={})),t.NodeType=n,t.htmlRegex=/<!--[\s\S]*?-->|<(\/?)([a-zA-Z][-.:0-9_a-zA-Z]*)((?:\s+[^>]*?(?:(?:'[^']*')|(?:"[^"]*"))?)*)\s*(\/?)>/g,t.attrRegex=/(\S+)\s*=\s*(\"?)([^"]*)(\2|\s|$)/gi;var a="documentfragmentcontainer";t.frameflag=a,t.selfClosingTags=["area","base","br","col","hr","img","input","link","meta","source","embed","param","track","wbr"];var o=["script","noscript","style","pre"];function i(e){var t=e.nodeName,a=void 0===t?e.tagName:t,o={nodeName:"BODY",nodeType:n.Element,tagName:"body",tagRange:[],attributes:[],childNodes:[]};return e&&(o=r(r(r({},o),e),{nodeName:a})),o}t.blockTextElements=o,t.closedByOpening={li:{li:!0},p:{p:!0,div:!0},b:{div:!0},td:{td:!0,th:!0},th:{td:!0,th:!0},h1:{h1:!0},h2:{h2:!0},h3:{h3:!0},h4:{h4:!0},h5:{h5:!0},h6:{h6:!0}},t.closedByClosing={li:{ul:!0,ol:!0},a:{div:!0},b:{div:!0},i:{div:!0},p:{div:!0},td:{tr:!0,table:!0},th:{tr:!0,table:!0}},t.createElement=i,t.createText=function(e,t){return i({nodeType:n.Text,textContent:e,nodeName:"#text",tagName:void 0,tagRange:t})},t.createRange=function(e,t){return[e-a.length+2,t-a.length+2]},t.isBlockText=function(e){return o.map((function(e){return new RegExp("^"+e+"$","i")})).some((function(t){return t.test(e)}))},t.isIgnored=function(e){return o.map((function(e){return new RegExp("^"+e+"$","i")})).some((function(t){return t.test(e)}))}},49:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.parseString=t.parseHtml=void 0;var r=n(611);function a(e){for(var t=[],n=void 0;n=r.attrRegex.exec(e);){var a=n[1],o=n[3],i="'"===o[0]||'"'===o[0],l={name:a.toLowerCase(),value:i?o.slice(1,o.length-1):o};t.push(l)}return t}function o(e){return void 0===e&&(e=""),e.replace(/\r?\n|\r/g,"").replace(/\s{2,}/g," ").replace(/ /," ")||null}t.parseHtml=function(e){for(var t,n=r.createElement({tagName:"body",tagRange:[0,e.length]}),i=[n],l=-1,s=void 0,c=e.length;t=r.htmlRegex.exec(e);){var d=t[0],g=t[3],u=t[4],p=t[1],f=t[2];f=f.toLowerCase();var h=d.length,m=r.htmlRegex.lastIndex-h,v=r.htmlRegex.lastIndex,x=r.selfClosingTags.includes(f);if(l>-1&&l+h<v){var y=o(e.substring(l,m));y&&n.childNodes.push(r.createText(y,r.createRange(m,v)))}if(l=r.htmlRegex.lastIndex,!p){var b=a(g),R=n.tagName;!u&&r.closedByOpening[R]&&r.closedByOpening[R][f]&&(i.pop(),n=i[i.length-1]),"a"===f&&(void 0!==s&&(i.splice(s),n=i[i.length-1]),s=i.length);var T=r.htmlRegex.lastIndex,N=T-h,O=r.createElement({tagName:f,nodeType:1,attributes:b,tagRange:r.createRange(N,T)});if(n.childNodes.push(O),n=O,i.push(n),r.isBlockText(f)){var C="</"+f+">",E=f?e.toLocaleLowerCase().indexOf(C,r.htmlRegex.lastIndex):e.indexOf(C,r.htmlRegex.lastIndex),B=-1===E?c:E;if(r.isIgnored(f)){var w=e.substring(T,B).replace(/^\s+|\s+$/g,"");w.length>0&&/\S/.test(w)&&n.childNodes.push(r.createText(w,r.createRange(N,T)))}-1===E?l=r.htmlRegex.lastIndex=e.length+1:(l=r.htmlRegex.lastIndex=E+C.length,p="/")}}if(p||u||x)for(;;){if("a"===f&&(s=void 0),n.tagName===f){n.tagRange[1]=r.createRange(-1,Math.max(l,v))[1],i.pop(),n=i[i.length-1];break}if(R=n.tagName,!r.closedByClosing[R]||!r.closedByClosing[R][f])break;i.pop(),n=i[i.length-1]}}return i},t.parseString=o},642:function(e){e.exports=require("preact")}},t={};function n(r){var a=t[r];if(void 0!==a)return a.exports;var o=t[r]={exports:{}};return e[r].call(o.exports,o,o.exports,n),o.exports}var r={};return function(){var e=r;Object.defineProperty(e,"__esModule",{value:!0}),e.parse=void 0;var t=n(642),a=n(611),o=n(49);function i(e){var n=e.children,r=void 0===n?[]:n;return t.h(t.Fragment,{},r)}function l(e){var n=this;if(e.nodeType===a.NodeType.Text)return o.parseString(e.textContent);if(e.nodeType!==a.NodeType.Element)return null;var r=String(e.nodeName).toLowerCase(),s=Array.from(e.childNodes),c=function(){return s.map((function(e){return l.call(n,e)}))},d=function(e){var t={};if(!(null==e?void 0:e.length))return t;for(var n=e.length-1;n>=0;n--){var r=e[n];t[r.name]=r.value}return t}(e.attributes);return"script"===r?null:"body"===r?t.h(i,{},c()):t.h(r,d,c())}e.parse=function(e){var t,n="<!DOCTYPE html>\n<html><body>"+e+"</body></html>";if("undefined"==typeof window)return l(o.parseHtml(e)[0]);try{t=(new DOMParser).parseFromString(n,"text/html")}catch(e){}return t?l(t.body):void 0}}(),r}()})); |
@@ -0,0 +0,0 @@ interface IElement { |
declare function parseHtml(html: string): import("./model").IElement[]; | ||
declare function parseString(value: string): string; | ||
declare function parseString(value?: string): string; | ||
export { parseHtml, parseString }; |
{ | ||
"name": "preact-parser", | ||
"version": "1.3.2", | ||
"version": "1.3.3", | ||
"repository": "git@github.com:jahilldev/preact-parser.git", | ||
@@ -21,2 +21,5 @@ "author": "James Hill <contact@jameshill.dev>", | ||
], | ||
"engines": { | ||
"node": "^16" | ||
}, | ||
"files": [ | ||
@@ -56,2 +59,2 @@ "dist" | ||
} | ||
} | ||
} |
@@ -0,0 +0,0 @@ # preact-parser |
Sorry, the diff of this file is not supported yet
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
11807
1