MCPcopy Create free account
hub / github.com/Noumena-Network/code / processElements

Function processElements

src/utils/claudemd.ts:598–635  ·  view source on GitHub ↗
(elements: MarkdownToken[])

Source from the content-addressed store, hash-verified

596
597 // Recursively process elements to find text nodes
598 function processElements(elements: MarkdownToken[]) {
599 for (const element of elements) {
600 if (element.type === 'code' || element.type === 'codespan') {
601 continue
602 }
603
604 // For html tokens that contain comments, strip the comment spans and
605 // check the residual for @paths (e.g. `<!-- note --> @./file.md`).
606 // Other html tokens (non-comment tags) are skipped entirely.
607 if (element.type === 'html') {
608 const raw = element.raw || ''
609 const trimmed = raw.trimStart()
610 if (trimmed.startsWith('<!--') && trimmed.includes('-->')) {
611 const commentSpan = /<!--[\s\S]*?-->/g
612 const residue = raw.replace(commentSpan, '')
613 if (residue.trim().length > 0) {
614 extractPathsFromText(residue)
615 }
616 }
617 continue
618 }
619
620 // Process text nodes
621 if (element.type === 'text') {
622 extractPathsFromText(element.text || '')
623 }
624
625 // Recurse into children tokens
626 if (element.tokens) {
627 processElements(element.tokens)
628 }
629
630 // Special handling for list structures
631 if (element.items) {
632 processElements(element.items)
633 }
634 }
635 }
636
637 processElements(tokens as MarkdownToken[])
638 return [...absolutePaths]

Callers 1

Calls 1

extractPathsFromTextFunction · 0.85

Tested by

no test coverage detected