From d47e66e9552cc6cc8140f7576971b4cc06b5ad5f Mon Sep 17 00:00:00 2001 From: yuyinws Date: Mon, 12 Aug 2024 16:02:57 +0800 Subject: [PATCH] fix: strict token match --- src/node/markdownPlugin.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/node/markdownPlugin.ts b/src/node/markdownPlugin.ts index 69d9258..d0d6f68 100644 --- a/src/node/markdownPlugin.ts +++ b/src/node/markdownPlugin.ts @@ -5,13 +5,15 @@ function groupIconRule(state: StateCore) { const groupNameRegex = /\[([^\]]+)\]/ for (const token of state.tokens) { - const match = token.info.match(groupNameRegex) - if (match) { - const iconName = match[1] - token.info = token.info.replace( - groupNameRegex, + if (token.type === 'fence' && token.tag === 'code' && token.level === 1) { + const match = token.info.match(groupNameRegex) + if (match) { + const iconName = match[1] + token.info = token.info.replace( + groupNameRegex, `[]`, - ) + ) + } } } }