MCPcopy Index your code
hub / github.com/markmap/markmap / htmlOpen

Function htmlOpen

packages/markmap-common/src/html.ts:17–33  ·  view source on GitHub ↗
(
  tagName: string,
  attrs?: Record<string, string | boolean>,
)

Source from the content-addressed store, hash-verified

15}
16
17export function htmlOpen(
18 tagName: string,
19 attrs?: Record<string, string | boolean>,
20): string {
21 const attrStr = attrs
22 ? Object.entries(attrs)
23 .map(([key, value]) => {
24 if (value == null || value === false) return;
25 key = ` ${escapeHtml(key)}`;
26 if (value === true) return key;
27 return `${key}="${escapeHtml(value)}"`;
28 })
29 .filter(Boolean)
30 .join('')
31 : '';
32 return `<${tagName}${attrStr}>`;
33}
34
35export function htmlClose(tagName: string): string {
36 return `</${tagName}>`;

Callers 1

wrapHtmlFunction · 0.85

Calls 1

escapeHtmlFunction · 0.85

Tested by

no test coverage detected