latex update

This commit is contained in:
wangjinlei
2026-02-26 17:03:07 +08:00
parent dea6f8ea1e
commit a7ce5fe278

View File

@@ -2300,9 +2300,21 @@ class Production extends Base
return '';
}
//单行处理公式内容
$pattern = '/^<wmath[^>]*?\s+data-latex="([^"]*)"[^>]*?>.*?<\/wmath>$/';
/* $pattern = '/^<wmath[^>]*?\s+data-latex="([^"]*)"[^>]*?>.*?<\/wmath>$/';*/
// if(preg_match($pattern, $content) === 1){
// $pattern1 = '/<wmath[^>]*?\s+data-latex="([^"]*)">/';
// if (preg_match($pattern1, $content, $matches)) {
// $latexContent = $matches[1];
// // 将 $$ 转换为 $因为equation环境不需要$$
// $latexContent = str_replace('$$', '', $latexContent);
//
// return "\\begin{equation}\n\t{$latexContent}\n\\end{equation}";
// }
// return $content;
// }
$pattern = '/^<wmath[^>]*?\s+data-latex="([^"]*)"[^>]*?\s+data-wrap="block"[^>]*?>.*?<\/wmath>$/';
if(preg_match($pattern, $content) === 1){
$pattern1 = '/<wmath[^>]*?\s+data-latex="([^"]*)">/';
$pattern1 = '/<wmath[^>]*?\s+data-latex="([^"]*)"[^>]*?\s+data-wrap="block"[^>]*?>/';
if (preg_match($pattern1, $content, $matches)) {
$latexContent = $matches[1];
// 将 $$ 转换为 $因为equation环境不需要$$
@@ -2360,7 +2372,7 @@ class Production extends Base
$latex .= $this->escapeLatexSpecialChars($content);
$content = '';
}else {
$tagOpen = "<{$nextTag}>";
$tagOpen = "<{$nextTag}";
$tagClose = "</{$nextTag}>";
$beginTag = strpos($content, $tagOpen);
@@ -2450,7 +2462,7 @@ class Production extends Base
* @return int|false 闭合标签的起始位置
*/
private function getLastTabIndex($content, $tag) {
$tagOpen = "<{$tag}>";
$tagOpen = "<{$tag}";
$tagClose = "</{$tag}>";
$beginTag = strpos($content, $tagOpen);
@@ -2466,7 +2478,7 @@ class Production extends Base
// 统计当前标签内的开放标签数量
$caNowStr = substr($content, $beginTag, $endTagCa - $beginTag + strlen($tagClose));
$caCount = preg_match_all("/<{$tag}>/", $caNowStr, $matches);
$caCount = preg_match_all("/<{$tag}/", $caNowStr, $matches);
if ($caCount === 1) {
return $endTagCa;
@@ -2479,7 +2491,7 @@ class Production extends Base
break;
}
$substring = substr($content, $beginTag, $numIndex - $beginTag + strlen($tagClose));
$ccaCount = preg_match_all("/<{$tag}>/", $substring, $matches);
$ccaCount = preg_match_all("/<{$tag}/", $substring, $matches);
if ($ccaCount !== $caCount) {
$caCount = $ccaCount;
} else {