import { markdownContainerPlugin as containerPlugin } from '@vuepress/plugin-markdown-container' import type { Plugin } from 'vuepress/core' export const customContainerPlugins: Plugin[] = [ /** * :::demo-wrapper img no-padding title="xxx" height="100px" * ::: */ containerPlugin({ type: 'demo-wrapper', before(info) { const title = resolveAttr(info, 'title') const wrapperClasses: string[] = ['demo-wrapper'] let containerStyle = '' if (title) wrapperClasses.push('has-title') if (info.includes('img')) wrapperClasses.push('only-img') if (info.includes('no-padding')) wrapperClasses.push('no-padding') const height = resolveAttr(info, 'height') if (height) { const h = Number.parseFloat(height) === Number(height) ? `${height}px` : height containerStyle += `--demo-container-height: ${h};` wrapperClasses.push('has-height') } return `
${title}
` : ''}['"])(?.+?)\\k (\\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 }