MCPcopy Create free account
hub / github.com/THU-MAIC/OpenMAIC / toHTML

Function toHTML

lib/export/html-parser/stringify.ts:16–28  ·  view source on GitHub ↗
(tree: AST[])

Source from the content-addressed store, hash-verified

14};
15
16export 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};

Callers

nothing calls this directly

Calls 1

formatAttributesFunction · 0.70

Tested by

no test coverage detected