|
|
@@ -79,11 +79,13 @@ class MathFormulaProcessor
|
|
|
*/
|
|
|
private static function normalizeBackslashesInDelimiters(string $content): string
|
|
|
{
|
|
|
- // 只替换 \\+字母 的情况(被JSON转义的LaTeX命令)
|
|
|
+ // 只替换 \\+小写字母 的情况(被JSON转义的LaTeX命令,如 \\sqrt -> \sqrt)
|
|
|
+ // 保留 \\+大写字母 的情况(换行符后跟文本,如 \\CD 应保持为 \\CD)
|
|
|
// 保留 \\+数字 或 \\+空白 的情况(矩阵换行符)
|
|
|
$fixEscapedCommands = function ($tex) {
|
|
|
- // \\sqrt -> \sqrt, \\frac -> \frac, 但 \\2 或 \\ 保持不变
|
|
|
- return preg_replace('/\\\\\\\\([a-zA-Z])/', '\\\\$1', $tex);
|
|
|
+ // \\sqrt -> \sqrt, \\frac -> \frac, 但 \\CD 或 \\2 保持不变
|
|
|
+ // 【修复】只匹配小写字母,因为 LaTeX 命令都是小写
|
|
|
+ return preg_replace('/\\\\\\\\([a-z])/', '\\\\$1', $tex);
|
|
|
};
|
|
|
|
|
|
// 1. 处理 $$...$$ 块级公式
|