|
|
@ -14,31 +14,24 @@ export const containerPlugin = (
|
|
|
|
options: Options,
|
|
|
|
options: Options,
|
|
|
|
containerOptions?: ContainerOptions
|
|
|
|
containerOptions?: ContainerOptions
|
|
|
|
) => {
|
|
|
|
) => {
|
|
|
|
md.use(...createContainer('tip', containerOptions?.tipLabel || 'TIP', md))
|
|
|
|
const defaultContainers = {
|
|
|
|
.use(...createContainer('info', containerOptions?.infoLabel || 'INFO', md))
|
|
|
|
tip: containerOptions?.tipLabel ?? 'TIP',
|
|
|
|
.use(
|
|
|
|
info: containerOptions?.infoLabel ?? 'INFO',
|
|
|
|
...createContainer(
|
|
|
|
warning: containerOptions?.warningLabel ?? 'WARNING',
|
|
|
|
'warning',
|
|
|
|
danger: containerOptions?.dangerLabel ?? 'DANGER',
|
|
|
|
containerOptions?.warningLabel || 'WARNING',
|
|
|
|
details: containerOptions?.detailsLabel ?? 'Details'
|
|
|
|
md
|
|
|
|
}
|
|
|
|
)
|
|
|
|
const containers: Record<string, string> = {
|
|
|
|
)
|
|
|
|
...defaultContainers,
|
|
|
|
.use(
|
|
|
|
...(containerOptions?.customContainers ?? {})
|
|
|
|
...createContainer(
|
|
|
|
}
|
|
|
|
'danger',
|
|
|
|
|
|
|
|
containerOptions?.dangerLabel || 'DANGER',
|
|
|
|
Object.entries(containers).forEach(([key, value]) => {
|
|
|
|
md
|
|
|
|
md.use(...createContainer(key, value, md))
|
|
|
|
)
|
|
|
|
})
|
|
|
|
)
|
|
|
|
|
|
|
|
.use(
|
|
|
|
|
|
|
|
...createContainer(
|
|
|
|
|
|
|
|
'details',
|
|
|
|
|
|
|
|
containerOptions?.detailsLabel || 'Details',
|
|
|
|
|
|
|
|
md
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
// explicitly escape Vue syntax
|
|
|
|
// explicitly escape Vue syntax
|
|
|
|
.use(container, 'v-pre', {
|
|
|
|
md.use(container, 'v-pre', {
|
|
|
|
render: (tokens: Token[], idx: number) =>
|
|
|
|
render: (tokens: Token[], idx: number) =>
|
|
|
|
tokens[idx].nesting === 1 ? `<div v-pre>\n` : `</div>\n`
|
|
|
|
tokens[idx].nesting === 1 ? `<div v-pre>\n` : `</div>\n`
|
|
|
|
})
|
|
|
|
})
|
|
|
@ -136,4 +129,5 @@ export interface ContainerOptions {
|
|
|
|
detailsLabel?: string
|
|
|
|
detailsLabel?: string
|
|
|
|
importantLabel?: string
|
|
|
|
importantLabel?: string
|
|
|
|
cautionLabel?: string
|
|
|
|
cautionLabel?: string
|
|
|
|
|
|
|
|
customContainers?: Record<string, string>
|
|
|
|
}
|
|
|
|
}
|
|
|
|