fix: restore markdown format

This commit is contained in:
2025-12-26 21:21:36 +08:00
parent 9cbc19689c
commit 62c1a43ba5
2 changed files with 9 additions and 1 deletions

View File

@@ -148,3 +148,4 @@ export default function Navbar() {

View File

@@ -1,5 +1,5 @@
import { useState } from 'react'; import { useState } from 'react';
import { Download, Code2, Check, Copy } from 'lucide-react'; import { Download, Code2 } from 'lucide-react';
import ReactMarkdown from 'react-markdown'; import ReactMarkdown from 'react-markdown';
import remarkMath from 'remark-math'; import remarkMath from 'remark-math';
import remarkBreaks from 'remark-breaks'; import remarkBreaks from 'remark-breaks';
@@ -55,6 +55,13 @@ function preprocessLatex(content: string): string {
processed = processed.replace(/\\right\s+\)/g, '\\right)'); processed = processed.replace(/\\right\s+\)/g, '\\right)');
// Fix: \begin{matrix} with mismatched \left/\right -> use \begin{array}
// This is a more complex issue that requires proper \left/\right pairing
// For now, we'll try to convert problematic patterns
// Replace \left( ... \right. text \right) pattern with ( ... \right. text )
// This fixes the common mispairing issue
processed = processed.replace(/\\left\(([^)]*?)\\right\.\s*(\\text\{[^}]*\})\s*\\right\)/g, '($1\\right. $2)');
return processed; return processed;
} }