@bbob/html
Advanced tools
Comparing version 0.0.0-alpha.4a7856d to 0.0.0-alpha.626820c
@@ -141,3 +141,3 @@ (function (global, factory) { | ||
toTagStart({ openTag = OPEN_BRAKET, closeTag = CLOSE_BRAKET } = {}) { | ||
const tagAttrs = getTagAttrs(this.tag, this.attrs); | ||
const tagAttrs = getTagAttrs(String(this.tag), this.attrs); | ||
return `${openTag}${tagAttrs}${closeTag}`; | ||
@@ -149,3 +149,3 @@ } | ||
toTagNode() { | ||
return new TagNode(this.tag.toLowerCase(), this.attrs, this.content); | ||
return new TagNode(String(this.tag).toLowerCase(), this.attrs, this.content); | ||
} | ||
@@ -152,0 +152,0 @@ toString({ openTag = OPEN_BRAKET, closeTag = CLOSE_BRAKET } = {}) { |
@@ -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).BbobHtml={})}(this,function(t){"use strict";function e(t){return"object"==typeof t&&null!==t&&"tag"in t}function r(t,e,r){return Object.keys(t).reduce((r,n)=>e(r,n,t),r)}function n(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'").replace(/(javascript|data|vbscript):/gi,"$1%3A")}function s(t,e){switch(typeof e){case"boolean":return e?""+t:"";case"number":return`${t}="${e}"`;case"string":return`${t}="${n(e)}"`;case"object":return`${t}="${n(JSON.stringify(e))}"`;default:return""}}function i(t){return null==t?"":r(t,(t,e,r)=>[...t,s(e,r[e])],[""]).join(" ")}let u=(t,e)=>{let n=r(e||{},(t,e,r)=>r[e]===e?r[e]:null,null);if(n){let r=s(t,n),u={...e};delete u[n+""];let o=i(u);return`${r}${o}`}return`${t}${i(e)}`},o=(t,r,n)=>{let s=t=>e(t)?t.toString({openTag:r,closeTag:n}):t+"";return Array.isArray(t)?t.reduce((t,e)=>null!==e?t+s(e):t,""):t?s(t):null};class l{attr(t,e){return void 0!==e&&(this.attrs[t]=e),this.attrs[t]}append(t){Array.isArray(this.content)&&this.content.push(t)}get length(){return function t(r){return e(r)&&Array.isArray(r.content)?r.content.reduce((e,r)=>e+t(r),0):"string"==typeof r?(r+"").length:0}(this)}toTagStart({openTag:t="[",closeTag:e="]"}={}){let r=u(this.tag,this.attrs);return`${t}${r}${e}`}toTagEnd({openTag:t="[",closeTag:e="]"}={}){return`${t}/${this.tag}${e}`}toTagNode(){return new l(this.tag.toLowerCase(),this.attrs,this.content)}toString({openTag:t="[",closeTag:e="]"}={}){let r=this.content?o(this.content,t,e):"",n=this.toTagStart({openTag:t,closeTag:e});return null===this.content||Array.isArray(this.content)&&0===this.content.length?n:`${n}${r}${this.toTagEnd({openTag:t,closeTag:e})}`}static create(t,e={},r=null){return new l(t,e,r)}static isOf(t,e){return t.tag===e}constructor(t,e,r){this.tag=t,this.attrs=e,this.content=r}}let a=t=>t&&void 0!==t.v?t.v:"",h=t=>t&&t.l||0,c=t=>t&&t.r||0,f=t=>!!t&&void 0!==t.t&&(5===t.t||6===t.t||1===t.t),g=t=>!!t&&void 0!==t.t&&2===t.t,p=t=>47===a(t).charCodeAt(0),d=t=>!p(t),y=t=>!!t&&void 0!==t.t&&3===t.t,A=t=>!!t&&void 0!==t.t&&4===t.t,b=t=>{let e=a(t);return p(t)?e.slice(1):e},T=t=>"["+a(t)+"]";class k{get type(){return this.t}isEmpty(){return 0===this.t||isNaN(this.t)}isText(){return f(this)}isTag(){return g(this)}isAttrName(){return y(this)}isAttrValue(){return A(this)}isStart(){return d(this)}isEnd(){return p(this)}getName(){return b(this)}getValue(){return a(this)}getLine(){return h(this)}getColumn(){return c(this)}toString(){return T(this)}constructor(t,e,r=0,n=0){this.l=r,this.r=n,this.t=t||0,this.v=e+""}}class x{skip(t=1,e){this.c.pos+=t,this.o&&this.o.onSkip&&!e&&this.o.onSkip()}hasNext(){return this.c.len>this.c.pos}getCurr(){return void 0===this.s[this.c.pos]?"":this.s[this.c.pos]}getRest(){return this.s.substring(this.c.pos)}getNext(){let t=this.c.pos+1;return t<=this.s.length-1?this.s[t]:null}getPrev(){let t=this.c.pos-1;return void 0===this.s[t]?null:this.s[t]}isLast(){return this.c.pos===this.c.len}includes(t){return this.s.indexOf(t,this.c.pos)>=0}grabWhile(t,e){let r=0;if(this.hasNext())for(r=this.c.pos;this.hasNext()&&t(this.getCurr());)this.skip(1,e);return this.s.substring(r,this.c.pos)}grabN(t=0){return this.s.substring(this.c.pos,this.c.pos+t)}substrUntilChar(t){let{pos:e}=this.c,r=this.s.indexOf(t,e);return r>=0?this.s.substring(e,r):""}constructor(t,e={}){this.s=t,this.c={pos:0,len:t.length},this.o=e}}let m=(t,e)=>new x(t,e),v=(t,e)=>{for(;t.charAt(0)===e;)t=t.substring(1);for(;t.charAt(t.length-1)===e;)t=t.substring(0,t.length-1);return t},C=t=>t.replace('\\"','"'),N=[" "," "],$=["="," "," "],w=t=>N.indexOf(t)>=0,O=t=>"\\"===t,S=t=>$.indexOf(t)>=0,E=t=>"\n"===t,L=t=>C(v(t,'"'));class j{last(){return Array.isArray(this.n)&&this.n.length>0&&void 0!==this.n[this.n.length-1]?this.n[this.n.length-1]:null}flush(){return!!this.n.length&&this.n.pop()}push(t){this.n.push(t)}toArray(){return this.n}constructor(){this.n=[]}}let W=()=>new j;function V(t,r={}){var n;let s=r.openTag||"[",i=r.closeTag||"]",u=(r.onlyAllowTags||[]).filter(Boolean).map(t=>t.toLowerCase()),o=null,a=W(),h=W(),c=W(),f=W(),g=new Set;function p(){c.flush()&&f.flush()}function d(){let t=h.last();return t&&e(t)?t.content:a.toArray()}function y(t,e,r=!0){Array.isArray(t)&&void 0!==e&&(t.push(e.toTagStart({openTag:s,closeTag:i})),Array.isArray(e.content)&&e.content.length&&(e.content.forEach(e=>{t.push(e)}),r&&t.push(e.toTagEnd({openTag:s,closeTag:i}))))}function A(t,r){if(Array.isArray(t)&&void 0!==r){if(e(r)){var n;(n=r.tag,!u.length||u.indexOf(n.toLowerCase())>=0)?t.push(r.toTagNode()):y(t,r)}else t.push(r)}}(o=(r.createTokenizer?r.createTokenizer:function(t,e={}){let r=0,n=0,s=-1,i=0,u=0,o="",l=Array(Math.floor(t.length)),a=e.openTag||"[",h=e.closeTag||"]",c=!!e.enableEscapeTags,f=(e.contextFreeTags||[]).filter(Boolean).map(t=>t.toLowerCase()),g=new Map,p=e.onToken||(()=>{}),d=[h,a,'"',"\\"," "," ","=","\n","!"],y=[a," "," ","\n"],A=t=>d.indexOf(t)>=0,b=t=>-1===y.indexOf(t),T=t=>t===a||t===h||"\\"===t,x=()=>{n++},v=(t,e)=>{""!==o&&e&&(o=""),""===o&&f.includes(t.toLowerCase())&&(o=t)},C=m(t,{onSkip:x});function N(t,e){let i=function(t,e,r=0,n=0){return new k(t,e,r,n)}(t,e,r,n);p(i),l[s+=1]=i}return{tokenize:function(){for(i=0;C.hasNext();)switch(i){case 1:i=function(){let t=C.getCurr(),e=C.getNext();C.skip();let r=C.substrUntilChar(h),n=0===r.length||r.indexOf(a)>=0;if(e&&A(e)||n||C.isLast())return N(1,t),0;let s=-1===r.indexOf("="),i="/"===r[0];if(s||i){let t=C.grabWhile(t=>t!==h);return C.skip(),N(2,t),v(t,i),0}return 2}();break;case 2:i=function(){let t=m(C.grabWhile(t=>t!==h,!0),{onSkip:x}),e=t.includes(" ");for(u=0;t.hasNext();)u=function(t,e){if(1===u){let e=t.grabWhile(t=>!("="===t||w(t))),r=t.isLast(),n="="!==t.getCurr();return(t.skip(),r||n?N(4,L(e)):N(3,e),r)?0:n?1:2}if(2===u){let r=!1,n=t.grabWhile(n=>{let s='"'===n,i=t.getPrev(),u=t.getNext(),o="="===u,l=w(n),a=u&&w(u);return!!(r&&S(n))||(!s||"\\"===i||!!(r=!r)||!!o||!!a)&&(!!e||!l)});return(t.skip(),N(4,L(n)),t.isLast())?0:1}let r=t.grabWhile(e=>!("="===e||w(e)||t.isLast()));return(N(2,r),v(r),t.skip(),e)?2:t.includes("=")?1:2}(t,!e);return C.skip(),0}();break;default:i=function(){if(E(C.getCurr()))return N(6,C.getCurr()),C.skip(),n=0,r++,0;if(w(C.getCurr()))return N(5,C.grabWhile(w)),0;if(C.getCurr()===a){if(o){let t=a.length+1+o.length,e=`${a}/${o}`;if(C.grabN(t)===e)return 1}else if(C.includes(h))return 1;return N(1,C.getCurr()),C.skip(),0}if(c){if(O(C.getCurr())){let t=C.getCurr(),e=C.getNext();return(C.skip(),e&&T(e))?(C.skip(),N(1,e)):N(1,t),0}return N(1,C.grabWhile(t=>b(t)&&!O(t))),0}return N(1,C.grabWhile(b)),0}()}return l.length=s+1,l},isTokenNested:function(e){let r=a+"/"+e.getValue();if(g.has(r))return!!g.get(r);{let e=t.indexOf(r)>-1;return g.set(r,e),e}}}})(t,{onToken:function(t){t.isTag()?(t.isStart()&&function(t){p();let e=l.create(t.getValue(),{},[]),r=function(t){let e=t.getValue(),{isTokenNested:r}=o||{};return!g.has(e)&&r&&r(t)?(g.add(e),!0):g.has(e)}(t);c.push(e),r?h.push(e):A(d(),e)}(t),t.isEnd()&&function(t){p();let e=h.flush();if(e)A(d(),e);else if("function"==typeof r.onError){let e=t.getValue(),n=t.getLine(),s=t.getColumn();r.onError({tagName:e,lineNumber:n,columnNumber:s})}}(t)):!function(t){var e;let r=c.last(),n=t.getValue(),s=(e=t.toString(),!!g.has(e)),i=d();if(null!==r){if(t.isAttrName()){f.push(n);let t=f.last();t&&r.attr(t,"")}else if(t.isAttrValue()){let t=f.last();t?(r.attr(t,n),f.flush()):r.attr(n,n)}else t.isText()?s?r.append(n):A(i,n):t.isTag()&&A(i,t.toString())}else t.isText()?A(i,n):t.isTag()&&A(i,t.toString())}(t)},openTag:s,closeTag:i,onlyAllowTags:r.onlyAllowTags,contextFreeTags:r.contextFreeTags,enableEscapeTags:r.enableEscapeTags})).tokenize();let b=h.flush();return null!==b&&b&&e(b)&&(n=b.tag,g.has(n))&&y(d(),b,!1),a.toArray()}let P=t=>"object"==typeof t&&null!==t,z=t=>"boolean"==typeof t;function B(t,e){if(Array.isArray(t))for(let r=0;r<t.length;r++)t[r]=B(e(t[r]),e);else P(t)&&"content"in t&&B(t.content,e);return t}function F(t,e){return typeof t==typeof e&&(P(t)&&null!==t?Array.isArray(t)?t.every(t=>[].some.call(e,e=>F(t,e))):!!(P(t)&&P(e))&&Object.keys(t).every(r=>{let n=e[r],s=t[r];return P(s)&&P(n)?F(s,n):z(s)?s!==(null===n):n===s}):t===e)}function M(t,e){return t.messages=[...t.messages||[]],t.options={...e,...t.options},t.walk=function(t){return B(this,t)},t.match=function(t,e){return Array.isArray(t)?B(this,r=>{for(let n=0;n<t.length;n++)if(F(t[n],r))return e(r);return r}):B(this,r=>F(t,r)?e(r):r)},t}function U(t,r){let{stripTags:n=!1}=r||{};if(null==t)return"";if("string"==typeof t||"number"==typeof t)return t+"";if(Array.isArray(t))return _(t,r);if(e(t)){if(n)return _(t.content,r);let e=i(t.attrs);return null===t.content?"<"+t.tag+e+"/>":"<"+t.tag+e+">"+_(t.content,r)+"</"+t.tag+">"}return""}function _(t,e){return t&&Array.isArray(t)?t.reduce((t,r)=>t+U(r,e),""):t?U(t,e):""}function q(t,e,r){return(function(t){let e="function"==typeof t?[t]:t||[],r=()=>"";return{process(t,n){let s=n||{skipParse:!1,parser:V,render:r,data:null},i=s.parser||V,u=s.render,o=s.data||null;if("function"!=typeof i)throw Error("C1");let l=s.skipParse&&Array.isArray(t)?t:i(t,s),a=s.skipParse&&Array.isArray(t)?M(t||[],s):M(l,s);for(let t=0;t<e.length;t++){let r=e[t];"function"==typeof r&&u&&(a=M(r(a,{parse:i,render:u,iterate:B,data:o})||a,s))}return{get html(){if("function"!=typeof u)throw Error("C2");return u(a,a.options)},tree:a,raw:l,messages:a.messages}}}})(e).process(t,{...r,render:_}).html}t.default=q,t.html=q,t.render=_,Object.defineProperty(t,"__esModule",{value:!0})}); | ||
!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).BbobHtml={})}(this,function(t){"use strict";function e(t){return"object"==typeof t&&null!==t&&"tag"in t}function r(t,e,r){return Object.keys(t).reduce((r,n)=>e(r,n,t),r)}function n(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'").replace(/(javascript|data|vbscript):/gi,"$1%3A")}function s(t,e){switch(typeof e){case"boolean":return e?""+t:"";case"number":return`${t}="${e}"`;case"string":return`${t}="${n(e)}"`;case"object":return`${t}="${n(JSON.stringify(e))}"`;default:return""}}function i(t){return null==t?"":r(t,(t,e,r)=>[...t,s(e,r[e])],[""]).join(" ")}let u=(t,e)=>{let n=r(e||{},(t,e,r)=>r[e]===e?r[e]:null,null);if(n){let r=s(t,n),u={...e};delete u[n+""];let o=i(u);return`${r}${o}`}return`${t}${i(e)}`},o=(t,r,n)=>{let s=t=>e(t)?t.toString({openTag:r,closeTag:n}):t+"";return Array.isArray(t)?t.reduce((t,e)=>null!==e?t+s(e):t,""):t?s(t):null};class l{attr(t,e){return void 0!==e&&(this.attrs[t]=e),this.attrs[t]}append(t){Array.isArray(this.content)&&this.content.push(t)}get length(){return function t(r){return e(r)&&Array.isArray(r.content)?r.content.reduce((e,r)=>e+t(r),0):"string"==typeof r?(r+"").length:0}(this)}toTagStart({openTag:t="[",closeTag:e="]"}={}){let r=u(this.tag+"",this.attrs);return`${t}${r}${e}`}toTagEnd({openTag:t="[",closeTag:e="]"}={}){return`${t}/${this.tag}${e}`}toTagNode(){return new l((this.tag+"").toLowerCase(),this.attrs,this.content)}toString({openTag:t="[",closeTag:e="]"}={}){let r=this.content?o(this.content,t,e):"",n=this.toTagStart({openTag:t,closeTag:e});return null===this.content||Array.isArray(this.content)&&0===this.content.length?n:`${n}${r}${this.toTagEnd({openTag:t,closeTag:e})}`}static create(t,e={},r=null){return new l(t,e,r)}static isOf(t,e){return t.tag===e}constructor(t,e,r){this.tag=t,this.attrs=e,this.content=r}}let a=t=>t&&void 0!==t.v?t.v:"",h=t=>t&&t.l||0,c=t=>t&&t.r||0,f=t=>!!t&&void 0!==t.t&&(5===t.t||6===t.t||1===t.t),g=t=>!!t&&void 0!==t.t&&2===t.t,p=t=>47===a(t).charCodeAt(0),d=t=>!p(t),y=t=>!!t&&void 0!==t.t&&3===t.t,A=t=>!!t&&void 0!==t.t&&4===t.t,b=t=>{let e=a(t);return p(t)?e.slice(1):e},T=t=>"["+a(t)+"]";class k{get type(){return this.t}isEmpty(){return 0===this.t||isNaN(this.t)}isText(){return f(this)}isTag(){return g(this)}isAttrName(){return y(this)}isAttrValue(){return A(this)}isStart(){return d(this)}isEnd(){return p(this)}getName(){return b(this)}getValue(){return a(this)}getLine(){return h(this)}getColumn(){return c(this)}toString(){return T(this)}constructor(t,e,r=0,n=0){this.l=r,this.r=n,this.t=t||0,this.v=e+""}}class x{skip(t=1,e){this.c.pos+=t,this.o&&this.o.onSkip&&!e&&this.o.onSkip()}hasNext(){return this.c.len>this.c.pos}getCurr(){return void 0===this.s[this.c.pos]?"":this.s[this.c.pos]}getRest(){return this.s.substring(this.c.pos)}getNext(){let t=this.c.pos+1;return t<=this.s.length-1?this.s[t]:null}getPrev(){let t=this.c.pos-1;return void 0===this.s[t]?null:this.s[t]}isLast(){return this.c.pos===this.c.len}includes(t){return this.s.indexOf(t,this.c.pos)>=0}grabWhile(t,e){let r=0;if(this.hasNext())for(r=this.c.pos;this.hasNext()&&t(this.getCurr());)this.skip(1,e);return this.s.substring(r,this.c.pos)}grabN(t=0){return this.s.substring(this.c.pos,this.c.pos+t)}substrUntilChar(t){let{pos:e}=this.c,r=this.s.indexOf(t,e);return r>=0?this.s.substring(e,r):""}constructor(t,e={}){this.s=t,this.c={pos:0,len:t.length},this.o=e}}let m=(t,e)=>new x(t,e),v=(t,e)=>{for(;t.charAt(0)===e;)t=t.substring(1);for(;t.charAt(t.length-1)===e;)t=t.substring(0,t.length-1);return t},C=t=>t.replace('\\"','"'),N=[" "," "],$=["="," "," "],w=t=>N.indexOf(t)>=0,O=t=>"\\"===t,S=t=>$.indexOf(t)>=0,E=t=>"\n"===t,L=t=>C(v(t,'"'));class j{last(){return Array.isArray(this.n)&&this.n.length>0&&void 0!==this.n[this.n.length-1]?this.n[this.n.length-1]:null}flush(){return!!this.n.length&&this.n.pop()}push(t){this.n.push(t)}toArray(){return this.n}constructor(){this.n=[]}}let W=()=>new j;function V(t,r={}){var n;let s=r.openTag||"[",i=r.closeTag||"]",u=(r.onlyAllowTags||[]).filter(Boolean).map(t=>t.toLowerCase()),o=null,a=W(),h=W(),c=W(),f=W(),g=new Set;function p(){c.flush()&&f.flush()}function d(){let t=h.last();return t&&e(t)?t.content:a.toArray()}function y(t,e,r=!0){Array.isArray(t)&&void 0!==e&&(t.push(e.toTagStart({openTag:s,closeTag:i})),Array.isArray(e.content)&&e.content.length&&(e.content.forEach(e=>{t.push(e)}),r&&t.push(e.toTagEnd({openTag:s,closeTag:i}))))}function A(t,r){if(Array.isArray(t)&&void 0!==r){if(e(r)){var n;(n=r.tag,!u.length||u.indexOf(n.toLowerCase())>=0)?t.push(r.toTagNode()):y(t,r)}else t.push(r)}}(o=(r.createTokenizer?r.createTokenizer:function(t,e={}){let r=0,n=0,s=-1,i=0,u=0,o="",l=Array(Math.floor(t.length)),a=e.openTag||"[",h=e.closeTag||"]",c=!!e.enableEscapeTags,f=(e.contextFreeTags||[]).filter(Boolean).map(t=>t.toLowerCase()),g=new Map,p=e.onToken||(()=>{}),d=[h,a,'"',"\\"," "," ","=","\n","!"],y=[a," "," ","\n"],A=t=>d.indexOf(t)>=0,b=t=>-1===y.indexOf(t),T=t=>t===a||t===h||"\\"===t,x=()=>{n++},v=(t,e)=>{""!==o&&e&&(o=""),""===o&&f.includes(t.toLowerCase())&&(o=t)},C=m(t,{onSkip:x});function N(t,e){let i=function(t,e,r=0,n=0){return new k(t,e,r,n)}(t,e,r,n);p(i),l[s+=1]=i}return{tokenize:function(){for(i=0;C.hasNext();)switch(i){case 1:i=function(){let t=C.getCurr(),e=C.getNext();C.skip();let r=C.substrUntilChar(h),n=0===r.length||r.indexOf(a)>=0;if(e&&A(e)||n||C.isLast())return N(1,t),0;let s=-1===r.indexOf("="),i="/"===r[0];if(s||i){let t=C.grabWhile(t=>t!==h);return C.skip(),N(2,t),v(t,i),0}return 2}();break;case 2:i=function(){let t=m(C.grabWhile(t=>t!==h,!0),{onSkip:x}),e=t.includes(" ");for(u=0;t.hasNext();)u=function(t,e){if(1===u){let e=t.grabWhile(t=>!("="===t||w(t))),r=t.isLast(),n="="!==t.getCurr();return(t.skip(),r||n?N(4,L(e)):N(3,e),r)?0:n?1:2}if(2===u){let r=!1,n=t.grabWhile(n=>{let s='"'===n,i=t.getPrev(),u=t.getNext(),o="="===u,l=w(n),a=u&&w(u);return!!(r&&S(n))||(!s||"\\"===i||!!(r=!r)||!!o||!!a)&&(!!e||!l)});return(t.skip(),N(4,L(n)),t.isLast())?0:1}let r=t.grabWhile(e=>!("="===e||w(e)||t.isLast()));return(N(2,r),v(r),t.skip(),e)?2:t.includes("=")?1:2}(t,!e);return C.skip(),0}();break;default:i=function(){if(E(C.getCurr()))return N(6,C.getCurr()),C.skip(),n=0,r++,0;if(w(C.getCurr()))return N(5,C.grabWhile(w)),0;if(C.getCurr()===a){if(o){let t=a.length+1+o.length,e=`${a}/${o}`;if(C.grabN(t)===e)return 1}else if(C.includes(h))return 1;return N(1,C.getCurr()),C.skip(),0}if(c){if(O(C.getCurr())){let t=C.getCurr(),e=C.getNext();return(C.skip(),e&&T(e))?(C.skip(),N(1,e)):N(1,t),0}return N(1,C.grabWhile(t=>b(t)&&!O(t))),0}return N(1,C.grabWhile(b)),0}()}return l.length=s+1,l},isTokenNested:function(e){let r=a+"/"+e.getValue();if(g.has(r))return!!g.get(r);{let e=t.indexOf(r)>-1;return g.set(r,e),e}}}})(t,{onToken:function(t){t.isTag()?(t.isStart()&&function(t){p();let e=l.create(t.getValue(),{},[]),r=function(t){let e=t.getValue(),{isTokenNested:r}=o||{};return!g.has(e)&&r&&r(t)?(g.add(e),!0):g.has(e)}(t);c.push(e),r?h.push(e):A(d(),e)}(t),t.isEnd()&&function(t){p();let e=h.flush();if(e)A(d(),e);else if("function"==typeof r.onError){let e=t.getValue(),n=t.getLine(),s=t.getColumn();r.onError({tagName:e,lineNumber:n,columnNumber:s})}}(t)):!function(t){var e;let r=c.last(),n=t.getValue(),s=(e=t.toString(),!!g.has(e)),i=d();if(null!==r){if(t.isAttrName()){f.push(n);let t=f.last();t&&r.attr(t,"")}else if(t.isAttrValue()){let t=f.last();t?(r.attr(t,n),f.flush()):r.attr(n,n)}else t.isText()?s?r.append(n):A(i,n):t.isTag()&&A(i,t.toString())}else t.isText()?A(i,n):t.isTag()&&A(i,t.toString())}(t)},openTag:s,closeTag:i,onlyAllowTags:r.onlyAllowTags,contextFreeTags:r.contextFreeTags,enableEscapeTags:r.enableEscapeTags})).tokenize();let b=h.flush();return null!==b&&b&&e(b)&&(n=b.tag,g.has(n))&&y(d(),b,!1),a.toArray()}let P=t=>"object"==typeof t&&null!==t,z=t=>"boolean"==typeof t;function B(t,e){if(Array.isArray(t))for(let r=0;r<t.length;r++)t[r]=B(e(t[r]),e);else P(t)&&"content"in t&&B(t.content,e);return t}function F(t,e){return typeof t==typeof e&&(P(t)&&null!==t?Array.isArray(t)?t.every(t=>[].some.call(e,e=>F(t,e))):!!(P(t)&&P(e))&&Object.keys(t).every(r=>{let n=e[r],s=t[r];return P(s)&&P(n)?F(s,n):z(s)?s!==(null===n):n===s}):t===e)}function M(t,e){return t.messages=[...t.messages||[]],t.options={...e,...t.options},t.walk=function(t){return B(this,t)},t.match=function(t,e){return Array.isArray(t)?B(this,r=>{for(let n=0;n<t.length;n++)if(F(t[n],r))return e(r);return r}):B(this,r=>F(t,r)?e(r):r)},t}function U(t,r){let{stripTags:n=!1}=r||{};if(null==t)return"";if("string"==typeof t||"number"==typeof t)return t+"";if(Array.isArray(t))return _(t,r);if(e(t)){if(n)return _(t.content,r);let e=i(t.attrs);return null===t.content?"<"+t.tag+e+"/>":"<"+t.tag+e+">"+_(t.content,r)+"</"+t.tag+">"}return""}function _(t,e){return t&&Array.isArray(t)?t.reduce((t,r)=>t+U(r,e),""):t?U(t,e):""}function q(t,e,r){return(function(t){let e="function"==typeof t?[t]:t||[],r=()=>"";return{process(t,n){let s=n||{skipParse:!1,parser:V,render:r,data:null},i=s.parser||V,u=s.render,o=s.data||null;if("function"!=typeof i)throw Error("C1");let l=s.skipParse&&Array.isArray(t)?t:i(t,s),a=s.skipParse&&Array.isArray(t)?M(t||[],s):M(l,s);for(let t=0;t<e.length;t++){let r=e[t];"function"==typeof r&&u&&(a=M(r(a,{parse:i,render:u,iterate:B,data:o})||a,s))}return{get html(){if("function"!=typeof u)throw Error("C2");return u(a,a.options)},tree:a,raw:l,messages:a.messages}}}})(e).process(t,{...r,render:_}).html}t.default=q,t.html=q,t.render=_,Object.defineProperty(t,"__esModule",{value:!0})}); |
{ | ||
"name": "@bbob/html", | ||
"version": "0.0.0-alpha.4a7856d", | ||
"version": "0.0.0-alpha.626820c", | ||
"description": "A BBCode to HTML Renderer part of @bbob", | ||
@@ -73,4 +73,5 @@ "keywords": [ | ||
"src", | ||
"es" | ||
"es", | ||
"types" | ||
] | ||
} |
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
100665
10
1274