(elements: MarkdownToken[])
| 494 | |
| 495 | // Recursively process elements to find text nodes |
| 496 | function processElements(elements: MarkdownToken[]) { |
| 497 | for (const element of elements) { |
| 498 | if (element.type === 'code' || element.type === 'codespan') { |
| 499 | continue |
| 500 | } |
| 501 | |
| 502 | // For html tokens that contain comments, strip the comment spans and |
| 503 | // check the residual for @paths (e.g. `<!-- note --> @./file.md`). |
| 504 | // Other html tokens (non-comment tags) are skipped entirely. |
| 505 | if (element.type === 'html') { |
| 506 | const raw = element.raw || '' |
| 507 | const trimmed = raw.trimStart() |
| 508 | if (trimmed.startsWith('<!--') && trimmed.includes('-->')) { |
| 509 | const commentSpan = /<!--[\s\S]*?-->/g |
| 510 | const residue = raw.replace(commentSpan, '') |
| 511 | if (residue.trim().length > 0) { |
| 512 | extractPathsFromText(residue) |
| 513 | } |
| 514 | } |
| 515 | continue |
| 516 | } |
| 517 | |
| 518 | // Process text nodes |
| 519 | if (element.type === 'text') { |
| 520 | extractPathsFromText(element.text || '') |
| 521 | } |
| 522 | |
| 523 | // Recurse into children tokens |
| 524 | if (element.tokens) { |
| 525 | processElements(element.tokens) |
| 526 | } |
| 527 | |
| 528 | // Special handling for list structures |
| 529 | if (element.items) { |
| 530 | processElements(element.items) |
| 531 | } |
| 532 | } |
| 533 | } |
| 534 | |
| 535 | processElements(tokens as MarkdownToken[]) |
| 536 | return [...absolutePaths] |
no test coverage detected