(content: string)
| 131 | } |
| 132 | |
| 133 | private extractHeaders(content: string): HeaderInfo[] { |
| 134 | const headers: HeaderInfo[] = [] |
| 135 | const headerRegex = /^(#{1,6})\s+(.+)$/gm |
| 136 | let match |
| 137 | |
| 138 | while ((match = headerRegex.exec(content)) !== null) { |
| 139 | const level = match[1].length |
| 140 | const text = match[2].trim() |
| 141 | const anchor = this.generateAnchor(text) |
| 142 | |
| 143 | headers.push({ |
| 144 | text, |
| 145 | level, |
| 146 | anchor, |
| 147 | position: match.index, |
| 148 | }) |
| 149 | } |
| 150 | |
| 151 | return headers |
| 152 | } |
| 153 | |
| 154 | private generateAnchor(headerText: string): string { |
| 155 | return headerText |
no test coverage detected