mirror of
https://github.com/pengzhanbo/vuepress-theme-plume.git
synced 2026-05-01 12:38:12 +08:00
10 lines
369 B
TypeScript
10 lines
369 B
TypeScript
export function resolveAttr(info: string, attr: string): string | null {
|
|
// try to match specified attr mark
|
|
const pattern = `\\b${attr}\\s*=\\s*(?<quote>['"])(?<content>.+?)\\k<quote>(\\s|$)`
|
|
const regex = new RegExp(pattern, 'i')
|
|
const match = info.match(regex)
|
|
|
|
// return content if matched, null if not specified
|
|
return match?.groups?.content ?? null
|
|
}
|