ai: fewer updates to fix one single latex expr being rendered 800 times

This commit is contained in:
end-4
2025-04-06 18:16:47 +02:00
parent 3dc0a61acc
commit 3f89411205
4 changed files with 15 additions and 6 deletions
+2 -2
View File
@@ -49,8 +49,8 @@ const replaceCategory = (text, replaces) => {
// Main function
export function replaceInlineLatexWithCodeBlocks(text) {
return text.replace(/\\\[(.*?)\\\]|\\\((.*?)\\\)/gs, (match, square, round) => {
const latex = square || round;
return text.replace(/\\\[(.*?)\\\]|\\\((.*?)\\\)|\$\$(.*?)\$\$|(?<!\w)\$(.*?[^\\])\$(?!\w)/gs, (match, square, round, double, single) => {
const latex = square || round || double || single;
return `\n\`\`\`latex\n${latex}\n\`\`\`\n`;
});
}