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

Function formatAttributes

lib/export/html-parser/stringify.ts:4–14  ·  view source on GitHub ↗
(attributes: ElementAttribute[])

Source from the content-addressed store, hash-verified

2import { voidTags } from './tags';
3
4export const formatAttributes = (attributes: ElementAttribute[]) => {
5 return attributes.reduce((attrs, attribute) => {
6 const { key, value } = attribute;
7 if (value === null) return `${attrs} ${key}`;
8 if (key === 'style' && !value) return '';
9
10 const quoteEscape = value.indexOf("'") !== -1;
11 const quote = quoteEscape ? '"' : "'";
12 return `${attrs} ${key}=${quote}${value}${quote}`;
13 }, '');
14};
15
16export const toHTML = (tree: AST[]) => {
17 const htmlStrings: string[] = tree.map((node) => {

Callers 1

toHTMLFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected