From 5f245eca7bfa9929b8bd32d54377fcb5a2843b69 Mon Sep 17 00:00:00 2001 From: Divyansh Singh <40380293+brc-dd@users.noreply.github.com> Date: Sun, 21 Jan 2024 23:15:11 +0530 Subject: [PATCH] tweak --- src/node/markdown/plugins/githubAlerts.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/node/markdown/plugins/githubAlerts.ts b/src/node/markdown/plugins/githubAlerts.ts index 238cf98f..fd084f59 100644 --- a/src/node/markdown/plugins/githubAlerts.ts +++ b/src/node/markdown/plugins/githubAlerts.ts @@ -1,6 +1,9 @@ import type MarkdownIt from 'markdown-it' import type { ContainerOptions } from './containers' +const markerRE = + /^\[\!(TIP|NOTE|INFO|IMPORTANT|WARNING|CAUTION|DANGER)\]([^\n\r]*)/i + export const gitHubAlertsPlugin = ( md: MarkdownIt, options?: ContainerOptions @@ -15,9 +18,6 @@ export const gitHubAlertsPlugin = ( danger: options?.dangerLabel || 'DANGER' } as Record - const RE = - /^\[\!(TIP|NOTE|INFO|IMPORTANT|WARNING|CAUTION|DANGER)\]([^\n\r]*)/i - md.core.ruler.after('block', 'github-alerts', (state) => { const tokens = state.tokens for (let i = 0; i < tokens.length; i++) { @@ -32,7 +32,7 @@ export const gitHubAlertsPlugin = ( .slice(startIndex, endIndex + 1) .find((token) => token.type === 'inline') if (!firstContent) continue - const match = firstContent.content.match(RE) + const match = firstContent.content.match(markerRE) if (!match) continue const type = match[1].toLowerCase() const title = match[2].trim() || titleMark[type] || capitalize(type)