Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

html2ast

Package Overview
Dependencies
Maintainers
0
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

html2ast - npm Package Compare versions

Comparing version 1.0.4 to 1.1.0

2

dist/index.iife.js

@@ -1,1 +0,1 @@

var html2ast=function(t){"use strict";let e={},n={};function r(t){45===t&&(T({type:3,content:m(n.sectionStart,n.currentIndex)}),n.state=23)}function c(t){if(45===t){for(n.state=28;++n.currentIndex<n.currentInput.length;)if(45!==n.currentInput.charCodeAt(n.currentIndex)){n.sectionStart=n.currentIndex;break}}else n.state=23}function a(t){(62===t||function(t){for(;++n.currentIndex<n.currentInput.length;)if(n.currentInput.charCodeAt(n.currentIndex)===t)return!0;return n.currentIndex=n.currentInput.length-1,!1}(62))&&(n.state=1,n.sectionStart=n.currentIndex+1)}function u(t){n.state=45===t?25:23}function s(t){t===n.currentAttrValueQuote&&(n.cureentProp.value=m(n.sectionStart,n.currentIndex),n.currentOpenTag.props.push(n.cureentProp),n.sectionStart=-1,n.state=11)}function o(t){34!==t&&39!==t||(n.currentAttrValueQuote=t,n.state=19,n.sectionStart=n.currentIndex+1)}function i(t){var e,r;(61===t||h(t))&&(e=n.sectionStart,r=n.currentIndex,n.cureentProp={type:6,value:void 0,name:m(e,r)},function(t){n.state=17,n.sectionStart=n.currentIndex,f(t)}(t))}function f(t){61===t&&(n.state=18)}function d(t){60===t&&(n.currentIndex>n.sectionStart&&function(t){let r=n.stack[0]||e,c=r.children[r.children.length-1];c&&2===c.type?c.content+=t:r.children.push({type:2,content:t})}(m(n.sectionStart,n.currentIndex)),n.sectionStart=n.currentIndex,n.state=5)}function l(t){(62===t||h(t))&&(O(),n.state=10,p(t))}function p(t){62===t&&(n.state=1,n.sectionStart=n.currentIndex+1)}function I(t){h(t)||(n.state=k(t)?9:27,n.sectionStart=n.currentIndex)}function g(t){33===t?(n.state=22,n.sectionStart=n.currentIndex+1):63===t?n.state=23:k(t)?(n.sectionStart=n.currentIndex,n.state=6):47===t?n.state=8:(n.state=1,d(t))}function k(t){return t>=97&&t<=122||t>=65&&t<=90}function x(t){var e;(47===(e=t)||62===e||h(e))&&function(t){(function(t,e){let r=n.currentInput.slice(t,e);n.currentOpenTag={type:1,tag:r,props:[],children:[],content:""}})(n.sectionStart,n.currentIndex),n.state=11,n.sectionStart=-1,S(t)}(t)}function h(t){return 32===t||10===t||9===t||12===t||13===t}function S(t){62==t?(n.selfClosingTags.has(n.currentOpenTag.tag)?v(n.currentOpenTag):b(n.currentOpenTag),n.state=1,n.sectionStart=n.currentIndex+1):47==t?n.state=7:h(t)||(n.sectionStart=n.currentIndex,n.state=12)}function b(t){T(t),n.stack.unshift(t),n.currentOpenTag=null}function T(t){(n.stack[0]||e).children.push(t)}function O(){let t=m(n.sectionStart,n.currentIndex),e=n.stack,r=e[0];r&&r.tag===t&&e.shift()}function m(t,e){return n.currentInput.slice(t,e)}function y(t){62===t?(v(n.currentOpenTag),n.state=1):h(t)||(n.state=11,S(t))}function v(t){const e=n.currentOpenTag.tag;b(t),n.stack[0]&&n.stack[0].tag===e&&O(n.stack.shift())}return t.parse=function(t,k){e={type:"Program",children:[],content:""},n={state:1,currentOpenTag:null,cureentProp:null,currentInput:"",currentAttrValueQuote:"",sectionStart:0,currentIndex:0,stack:[],selfClosingTags:new Set(["meta","img","br","hr","input","link","base","source","track","area","col","wbr","embed","param","keygen","command"])};let h=t.length;for(n=Object.assign(n,{currentInput:t},k);n.currentIndex<h;){let e=t[n.currentIndex].charCodeAt();switch(n.state){case 1:d(e);break;case 5:g(e);break;case 6:x(e);break;case 7:y(e);break;case 8:I(e);break;case 9:l(e);break;case 10:p(e);break;case 11:S(e);break;case 12:i(e);break;case 17:f(e);break;case 18:o(e);break;case 19:s(e);break;case 22:u(e);break;case 23:a(e);break;case 25:c(e);break;case 28:r(e)}n.currentIndex++}return e},t}({});
var html2ast=function(t){"use strict";let e={},n={};function r(t){45===t&&(O({type:3,content:y(n.sectionStart,n.currentIndex)}),n.state=23)}function c(t){if(45===t){for(n.state=28;++n.currentIndex<n.currentInput.length;)if(45!==n.currentInput.charCodeAt(n.currentIndex)){n.sectionStart=n.currentIndex;break}}else n.state=23}function a(t){(62===t||function(t){for(;++n.currentIndex<n.currentInput.length;)if(n.currentInput.charCodeAt(n.currentIndex)===t)return!0;return n.currentIndex=n.currentInput.length-1,!1}(62))&&(n.state=1,n.sectionStart=n.currentIndex+1)}function u(t){n.state=45===t?25:23}function s(t){t===n.currentAttrValueQuote&&(n.currentProp.value=y(n.sectionStart,n.currentIndex),n.currentOpenTag.props.push(n.currentProp),n.sectionStart=-1,n.state=11)}function o(t){34!==t&&39!==t||(n.currentAttrValueQuote=t,n.state=19,n.sectionStart=n.currentIndex+1)}function i(t){var e,r;(61===t||S(t))&&(e=n.sectionStart,r=n.currentIndex,n.currentProp={type:6,value:void 0,name:y(e,r)},function(t){n.state=17,n.sectionStart=n.currentIndex,p(t)}(t))}function p(t){61===t?n.state=18:(62===t||47===t||h(t))&&(n.currentOpenTag.props.push(n.currentProp),n.currentProp=null,n.state=11,n.sectionStart=-1,b(t))}function f(t){60===t&&(n.currentIndex>n.sectionStart&&function(t){let r=n.stack[0]||e,c=r.children[r.children.length-1];c&&2===c.type?c.content+=t:r.children.push({type:2,content:t})}(y(n.sectionStart,n.currentIndex)),n.sectionStart=n.currentIndex,n.state=5)}function l(t){(62===t||h(t))&&(m(),n.state=10,d(t))}function d(t){62===t&&(n.state=1,n.sectionStart=n.currentIndex+1)}function I(t){h(t)||(n.state=k(t)?9:27,n.sectionStart=n.currentIndex)}function g(t){33===t?(n.state=22,n.sectionStart=n.currentIndex+1):63===t?n.state=23:k(t)?(n.sectionStart=n.currentIndex,n.state=6):47===t?n.state=8:(n.state=1,f(t))}function k(t){return t>=97&&t<=122||t>=65&&t<=90}function x(t){var e;S(t)&&(e=t,function(t,e){let r=n.currentInput.slice(t,e);n.currentOpenTag={type:1,tag:r,props:[],children:[],content:""}}(n.sectionStart,n.currentIndex),n.state=11,n.sectionStart=-1,b(e))}function h(t){return 32===t||10===t||9===t||12===t||13===t}function S(t){return 47===t||62===t||h(t)}function b(t){62==t?(n.selfClosingTags.has(n.currentOpenTag.tag)?v(n.currentOpenTag):T(n.currentOpenTag),n.state=1,n.sectionStart=n.currentIndex+1):47==t?n.state=7:h(t)||(n.sectionStart=n.currentIndex,n.state=12)}function T(t){O(t),n.stack.unshift(t),n.currentOpenTag=null}function O(t){(n.stack[0]||e).children.push(t)}function m(){let t=y(n.sectionStart,n.currentIndex),e=n.stack,r=e[0];r&&r.tag===t&&e.shift()}function y(t,e){return n.currentInput.slice(t,e)}function P(t){62===t?(v(n.currentOpenTag),n.state=1):h(t)||(n.state=11,b(t))}function v(t){const e=n.currentOpenTag.tag;T(t),n.stack[0]&&n.stack[0].tag===e&&m(n.stack.shift())}return t.parse=function(t,k){e={type:"Program",children:[],content:""},n={state:1,currentOpenTag:null,currentProp:null,currentInput:"",currentAttrValueQuote:"",sectionStart:0,currentIndex:0,stack:[],selfClosingTags:new Set(["meta","img","br","hr","input","link","base","source","track","area","col","wbr","embed","param","keygen","command"])};let h=t.length;for(n=Object.assign(n,{currentInput:t},k);n.currentIndex<h;){let e=t[n.currentIndex].charCodeAt();switch(n.state){case 1:f(e);break;case 5:g(e);break;case 6:x(e);break;case 7:P(e);break;case 8:I(e);break;case 9:l(e);break;case 10:d(e);break;case 11:b(e);break;case 12:i(e);break;case 17:p(e);break;case 18:o(e);break;case 19:s(e);break;case 22:u(e);break;case 23:a(e);break;case 25:c(e);break;case 28:r(e)}n.currentIndex++}return e},t}({});

@@ -15,3 +15,3 @@ // root node

currentOpenTag: null,
cureentProp: null,
currentProp: null,
currentInput: '',

@@ -132,4 +132,4 @@ currentAttrValueQuote: '',

if (char === options.currentAttrValueQuote) {
options.cureentProp.value = getSlice(options.sectionStart, options.currentIndex);
options.currentOpenTag.props.push(options.cureentProp);
options.currentProp.value = getSlice(options.sectionStart, options.currentIndex);
options.currentOpenTag.props.push(options.currentProp);
options.sectionStart = -1;

@@ -148,3 +148,3 @@ options.state = 11;

function stateInAttrName(char) {
if (char === 61 || isWhitespace(char)) {
if (char === 61 || isEndOfTagSection(char)) {
onattribname(options.sectionStart, options.currentIndex);

@@ -162,6 +162,15 @@ handleAttrNameEnd(char);

options.state = 18;
} else if (char === 62 || char === 47 || isWhitespace(char)) {
onattribend();
options.state = 11;
options.sectionStart = -1;
stateBeforeAttrName(char);
}
}
function onattribend() {
options.currentOpenTag.props.push(options.currentProp);
options.currentProp = null;
}
function onattribname(start, end) {
options.cureentProp = {
options.currentProp = {
type: 6,

@@ -168,0 +177,0 @@ value: void 0,

@@ -1,1 +0,1 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).html2ast={})}(this,(function(t){"use strict";let e={},n={};function r(t){45===t&&(T({type:3,content:y(n.sectionStart,n.currentIndex)}),n.state=23)}function c(t){if(45===t){for(n.state=28;++n.currentIndex<n.currentInput.length;)if(45!==n.currentInput.charCodeAt(n.currentIndex)){n.sectionStart=n.currentIndex;break}}else n.state=23}function a(t){(62===t||function(t){for(;++n.currentIndex<n.currentInput.length;)if(n.currentInput.charCodeAt(n.currentIndex)===t)return!0;return n.currentIndex=n.currentInput.length-1,!1}(62))&&(n.state=1,n.sectionStart=n.currentIndex+1)}function u(t){n.state=45===t?25:23}function s(t){t===n.currentAttrValueQuote&&(n.cureentProp.value=y(n.sectionStart,n.currentIndex),n.currentOpenTag.props.push(n.cureentProp),n.sectionStart=-1,n.state=11)}function o(t){34!==t&&39!==t||(n.currentAttrValueQuote=t,n.state=19,n.sectionStart=n.currentIndex+1)}function i(t){var e,r;(61===t||k(t))&&(e=n.sectionStart,r=n.currentIndex,n.cureentProp={type:6,value:void 0,name:y(e,r)},function(t){n.state=17,n.sectionStart=n.currentIndex,f(t)}(t))}function f(t){61===t&&(n.state=18)}function d(t){60===t&&(n.currentIndex>n.sectionStart&&function(t){let r=n.stack[0]||e,c=r.children[r.children.length-1];c&&2===c.type?c.content+=t:r.children.push({type:2,content:t})}(y(n.sectionStart,n.currentIndex)),n.sectionStart=n.currentIndex,n.state=5)}function p(t){(62===t||k(t))&&(m(),n.state=10,l(t))}function l(t){62===t&&(n.state=1,n.sectionStart=n.currentIndex+1)}function I(t){k(t)||(n.state=g(t)?9:27,n.sectionStart=n.currentIndex)}function x(t){33===t?(n.state=22,n.sectionStart=n.currentIndex+1):63===t?n.state=23:g(t)?(n.sectionStart=n.currentIndex,n.state=6):47===t?n.state=8:(n.state=1,d(t))}function g(t){return t>=97&&t<=122||t>=65&&t<=90}function h(t){var e;(47===(e=t)||62===e||k(e))&&function(t){(function(t,e){let r=n.currentInput.slice(t,e);n.currentOpenTag={type:1,tag:r,props:[],children:[],content:""}})(n.sectionStart,n.currentIndex),n.state=11,n.sectionStart=-1,b(t)}(t)}function k(t){return 32===t||10===t||9===t||12===t||13===t}function b(t){62==t?(n.selfClosingTags.has(n.currentOpenTag.tag)?A(n.currentOpenTag):S(n.currentOpenTag),n.state=1,n.sectionStart=n.currentIndex+1):47==t?n.state=7:k(t)||(n.sectionStart=n.currentIndex,n.state=12)}function S(t){T(t),n.stack.unshift(t),n.currentOpenTag=null}function T(t){(n.stack[0]||e).children.push(t)}function m(){let t=y(n.sectionStart,n.currentIndex),e=n.stack,r=e[0];r&&r.tag===t&&e.shift()}function y(t,e){return n.currentInput.slice(t,e)}function O(t){62===t?(A(n.currentOpenTag),n.state=1):k(t)||(n.state=11,b(t))}function A(t){const e=n.currentOpenTag.tag;S(t),n.stack[0]&&n.stack[0].tag===e&&m(n.stack.shift())}t.parse=function(t,g){e={type:"Program",children:[],content:""},n={state:1,currentOpenTag:null,cureentProp:null,currentInput:"",currentAttrValueQuote:"",sectionStart:0,currentIndex:0,stack:[],selfClosingTags:new Set(["meta","img","br","hr","input","link","base","source","track","area","col","wbr","embed","param","keygen","command"])};let k=t.length;for(n=Object.assign(n,{currentInput:t},g);n.currentIndex<k;){let e=t[n.currentIndex].charCodeAt();switch(n.state){case 1:d(e);break;case 5:x(e);break;case 6:h(e);break;case 7:O(e);break;case 8:I(e);break;case 9:p(e);break;case 10:l(e);break;case 11:b(e);break;case 12:i(e);break;case 17:f(e);break;case 18:o(e);break;case 19:s(e);break;case 22:u(e);break;case 23:a(e);break;case 25:c(e);break;case 28:r(e)}n.currentIndex++}return e}}));
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).html2ast={})}(this,(function(t){"use strict";let e={},n={};function r(t){45===t&&(m({type:3,content:O(n.sectionStart,n.currentIndex)}),n.state=23)}function c(t){if(45===t){for(n.state=28;++n.currentIndex<n.currentInput.length;)if(45!==n.currentInput.charCodeAt(n.currentIndex)){n.sectionStart=n.currentIndex;break}}else n.state=23}function a(t){(62===t||function(t){for(;++n.currentIndex<n.currentInput.length;)if(n.currentInput.charCodeAt(n.currentIndex)===t)return!0;return n.currentIndex=n.currentInput.length-1,!1}(62))&&(n.state=1,n.sectionStart=n.currentIndex+1)}function u(t){n.state=45===t?25:23}function s(t){t===n.currentAttrValueQuote&&(n.currentProp.value=O(n.sectionStart,n.currentIndex),n.currentOpenTag.props.push(n.currentProp),n.sectionStart=-1,n.state=11)}function o(t){34!==t&&39!==t||(n.currentAttrValueQuote=t,n.state=19,n.sectionStart=n.currentIndex+1)}function i(t){var e,r;(61===t||b(t))&&(e=n.sectionStart,r=n.currentIndex,n.currentProp={type:6,value:void 0,name:O(e,r)},function(t){n.state=17,n.sectionStart=n.currentIndex,f(t)}(t))}function f(t){61===t?n.state=18:(62===t||47===t||k(t))&&(n.currentOpenTag.props.push(n.currentProp),n.currentProp=null,n.state=11,n.sectionStart=-1,S(t))}function p(t){60===t&&(n.currentIndex>n.sectionStart&&function(t){let r=n.stack[0]||e,c=r.children[r.children.length-1];c&&2===c.type?c.content+=t:r.children.push({type:2,content:t})}(O(n.sectionStart,n.currentIndex)),n.sectionStart=n.currentIndex,n.state=5)}function d(t){(62===t||k(t))&&(y(),n.state=10,l(t))}function l(t){62===t&&(n.state=1,n.sectionStart=n.currentIndex+1)}function I(t){k(t)||(n.state=x(t)?9:27,n.sectionStart=n.currentIndex)}function g(t){33===t?(n.state=22,n.sectionStart=n.currentIndex+1):63===t?n.state=23:x(t)?(n.sectionStart=n.currentIndex,n.state=6):47===t?n.state=8:(n.state=1,p(t))}function x(t){return t>=97&&t<=122||t>=65&&t<=90}function h(t){var e;b(t)&&(e=t,function(t,e){let r=n.currentInput.slice(t,e);n.currentOpenTag={type:1,tag:r,props:[],children:[],content:""}}(n.sectionStart,n.currentIndex),n.state=11,n.sectionStart=-1,S(e))}function k(t){return 32===t||10===t||9===t||12===t||13===t}function b(t){return 47===t||62===t||k(t)}function S(t){62==t?(n.selfClosingTags.has(n.currentOpenTag.tag)?A(n.currentOpenTag):T(n.currentOpenTag),n.state=1,n.sectionStart=n.currentIndex+1):47==t?n.state=7:k(t)||(n.sectionStart=n.currentIndex,n.state=12)}function T(t){m(t),n.stack.unshift(t),n.currentOpenTag=null}function m(t){(n.stack[0]||e).children.push(t)}function y(){let t=O(n.sectionStart,n.currentIndex),e=n.stack,r=e[0];r&&r.tag===t&&e.shift()}function O(t,e){return n.currentInput.slice(t,e)}function P(t){62===t?(A(n.currentOpenTag),n.state=1):k(t)||(n.state=11,S(t))}function A(t){const e=n.currentOpenTag.tag;T(t),n.stack[0]&&n.stack[0].tag===e&&y(n.stack.shift())}t.parse=function(t,x){e={type:"Program",children:[],content:""},n={state:1,currentOpenTag:null,currentProp:null,currentInput:"",currentAttrValueQuote:"",sectionStart:0,currentIndex:0,stack:[],selfClosingTags:new Set(["meta","img","br","hr","input","link","base","source","track","area","col","wbr","embed","param","keygen","command"])};let k=t.length;for(n=Object.assign(n,{currentInput:t},x);n.currentIndex<k;){let e=t[n.currentIndex].charCodeAt();switch(n.state){case 1:p(e);break;case 5:g(e);break;case 6:h(e);break;case 7:P(e);break;case 8:I(e);break;case 9:d(e);break;case 10:l(e);break;case 11:S(e);break;case 12:i(e);break;case 17:f(e);break;case 18:o(e);break;case 19:s(e);break;case 22:u(e);break;case 23:a(e);break;case 25:c(e);break;case 28:r(e)}n.currentIndex++}return e}}));

@@ -1,2 +0,2 @@

export {parse};
export { parse };
// root node

@@ -16,3 +16,3 @@ let ast = {

currentOpenTag: null,
cureentProp: null,
currentProp: null,
currentInput: '',

@@ -133,4 +133,4 @@ currentAttrValueQuote: '',

if (char === options.currentAttrValueQuote) {
options.cureentProp.value = getSlice(options.sectionStart, options.currentIndex);
options.currentOpenTag.props.push(options.cureentProp);
options.currentProp.value = getSlice(options.sectionStart, options.currentIndex);
options.currentOpenTag.props.push(options.currentProp);
options.sectionStart = -1;

@@ -149,3 +149,3 @@ options.state = 11;

function stateInAttrName(char) {
if (char === 61 || isWhitespace(char)) {
if (char === 61 || isEndOfTagSection(char)) {
onattribname(options.sectionStart, options.currentIndex);

@@ -163,6 +163,15 @@ handleAttrNameEnd(char);

options.state = 18;
} else if (char === 62 || char === 47 || isWhitespace(char)) {
onattribend();
options.state = 11;
options.sectionStart = -1;
stateBeforeAttrName(char);
}
}
function onattribend() {
options.currentOpenTag.props.push(options.currentProp);
options.currentProp = null;
}
function onattribname(start, end) {
options.cureentProp = {
options.currentProp = {
type: 6,

@@ -169,0 +178,0 @@ value: void 0,

{
"name": "html2ast",
"version": "1.0.4",
"version": "1.1.0",
"description": "Convert html to ast",

@@ -5,0 +5,0 @@ "main": "./dist/index.umd.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc