From d67a0339fd727a053afe15d66bba8494911d8564 Mon Sep 17 00:00:00 2001 From: undefined Date: Fri, 23 Dec 2022 01:16:43 +0800 Subject: [PATCH] ui: fix \def in katex --- packages/ui-default/backendlib/markdown-it-katex.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/ui-default/backendlib/markdown-it-katex.js b/packages/ui-default/backendlib/markdown-it-katex.js index bad99054..5e1ebff2 100644 --- a/packages/ui-default/backendlib/markdown-it-katex.js +++ b/packages/ui-default/backendlib/markdown-it-katex.js @@ -105,6 +105,7 @@ module.exports = function plugin(md) { const katexInline = function (latex) { options.displayMode = false; try { + latex = latex.replace(/\\def{\\([a-zA-Z0-9]+)}/g, '\\def\\$1'); return katex.renderToString(latex, options); } catch (error) { if (options.throwOnError) logger.error(error); @@ -117,6 +118,7 @@ module.exports = function plugin(md) { const katexBlock = function (latex) { options.displayMode = true; try { + latex = latex.replace(/\\def{\\([a-zA-Z0-9]+)}/g, '\\def\\$1'); return `

${katex.renderToString(latex, options)}

`; } catch (error) { if (options.throwOnError) logger.error(error);