chore: update regexp

pull/3482/head
Anthony Fu 2 years ago
parent f782fe4f7e
commit 53517e2949

@ -5,16 +5,6 @@ export const gitHubAlertsPlugin = (
md: MarkdownIt, md: MarkdownIt,
options?: ContainerOptions options?: ContainerOptions
) => { ) => {
const markers = [
'TIP',
'NOTE',
'INFO',
'IMPORTANT',
'WARNING',
'CAUTION',
'DANGER'
]
const matchCaseSensitive = true
const titleMark = { const titleMark = {
tip: options?.tipLabel || 'TIP', tip: options?.tipLabel || 'TIP',
note: options?.noteLabel || 'NOTE', note: options?.noteLabel || 'NOTE',
@ -25,11 +15,7 @@ export const gitHubAlertsPlugin = (
danger: options?.dangerLabel || 'DANGER' danger: options?.dangerLabel || 'DANGER'
} as Record<string, string> } as Record<string, string>
const markerNameRE = markers.join('|') const RE = /^\[\!(TIP|NOTE|INFO|IMPORTANT|WARNING|CAUTION|DANGER)\]([^\n\r]*)/i
const RE = new RegExp(
`^\\[\\!(${markerNameRE})\\]([^\\n\\r]*)`,
matchCaseSensitive ? '' : 'i'
)
md.core.ruler.after('block', 'github-alerts', (state) => { md.core.ruler.after('block', 'github-alerts', (state) => {
const tokens = state.tokens const tokens = state.tokens

Loading…
Cancel
Save