<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <title>数学公式渲染测试用例</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="/css/katex/katex.min.css">
    <style>
        body {
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
            max-width: 900px;
            margin: 50px auto;
            padding: 20px;
            background: #f5f5f5;
        }
        .container {
            background: white;
            padding: 40px;
            border-radius: 8px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        }
        h1 {
            color: #333;
            border-bottom: 3px solid #007bff;
            padding-bottom: 10px;
        }
        .test-case {
            margin: 30px 0;
            padding: 25px;
            background: #f8f9fa;
            border-left: 4px solid #007bff;
            border-radius: 4px;
        }
        .test-title {
            font-weight: bold;
            color: #007bff;
            margin-bottom: 15px;
            font-size: 18px;
        }
        .formula-display {
            margin: 20px 0;
            padding: 15px;
            background: white;
            border-radius: 4px;
        }
        .description {
            color: #666;
            margin-top: 10px;
            font-size: 14px;
        }
        .raw-latex {
            background: #272822;
            color: #f8f8f2;
            padding: 15px;
            border-radius: 4px;
            font-family: "Courier New", monospace;
            font-size: 14px;
            margin-top: 10px;
            overflow-x: auto;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>🧮 数学公式渲染测试用例</h1>

        <div class="test-case">
            <div class="test-title">测试用例：二次函数最值问题</div>

            <div class="description">LaTeX 原文：</div>
            <div class="raw-latex">已知函数 f(x) = 2x^3 - 3x^2 - 12x + 5，求函数在区间 [-2, 3] 上的最大值和最小值。</div>

            <div class="description" style="margin-top: 20px;">渲染效果：</div>
            <div class="formula-display">
                已知函数 <x-math-render :content="'$f(x) = 2x^3 - 3x^2 - 12x + 5$'" />，求函数在区间 <x-math-render :content="'$[-2, 3]$'" /> 上的最大值和最小值。
            </div>

            <div class="description">
                ✅ <strong>测试点</strong>：
                <ul style="margin-top: 10px; line-height: 1.8;">
                    <li>上标：$x^3$ 和 $x^2$ 应该显示为上标形式</li>
                    <li>减号：$2x^3 - 3x^2 - 12x + 5$ 中的减号应该正确显示</li>
                    <li>区间：$[-2, 3]$ 应该显示为数学区间格式</li>
                    <li>加号：$+ 5$ 中的加号应该正确显示</li>
                </ul>
            </div>
        </div>

        <div class="test-case">
            <div class="test-title">相关公式测试</div>

            <div class="description">导数：</div>
            <div class="formula-display">
                <x-math-render :content="'$f\'(x) = 6x^2 - 6x - 12$'" />
            </div>

            <div class="description">求导过程：</div>
            <div class="formula-display">
                <x-math-render :content="'$f\'(x) = \frac{d}{dx}(2x^3) - \frac{d}{dx}(3x^2) - \frac{d}{dx}(12x) + \frac{d}{dx}(5)$'" />
            </div>

            <div class="description">化简：</div>
            <div class="formula-display">
                <x-math-render :content="'$f\'(x) = 6x^2 - 6x - 12$'" />
            </div>
        </div>

        <div class="test-case">
            <div class="test-title">边界值测试</div>

            <div class="description">区间端点：</div>
            <div class="formula-display">
                <x-math-render :content="'$x = -2$ 或 $x = 3$'" />
            </div>

            <div class="description">函数值：</div>
            <div class="formula-display">
                <x-math-render :content="'$f(-2) = 2(-2)^3 - 3(-2)^2 - 12(-2) + 5 = -16 - 12 + 24 + 5 = 1$'" />
            </div>

            <div class="formula-display">
                <x-math-render :content="'$f(3) = 2(3)^3 - 3(3)^2 - 12(3) + 5 = 54 - 27 - 36 + 5 = -4$'" />
            </div>
        </div>

        <div class="test-case">
            <div class="test-title">关键点测试</div>

            <div class="description">驻点（导数为零的点）：</div>
            <div class="formula-display">
                <x-math-render :content="'$f\'(x) = 0$'" />
            </div>

            <div class="description">求解：</div>
            <div class="formula-display">
                <x-math-render :content="'$6x^2 - 6x - 12 = 0$'" />
            </div>

            <div class="formula-display">
                <x-math-render :content="'$x^2 - x - 2 = 0$'" />
            </div>

            <div class="formula-display">
                <x-math-render :content="'$x = \frac{1 \pm \sqrt{1 + 8}}{2} = \frac{1 \pm 3}{2}$'" />
            </div>

            <div class="formula-display">
                <x-math-render :content="'$x = 2$ 或 $x = -1$'" />
            </div>
        </div>
    </div>

    <script src="/js/katex.min.js"></script>
    <script src="/js/test-math-debug.js"></script>
    <script src="/js/math-render.js"></script>
</body>
</html>
