* Extract heading structure for metadata
($: cheerio.CheerioAPI)
| 246 | * Extract heading structure for metadata |
| 247 | */ |
| 248 | private extractHeadings($: cheerio.CheerioAPI): Array<{ level: number; text: string }> { |
| 249 | const headings: Array<{ level: number; text: string }> = [] |
| 250 | |
| 251 | $('h1, h2, h3, h4, h5, h6').each((_, element) => { |
| 252 | const $element = $(element) |
| 253 | const tagName = element.tagName?.toLowerCase() |
| 254 | const level = Number.parseInt(tagName?.charAt(1) || '1', 10) |
| 255 | const text = $element.text().trim() |
| 256 | |
| 257 | if (text) { |
| 258 | headings.push({ level, text }) |
| 259 | } |
| 260 | }) |
| 261 | |
| 262 | return headings |
| 263 | } |
| 264 | |
| 265 | /** |
| 266 | * Extract links from the document |
no test coverage detected