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(
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