MCPcopy Create free account
hub / github.com/ZenNotes/zennotes / ensureCodeBlockSummary

Function ensureCodeBlockSummary

packages/app-core/src/lib/code-block-copy.ts:108–116  ·  view source on GitHub ↗
(wrapper: HTMLElement, code: HTMLElement)

Source from the content-addressed store, hash-verified

106}
107
108function ensureCodeBlockSummary(wrapper: HTMLElement, code: HTMLElement): void {
109 let summary = wrapper.querySelector<HTMLElement>(`.${CODE_BLOCK_SUMMARY_CLASS}`)
110 if (!summary) {
111 summary = code.ownerDocument.createElement('div')
112 summary.className = CODE_BLOCK_SUMMARY_CLASS
113 wrapper.insertBefore(summary, wrapper.querySelector('pre')?.nextSibling ?? null)
114 }
115 summary.textContent = summarizeCodeBlock(code)
116}
117
118function summarizeCodeBlock(code: HTMLElement): string {
119 const lineCount = countCodeLines(code.textContent ?? '')

Callers 1

enhanceCodeBlockCopyFunction · 0.85

Calls 1

summarizeCodeBlockFunction · 0.85

Tested by

no test coverage detected