| 297 | |
| 298 | // Helper function to detect badge lines (markdown image links with badge URLs) |
| 299 | function isBadgeLine(line: string): boolean { |
| 300 | // Detect badge-specific patterns (shield.io, badge URLs, image links in a row) |
| 301 | return ( |
| 302 | /!\[.*\]\(.*badge.*\)/.test(line) || |
| 303 | /!\[.*\]\(.*shield\.io.*\)/.test(line) || |
| 304 | (/\[!\[.*\]\(.*\)\]\(.*\)/.test(line) && |
| 305 | (line.includes("badge") || line.includes("shield"))) || |
| 306 | /img\.shields\.io/.test(line) || |
| 307 | (line.includes("<img") && |
| 308 | (line.includes("badge") || line.includes("shield"))) |
| 309 | ); |
| 310 | } |
| 311 | |
| 312 | // First pass: Extract headers and their content |
| 313 | const lines = text.split("\n"); |