| 25 | closeNode(e){s(e)&&(this.buffer+="</span>")}value(){return this.buffer}span(e){ |
| 26 | this.buffer+=`<span class="${e}">`}}const a=(e={})=>{const t={children:[]} |
| 27 | ;return Object.assign(t,e),t};class c{constructor(){ |
| 28 | this.rootNode=a(),this.stack=[this.rootNode]}get top(){ |
| 29 | return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(e){ |
| 30 | this.top.children.push(e)}openNode(e){const t=a({scope:e}) |
| 31 | ;this.add(t),this.stack.push(t)}closeNode(){ |
| 32 | if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){ |
| 33 | for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)} |
| 34 | walk(e){return this.constructor._walk(e,this.rootNode)}static _walk(e,t){ |
| 35 | return"string"==typeof t?e.addText(t):t.children&&(e.openNode(t), |
| 36 | t.children.forEach((t=>this._walk(e,t))),e.closeNode(t)),e}static _collapse(e){ |
| 37 | "string"!=typeof e&&e.children&&(e.children.every((e=>"string"==typeof e))?e.children=[e.children.join("")]:e.children.forEach((e=>{ |
| 38 | c._collapse(e)})))}}class l extends c{constructor(e){super(),this.options=e} |
| 39 | addKeyword(e,t){""!==e&&(this.openNode(t),this.addText(e),this.closeNode())} |
| 40 | addText(e){""!==e&&this.add(e)}addSublanguage(e,t){const n=e.root |
| 41 | ;n.sublanguage=!0,n.language=t,this.add(n)}toHTML(){ |
nothing calls this directly
no outgoing calls
no test coverage detected