added export conversation feature.

This commit is contained in:
Xiaohan-Tian
2025-08-21 21:56:22 -07:00
parent c1112f41d5
commit 0c54332401
6 changed files with 181 additions and 8 deletions
+18 -1
View File
@@ -49,4 +49,21 @@ export function extractXMLFromString(input: string): string[] {
}
return matches;
}
}
/**
* Wrap XML blocks in content with fenced code blocks
* @param content - The input string that may contain XML blocks
* @returns The input string with XML blocks wrapped in fenced code blocks
*/
export const wrapXmlBlocksInContent = (content: string): string => {
if (!content) return content;
const xmlBlocks = extractXMLFromString(content);
if (!xmlBlocks || xmlBlocks.length === 0) return content;
let result = content;
for (const block of xmlBlocks) {
const fenced = '```\n' + block + '\n```';
result = result.split(block).join(fenced);
}
return result;
};