2021-09-26 22:09:33 +00:00
|
|
|
import container from 'markdown-it-container'
|
|
|
|
import type Token from 'markdown-it/lib/token'
|
|
|
|
|
|
|
|
type ContainerArgs = [
|
|
|
|
typeof container,
|
|
|
|
string,
|
|
|
|
{
|
|
|
|
render(tokens: Token[], idx: number): string
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
export default function createContainer(
|
|
|
|
klass: string,
|
|
|
|
defaultTitle: string
|
|
|
|
): ContainerArgs {
|
|
|
|
return [
|
|
|
|
container,
|
|
|
|
klass,
|
|
|
|
{
|
|
|
|
render(tokens, idx) {
|
|
|
|
const token = tokens[idx]
|
|
|
|
const info = token.info.trim().slice(klass.length).trim()
|
|
|
|
if (token.nesting === 1) {
|
2021-10-25 17:13:23 +00:00
|
|
|
return `<lay-block style="margin-left:8px;margin-bottom:40px;">${info}`
|
2021-09-26 22:09:33 +00:00
|
|
|
} else {
|
2021-10-25 17:13:23 +00:00
|
|
|
return '</lay-block>\n'
|
2021-09-26 22:09:33 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
]
|
2021-10-23 07:54:37 +00:00
|
|
|
}
|