animate/webGl/my-threejs-test/node_modules/posthtml-parser/dist/index.js

2 lines
2.1 KiB
JavaScript
Raw Normal View History

2024-06-24 09:24:00 +00:00
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkT6SARJYHjs = require('./chunk.T6SARJYH.js');var _htmlparser2 = require('htmlparser2');var j={lowerCaseTags:!1,lowerCaseAttributeNames:!1,decodeEntities:!1},v=[{name:"!doctype",start:"<",end:">"}],I= exports.parser =(d,f={})=>{let c=new (0, _chunkT6SARJYHjs.a)(d),i=[],s=[],p=0;function a(){return i[i.length-1]}function b(n,t){return n.name instanceof RegExp?new RegExp(n.name.source,"i").test(t):t===n.name}function y(n){let t={};return Object.keys(n).forEach(e=>{let o={};o[e]=String(n[e]).replace(/&quot;/g,'"'),Object.assign(t,o)}),t}function x(n,t){var g;let e=v.concat((g=f.directives)!=null?g:[]),o=a();for(let u of e){let l=u.start+t+u.end;if(b(u,n.toLowerCase())){if(o===void 0){s.push(l);return}typeof o=="object"&&(o.content===void 0&&(o.content=[]),Array.isArray(o.content)&&o.content.push(l))}}}function A(n){let t=a(),e=`<!--${n}-->`;if(t===void 0){s.push(e);return}typeof t=="object"&&(t.content===void 0&&(t.content=[]),Array.isArray(t.content)&&t.content.push(e))}function m(n,t){let e={tag:n};f.sourceLocations&&(e.location={start:c.getPosition(r.startIndex),end:c.getPosition(r.endIndex)},p=r.endIndex),Object.keys(t).length>0&&(e.attrs=y(t)),i.push(e)}function h(n,t){let e=i.pop();if(e&&typeof e=="object"&&e.location&&r.endIndex!==null&&(t?p<r.startIndex&&(e.location.end=c.getPosition(r.startIndex-1)):e.location.end=c.getPosition(r.endIndex)),e){let o=a();if(i.length<=0){s.push(e);return}typeof o=="object"&&(o.content===void 0&&(o.content=[]),Array.isArray(o.content)&&o.content.push(e))}}function N(n){let t=a();if(t===void 0){s.push(n);return}if(typeof t=="object"){if(t.content&&Array.isArray(t.content)&&t.content.length>0){let e=t.content[t.content.length-1];if(typeof e=="string"&&!e.startsWith("<!--")){t.content[t.content.length-1]=`${e}${n}`;return}}t.content===void 0&&(t.content=[]),Array.isArray(t.content)&&t.content.push(n)}}let r=new (0, _htmlparser2.Parser)({onprocessinginstruction:x,oncomment:A,onopentag:m,onclosetag:h,ontext:N},{...j,...f});return r.write(d),r.end(),s};exports.parser = I;