(code: HTMLElement)
| 116 | } |
| 117 | |
| 118 | function summarizeCodeBlock(code: HTMLElement): string { |
| 119 | const lineCount = countCodeLines(code.textContent ?? '') |
| 120 | const language = codeLanguageLabel(code) |
| 121 | const noun = lineCount === 1 ? 'line' : 'lines' |
| 122 | return `${language} folded (${lineCount} ${noun})` |
| 123 | } |
| 124 | |
| 125 | function countCodeLines(text: string): number { |
| 126 | const normalized = text.replace(/\r\n/g, '\n').replace(/\r/g, '\n').replace(/\n$/, '') |
no test coverage detected