(markdown: string)
| 66 | } |
| 67 | |
| 68 | function extractUpSection(markdown: string): Section | null { |
| 69 | const lines = markdown.split(/\r?\n/) |
| 70 | let sectionStart = -1 |
| 71 | let sectionLevel = 0 |
| 72 | |
| 73 | for (let index = 0; index < lines.length; index += 1) { |
| 74 | const line = lines[index] ?? '' |
| 75 | const match = line.match(/^(#{1,6})\s+(.*)$/) |
| 76 | if (!match) { |
| 77 | continue |
| 78 | } |
| 79 | |
| 80 | const level = match[1]?.length ?? 0 |
| 81 | const title = normalizeHeading(match[2] ?? '') |
| 82 | if ( |
| 83 | title === 'code up' || |
| 84 | title === 'ncode up' |
| 85 | ) { |
| 86 | sectionStart = index + 1 |
| 87 | sectionLevel = level |
| 88 | break |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | if (sectionStart === -1) { |
| 93 | return null |
| 94 | } |
| 95 | |
| 96 | let sectionEnd = lines.length |
| 97 | for (let index = sectionStart; index < lines.length; index += 1) { |
| 98 | const line = lines[index] ?? '' |
| 99 | const match = line.match(/^(#{1,6})\s+(.*)$/) |
| 100 | if (!match) { |
| 101 | continue |
| 102 | } |
| 103 | |
| 104 | const level = match[1]?.length ?? 0 |
| 105 | if (level <= sectionLevel) { |
| 106 | sectionEnd = index |
| 107 | break |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | return { |
| 112 | content: lines.slice(sectionStart, sectionEnd).join('\n'), |
| 113 | startLine: sectionStart + 1, |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | function isExecutableBlockLanguage(language: string): boolean { |
| 118 | const normalized = language.trim().toLowerCase() |
no test coverage detected