(lines: string[])
| 1 | import type {SectionInfo} from './types.js'; |
| 2 | |
| 3 | export function parseSectionsFromMarkdown(lines: string[]): SectionInfo[] { |
| 4 | const sections: SectionInfo[] = []; |
| 5 | let inCode = false; |
| 6 | for (let idx = 0; idx < lines.length; idx++) { |
| 7 | const line = lines[idx]; |
| 8 | if (/^```/.test(line.trim())) { |
| 9 | inCode = !inCode; |
| 10 | } |
| 11 | if (inCode) { |
| 12 | continue; |
| 13 | } |
| 14 | if (line.startsWith('## ')) { |
| 15 | const name = line.replace(/^##\s+/, '').trim(); |
| 16 | sections.push({name, startLine: idx, endLine: lines.length}); |
| 17 | } |
| 18 | } |
| 19 | for (let s = 0; s < sections.length - 1; s++) { |
| 20 | sections[s].endLine = sections[s + 1].startLine; |
| 21 | } |
| 22 | return sections; |
| 23 | } |
| 24 | |
| 25 | export function extractNameAndDescription(lines: string[]): {name: string; description?: string} { |
| 26 | let name = ''; |
no test coverage detected