From 97355cefad8238009c1301a4165c58e581f6edb4 Mon Sep 17 00:00:00 2001 From: ViperEkura <3081035982@qq.com> Date: Thu, 7 May 2026 22:33:14 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=20\\(...\\)=20?= =?UTF-8?q?=E5=86=85=E8=81=94=E6=95=B0=E5=AD=A6=E5=85=AC=E5=BC=8F=E6=94=AF?= =?UTF-8?q?=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- md2img/scripts/render.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/md2img/scripts/render.js b/md2img/scripts/render.js index 362f76a..d7d7331 100644 --- a/md2img/scripts/render.js +++ b/md2img/scripts/render.js @@ -121,6 +121,25 @@ const blockMathExtension = { }, }; +// marked extension for inline math \(...\) +const bracketInlineMathExtension = { + name: 'bracketInlineMath', + level: 'inline', + start(src) { + const idx = src.indexOf('\\('); + return idx === -1 ? undefined : idx; + }, + tokenizer(src) { + const match = src.match(/^\\\((.+?)\\\)/); + if (match) { + return { type: 'bracketInlineMath', raw: match[0], text: match[1].trim() }; + } + }, + renderer(token) { + return renderMath(token.text, false); + }, +}; + // marked extension for \[...\] block math const bracketMathExtension = { name: 'bracketMath', @@ -186,6 +205,7 @@ marked.use({ extensions: [ blockMathExtension, bracketMathExtension, + bracketInlineMathExtension, envMathExtension, mathExtension, ],