MCPcopy Create free account
hub / github.com/markmap/markmap / persistJS

Function persistJS

packages/markmap-common/src/html.ts:61–80  ·  view source on GitHub ↗
(items: JSItem[], context?: unknown)

Source from the content-addressed store, hash-verified

59}
60
61export function persistJS(items: JSItem[], context?: unknown): string[] {
62 return items.map((item) => {
63 if (item.type === 'script') {
64 const { textContent, ...rest } = item.data;
65 return wrapHtml(
66 'script',
67 textContent || '',
68 rest as Record<string, string | boolean>,
69 );
70 }
71 if (item.type === 'iife') {
72 const { fn, getParams } = item.data;
73 return wrapHtml(
74 'script',
75 escapeScript(buildCode(fn, getParams?.(context) || [])),
76 );
77 }
78 return '';
79 });
80}
81
82export function persistCSS(items: CSSItem[]): string[] {
83 return items.map((item) => {

Callers 1

fillTemplateFunction · 0.90

Calls 4

wrapHtmlFunction · 0.85
escapeScriptFunction · 0.85
buildCodeFunction · 0.85
getParamsFunction · 0.85

Tested by

no test coverage detected