mirror of
https://github.com/doocs/md.git
synced 2025-02-10 16:55:49 +08:00
feat: add case-insensitivity to alert type matching
This commit is contained in:
parent
c48f6419d3
commit
b9953ab2e7
@ -17,7 +17,7 @@ export default function markedAlert(options: AlertOptions = {}): MarkedExtension
|
|||||||
return
|
return
|
||||||
|
|
||||||
const matchedVariant = resolvedVariants.find(({ type }) =>
|
const matchedVariant = resolvedVariants.find(({ type }) =>
|
||||||
new RegExp(createSyntaxPattern(type)).test(token.text),
|
new RegExp(createSyntaxPattern(type), `i`).test(token.text),
|
||||||
)
|
)
|
||||||
|
|
||||||
if (matchedVariant) {
|
if (matchedVariant) {
|
||||||
@ -148,7 +148,7 @@ export function resolveVariants(variants: AlertVariantItem[]) {
|
|||||||
* Returns regex pattern to match alert syntax.
|
* Returns regex pattern to match alert syntax.
|
||||||
*/
|
*/
|
||||||
export function createSyntaxPattern(type: string) {
|
export function createSyntaxPattern(type: string) {
|
||||||
return `^(?:\\[!${type.toUpperCase()}])\\s*?\n*`
|
return `^(?:\\[!${type}])\\s*?\n*`
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user