Skip to content

Commit

Permalink
fix: strict token match
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyinws committed Aug 12, 2024
1 parent 62ff41c commit d47e66e
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/node/markdownPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
`[<GroupIcon name="${iconName}" />]`,
)
)
}
}
}
}
Expand Down

0 comments on commit d47e66e

Please sign in to comment.