(content: string)
| 79 | * ``` |
| 80 | */ |
| 81 | export function extractFiles(content: string): FileInfo[] { |
| 82 | const files: FileInfo[] = []; |
| 83 | |
| 84 | // Match file sections: ## filename\n```language\ncode\n``` |
| 85 | // Allow optional whitespace around newlines for flexibility |
| 86 | const fileRegex = /##\s+([^\n]+)\s*\n\s*```(?:\w+)?\s*\n([\s\S]*?)\n\s*```/g; |
| 87 | let match; |
| 88 | |
| 89 | while ((match = fileRegex.exec(content)) !== null) { |
| 90 | if (match[1] && match[2]) { |
| 91 | const filename = match[1].trim(); |
| 92 | const code = match[2].trim(); |
| 93 | files.push({ filename, content: code }); |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | return files; |
| 98 | } |
no test coverage detected