(tree: AST[])
| 14 | }; |
| 15 | |
| 16 | export const toHTML = (tree: AST[]) => { |
| 17 | const htmlStrings: string[] = tree.map((node) => { |
| 18 | if (node.type === 'text') return node.content; |
| 19 | if (node.type === 'comment') return `<!--${node.content}-->`; |
| 20 | |
| 21 | const { tagName, attributes, children } = node as ElementAST; |
| 22 | const isSelfClosing = voidTags.includes(tagName.toLowerCase()); |
| 23 | |
| 24 | if (isSelfClosing) return `<${tagName}${formatAttributes(attributes)}>`; |
| 25 | return `<${tagName}${formatAttributes(attributes)}>${toHTML(children)}</${tagName}>`; |
| 26 | }); |
| 27 | return htmlStrings.join(''); |
| 28 | }; |
nothing calls this directly
no test coverage detected