mirror of
https://github.com/yangjian102621/geekai.git
synced 2025-09-17 16:56:38 +08:00
fix: fix code highlight error when add formule detecting
This commit is contained in:
parent
37cdc26160
commit
81545d192b
@ -188,6 +188,7 @@ export function processContent(content) {
|
||||
const texts = []
|
||||
// 定义匹配数学公式的正则表达式
|
||||
const formulaRegex = /^\s*[a-z|A-Z]+[^=]+\s*=\s*[^=]+$/;
|
||||
let hasCode = false
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
// 处理引用块换行
|
||||
if (lines[i].startsWith(">")) {
|
||||
@ -195,9 +196,14 @@ export function processContent(content) {
|
||||
texts.push("\n")
|
||||
continue
|
||||
}
|
||||
console.log(formulaRegex.test(lines[i]))
|
||||
// 如果包含代码块则跳过公式检测
|
||||
if (lines[i].indexOf("```") !== -1) {
|
||||
texts.push(lines[i])
|
||||
hasCode = true
|
||||
continue
|
||||
}
|
||||
// 识别并处理数学公式,需要排除那些已经被识别出来的公式
|
||||
if (i > 0 && formulaRegex.test(lines[i]) && lines[i - 1].indexOf("$$") === -1) {
|
||||
if (i > 0 && formulaRegex.test(lines[i]) && lines[i - 1].indexOf("$$") === -1 && !hasCode) {
|
||||
texts.push("$$")
|
||||
texts.push(lines[i])
|
||||
texts.push("$$")
|
||||
|
Loading…
Reference in New Issue
Block a user