Comparing version 1.0.3 to 1.0.4
@@ -1,1 +0,1 @@ | ||
var html2ast=function(t){"use strict";let 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"])};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){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&&(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}({}); |
// root node | ||
let ast = { | ||
type: 'Program', | ||
children: [], | ||
content: '', | ||
}; | ||
let options = { | ||
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' | ||
]) | ||
}; | ||
function reset() { | ||
ast = { | ||
type: 'Program', | ||
children: [], | ||
content: '', | ||
}; | ||
options = { | ||
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' | ||
]) | ||
}; | ||
} | ||
function parse(input, optiones) { | ||
reset(); | ||
let len = input.length; | ||
@@ -23,0 +30,0 @@ options = Object.assign(options, { currentInput: input }, optiones); |
@@ -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={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"])};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){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&&(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}})); |
{ | ||
"name": "html2ast", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "Convert html to ast", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.umd.js", |
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
26505
695