@devries-cameron20 / composio-1 / commits / f4643dd93
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

docs: preserve mermaid diagrams in LLM markdown output

Split content at <Mermaid> tag boundaries before running mdxToCleanMarkdown, then rejoin with fenced code blocks. This prevents greedy [\s\S]*? patterns in Card/JSX regexes from consuming mermaid content during markdown conversion. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Sushmitha Mallesh committed Mar 4, 2026 at 00:41 UTC f4643dd93daf6d09bdc065af639bea74dd50da0b
1 file changed +21 -1
docs/lib/source.ts
+21 -1
@@ -397,7 +397,27 @@ ${page.data.description || ''}`;
397 ${page.data.description || ''}`;
398 }
399
400 - const cleanContent = mdxToCleanMarkdown(content);
400 + // Split content at Mermaid tags, process each segment separately, then rejoin
401 + // with mermaid code blocks. This prevents JSX regexes with [\s\S]*? from
402 + // matching across mermaid boundaries and consuming diagram content.
403 + const mermaidRegex = /<Mermaid\s+chart="([\s\S]*?)"\s*\/>/g;
404 + const segments: string[] = [];
405 + const mermaidCharts: string[] = [];
406 + let lastIndex = 0;
407 + let match;
408 +
409 + while ((match = mermaidRegex.exec(content)) !== null) {
410 + segments.push(content.slice(lastIndex, match.index));
411 + mermaidCharts.push(match[1]);
412 + lastIndex = match.index + match[0].length;
413 + }
414 + segments.push(content.slice(lastIndex));
415 +
416 + const cleanSegments = segments.map(s => mdxToCleanMarkdown(s));
417 + let cleanContent = cleanSegments[0];
418 + for (let i = 0; i < mermaidCharts.length; i++) {
419 + cleanContent += `\n\n\`\`\`mermaid\n${mermaidCharts[i]}\n\`\`\`\n\n${cleanSegments[i + 1]}`;
420 + }
421
422 const footer = includeFooter
423 ? `\n\n---\n\n📚 **More documentation:** [View all docs](https://docs.composio.dev/llms.txt) | [Glossary](https://docs.composio.dev/llms.mdx/docs/glossary) | [Cookbooks](https://docs.composio.dev/llms.mdx/cookbooks) | [API Reference](https://docs.composio.dev/llms.mdx/reference)`