Skip to content

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

refactor(docs): Remove duplicate mdxToCleanMarkdown function

Sushmithamallesh5bd12eb176d0
diff --git a/docs/app/llms.mdx/[[...slug]]/route.ts b/docs/app/llms.mdx/[[...slug]]/route.ts
index 9a1db25be..9cc06f44b 100644
--- a/docs/app/llms.mdx/[[...slug]]/route.ts
+++ b/docs/app/llms.mdx/[[...slug]]/route.ts
@@ -7,6 +7,7 @@ import {
slugToDate,
formatDate,
getLLMText,
+ mdxToCleanMarkdown,
} from '@/lib/source';
import { openapi } from '@/lib/openapi';
import { notFound } from 'next/navigation';
@@ -534,47 +535,6 @@ const sources = [
{ prefix: 'toolkits', source: toolkitsSource },
];
-/**
- * Strips MDX-specific syntax from content for clean markdown output.
- * Converts JSX components to plain text equivalents.
- */
-function mdxToCleanMarkdown(content: string): string {
- let result = content;
-
- // Remove frontmatter
- result = result.replace(/^---[\s\S]*?---\n*/m, '');
-
- // Convert Accordion to collapsible-style text
- result = result.replace(
- /<Accordion[\s\S]*?title="([^"]*)"[\s\S]*?>([\s\S]*?)<\/Accordion>/g,
- '\n**$1**\n$2'
- );
-
- // Convert Callout to blockquote
- result = result.replace(
- /<Callout[^>]*title="([^"]*)"[^>]*>([\s\S]*?)<\/Callout>/g,
- (_, title, calloutContent) => `> **${title}**: ${calloutContent.trim()}`
- );
- result = result.replace(
- /<Callout[^>]*>([\s\S]*?)<\/Callout>/g,
- (_, calloutContent) => `> ${calloutContent.trim()}`
- );
-
- // Remove wrapper components
- result = result.replace(/<\/?(Accordions|Cards|Tabs)[^>]*>/g, '');
-
- // Remove remaining self-closing JSX tags
- result = result.replace(/<[A-Z][a-zA-Z]*[\s\S]*?\/>/g, '');
-
- // Remove remaining JSX opening/closing tags but keep content
- result = result.replace(/<\/?[A-Z][a-zA-Z]*[^>]*>/g, '');
-
- // Clean up excessive newlines
- result = result.replace(/\n{3,}/g, '\n\n');
-
- return result.trim();
-}
-
/**
* Generate a changelog index with links to all changelog entries.
*/
diff --git a/docs/lib/source.ts b/docs/lib/source.ts
index 25c7b9580..58769d998 100644
--- a/docs/lib/source.ts
+++ b/docs/lib/source.ts
@@ -76,7 +76,7 @@ export function getOgImageUrl(_section: string, _slugs: string[], title?: string
* Converts MDX content to clean markdown for AI agents.
* Strips JSX components and converts them to plain text equivalents.
*/
-function mdxToCleanMarkdown(content: string): string {
+export function mdxToCleanMarkdown(content: string): string {
let result = content;
// Remove frontmatter