Merge branch 'stackblitz-labs:main' into FEAT_BoltDYI_NEW_SETTINGS_UI_V2

This commit is contained in:
Stijnus
2025-01-28 23:00:04 +01:00
committed by GitHub
5 changed files with 116 additions and 10 deletions

View File

@@ -54,8 +54,28 @@ export const allowedHTMLElements = [
'tr',
'ul',
'var',
'think',
];
// Add custom rehype plugin
function remarkThinkRawContent() {
return (tree: any) => {
visit(tree, (node: any) => {
if (node.type === 'html' && node.value && node.value.startsWith('<think>')) {
const cleanedContent = node.value.slice(7);
node.value = `<div class="__boltThought__">${cleanedContent}`;
return;
}
if (node.type === 'html' && node.value && node.value.startsWith('</think>')) {
const cleanedContent = node.value.slice(8);
node.value = `</div>${cleanedContent}`;
}
});
};
}
const rehypeSanitizeOptions: RehypeSanitizeOptions = {
...defaultSchema,
tagNames: allowedHTMLElements,
@@ -79,6 +99,8 @@ export function remarkPlugins(limitedMarkdown: boolean) {
plugins.unshift(limitedMarkdownPlugin);
}
plugins.unshift(remarkThinkRawContent);
return plugins;
}