\w+\b))\}\s?(?!\[.*?\])/
const match = rule.exec(src)
if (match) {
+ const { groups } = match
return {
type: 'mention',
raw: match[0],
- text: this.lexer.inlineTokens(match[1].trim(), []),
+ groups,
}
}
},
childTokens: ['text'],
},
+ {
+ level: 'block',
+ name: 'container',
+ start(src) {
+ return src.indexOf(':::')
+ },
+ renderer(token) {
+ const { groups, images, paragraph } = token
+ const { params, content, name } = groups
+
+ switch (name) {
+ case 'gallery':
+ // @ts-expect-error
+ return `${this.parser.parseInline(
+ images,
+ )}
`
+ case 'banner':
+ return `${this.parser.parse(
+ paragraph,
+ )}
`
+ }
+ return ''
+ },
+ tokenizer(src) {
+ const shouldCatchContainerName = [
+ 'gallery',
+ 'banner',
+ /* 'carousel', */
+ ].join('|')
+ const match = new RegExp(
+ `^\\s*::: *(?(${shouldCatchContainerName})) *({(?(.*?))})? *\n(?[\\s\\S]+?)\\s*::: *(?:\n *)+\n?`,
+ ).exec(src)
+ if (match) {
+ const { groups } = match
+ return {
+ type: 'container',
+ raw: match[0],
+ groups,
+ // @ts-expect-error
+ images: this.lexer.inlineTokens(groups.content),
+ // @ts-expect-error
+ paragraph: this.lexer.blockTokens(groups.content),
+ }
+ }
+ },
+ childTokens: ['paragraph', 'image'],
+ },
],
renderer: {
@@ -350,18 +428,24 @@ ${text.trim()}
'',
'',
'',
- '',
+ '',
// '',
// '',
// '',
+ '',
],
script: [
`window.mermaid.initialize({theme: 'default',startOnLoad: false})`,
`window.mermaid.init(undefined, '.mermaid')`,
+ `window.onload = () => { document.querySelectorAll('.katex-render').forEach(el => { window.katex.render(el.innerHTML, el, {
+ throwOnError: false,
+ }) }) }`,
],
link: [
'',
'',
+ // katex
+ '',
],
style: [style, themeStyleSheet],
}