diff --git a/packages/igniteui-mcp/igniteui-doc-mcp/src/lib/api-doc-search.ts b/packages/igniteui-mcp/igniteui-doc-mcp/src/lib/api-doc-search.ts index 3d27fe534..691a946b0 100644 --- a/packages/igniteui-mcp/igniteui-doc-mcp/src/lib/api-doc-search.ts +++ b/packages/igniteui-mcp/igniteui-doc-mcp/src/lib/api-doc-search.ts @@ -59,7 +59,7 @@ export function extractSection(markdown: string, section: string): string | null const headingMap: Record = { properties: ['properties', 'accessors'], methods: ['methods', 'functions'], - events: ['events', 'outputs'], + events: ['events', 'outputs', 'fires'], }; const headings = headingMap[section.toLowerCase()] || []; @@ -68,8 +68,9 @@ export function extractSection(markdown: string, section: string): string | null } const lines = markdown.split(/\r?\n/); - let startIndex = -1; - let endIndex = lines.length; + const matches: string[] = []; + let currentStart = -1; + let currentHeading = ''; for (let index = 0; index < lines.length; index++) { const match = lines[index].match(/^##\s+(.+?)\s*$/); @@ -79,20 +80,25 @@ export function extractSection(markdown: string, section: string): string | null const normalizedHeading = match[1].toLowerCase().replace(/\s+/g, ' ').trim(); - if (startIndex === -1) { - if (headings.includes(normalizedHeading)) { - startIndex = index; - } - continue; + if (currentStart !== -1) { + matches.push(lines.slice(currentStart, index).join('\n').trimEnd()); + currentStart = -1; + currentHeading = ''; } - endIndex = index; - break; + if (headings.includes(normalizedHeading)) { + currentStart = index; + currentHeading = normalizedHeading; + } + } + + if (currentStart !== -1 && headings.includes(currentHeading)) { + matches.push(lines.slice(currentStart).join('\n').trimEnd()); } - if (startIndex === -1) { + if (matches.length === 0) { return null; } - return lines.slice(startIndex, endIndex).join('\n').trimEnd(); + return matches.join('\n\n'); } \ No newline at end of file