优化公式支持mbox cont.

This commit is contained in:
黄心宇 2026-01-21 10:08:45 +08:00
parent b1257fa647
commit 19606389b6
2 changed files with 19 additions and 14 deletions

View File

@ -230,12 +230,12 @@ const kateX = {
try {
renderString = renderToString(token.text, {
displayMode: token.displayMode,
macros: {
"\\mbox": "\\text{#1}",
"\\textrm": "\\text{#1}",
"\\textnormal": "\\text{#1}",
},
trust: false
macros: {
"\\mbox": "\\text{#1}",
"\\textrm": "\\text{#1}",
"\\textnormal": "\\text{#1}",
},
trust: false
})
} catch (error) {
renderString = `<p style="color:#cc0000" title="${ error.message }">${ token.raw }`

View File

@ -99,13 +99,18 @@ export default ({
rs = rs.split(`<a href="`+`/${owner}/${projectsId}/issues/${item.project_issues_index}`+`">#${item.project_issues_index}</a>`).join(content);
}
}
// rs = rs.replace(/(__special_katext_id_\d+__)/g, (_match, capture) => {
// const { type, expression } = math_expressions[capture];
// return renderToString(_unescape(expression) || '', { displayMode: type === 'block', throwOnError: false, output: 'html' })
// })
// rs = dompurify.sanitize(rs.replace(//g, ""))
// rs = rs.split('<img ').join(`<img onerror="javascript:this.src='${ imgError }';"`) // replaceall
// resetMathExpressions()
rs = rs.replace(/(__special_katext_id_\d+__)/g, (_match, capture) => {
const { type, expression } = math_expressions[capture];
return renderToString(_unescape(expression) || '', { displayMode: true, throwOnError: false,macros: {
"\\mbox": "\\text{#1}",
"\\textrm": "\\text{#1}",
"\\textnormal": "\\text{#1}",
},
trust: false})
})
rs = dompurify.sanitize(rs.replace(/▁/g, "▁▁▁"))
rs = rs.split('<img ').join(`<img onerror="javascript:this.src='${ imgError }';"`) // replaceall
resetMathExpressions()
return rs
}, [str,issues]);
@ -161,4 +166,4 @@ export default ({
dangerouslySetInnerHTML={{ __html: html }}
></div>
)
}
}