@devries-cameron20 / composio Mirror · read-only / commits / 89d74472a
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.

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 22, 12:00 UTC

fix(docs): improve Steps/StepTitle conversion in .md endpoints

The .md endpoints were not properly converting Steps components: - StepTitle was showing as "#### # Title" instead of "#### Title" - Code blocks had excessive leading whitespace from nested JSX Changes: - Fix StepTitle regex to handle fumadocs processed content - Add post-processing to remove # prefix from step headers - Normalize code block content indentation by stripping common prefix - Remove excessive leading whitespace outside code blocks Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Sushmithamallesh committed Jan 28, 2026 at 00:58 UTC 89d74472ac9c5d84b11808670e940b6e21e95f41
1 file changed +57 -3
docs/lib/source.ts
+57 -3
@@ -127,9 +127,23 @@ function mdxToCleanMarkdown(content: string): string {
127 result = result.replace(/<TabsContent[\s\S]*?value="([^"]*)"[\s\S]*?>([\s\S]*?)<\/TabsContent>/g, '\n**$1:**\n$2');
128 result = result.replace(/<Tab[\s\S]*?value="([^"]*)"[\s\S]*?>([\s\S]*?)<\/Tab>/g, '\n**$1:**\n$2');
129
130 - // Convert Steps/Step
131 - result = result.replace(/<Step>\s*###\s*(.+)/g, '### Step: $1');
132 - result = result.replace(/<\/?Steps?>/g, '');
130 + // Convert Steps/Step with StepTitle
131 + // Handle StepTitle with potential whitespace and multiline content
132 + result = result.replace(/<StepTitle>([\s\S]*?)<\/StepTitle>/g, (_, title) => {
133 + // Clean up the title - remove extra whitespace and any # prefix fumadocs might add
134 + const cleanTitle = title.replace(/^[\s#]*#\s*/, '').replace(/\s+$/, '').trim();
135 + return cleanTitle ? `#### ${cleanTitle}` : '';
136 + });
137 + // Handle <Step> with ### header pattern (legacy)
138 + result = result.replace(/<Step>\s*###\s*(.+)/g, '#### $1');
139 + // Remove Steps wrapper and Step tags
140 + result = result.replace(/<\/?Steps>/g, '');
141 + result = result.replace(/<\/?Step>/g, '');
142 + // Clean up step titles that fumadocs converted to "# title" format
143 + // These appear as "#### # Title" after our processing, fix to "#### Title"
144 + result = result.replace(/^(\s*#{1,6})\s*#\s+(.+)$/gm, '$1 $2');
145 + // Clean up any standalone # that fumadocs might leave
146 + result = result.replace(/^\s*#\s*$/gm, '');
147
148 // Convert FrameworkOption to header with framework name
149 result = result.replace(
@@ -181,6 +195,46 @@ function mdxToCleanMarkdown(content: string): string {
195 // Clean up leftover JSX artifacts like lone } or {
196 result = result.replace(/^\s*[{}]\s*$/gm, '');
197
198 + // Normalize indentation - remove leading whitespace that came from nested JSX
199 + // Also normalize code block content indentation
200 + const lines = result.split('\n');
201 + const normalizedLines: string[] = [];
202 + let inCodeBlock = false;
203 + let codeBlockLines: string[] = [];
204 +
205 + for (const line of lines) {
206 + if (line.trim().startsWith('```')) {
207 + if (inCodeBlock) {
208 + // End of code block - normalize and flush
209 + if (codeBlockLines.length > 0) {
210 + // Find minimum indentation (ignoring empty lines)
211 + const nonEmptyLines = codeBlockLines.filter(l => l.trim().length > 0);
212 + const minIndent = nonEmptyLines.length > 0
213 + ? Math.min(...nonEmptyLines.map(l => l.match(/^(\s*)/)?.[1]?.length || 0))
214 + : 0;
215 + // Strip common indentation
216 + for (const codeLine of codeBlockLines) {
217 + normalizedLines.push(codeLine.slice(minIndent));
218 + }
219 + }
220 + codeBlockLines = [];
221 + inCodeBlock = false;
222 + normalizedLines.push(line.trim());
223 + } else {
224 + // Start of code block
225 + inCodeBlock = true;
226 + normalizedLines.push(line.trim());
227 + }
228 + } else if (inCodeBlock) {
229 + codeBlockLines.push(line);
230 + } else {
231 + // Outside code blocks, remove excessive leading whitespace
232 + normalizedLines.push(line.replace(/^\s+/, ''));
233 + }
234 + }
235 +
236 + result = normalizedLines.join('\n');
237 +
238 // Clean up excessive newlines
239 result = result.replace(/\n{3,}/g, '\n\n');
240