import { createMarkdownRenderer, disposeMdItInstance, type MarkdownOptions } from 'node/markdown/markdown' async function render(src: string, options: MarkdownOptions = {}) { disposeMdItInstance() const md = await createMarkdownRenderer('.', { highlight: (code) => code, ...options }) return md.renderAsync(src) } describe('node/markdown/plugins/containers', () => { test('renders built-in containers with default titles', async () => { const src = [ 'tip', 'info', 'warning', 'danger', 'note', 'important', 'caution' ] .map((t) => `::: ${t}\ncontent of ${t}\n:::`) .join('\n\n') expect(await render(src)).toMatchInlineSnapshot(` "
TIP
content of tip
INFO
content of info
WARNING
content of warning
DANGER
content of danger
NOTE
content of note
IMPORTANT
content of important
CAUTION
content of caution
hidden content
STOP
Danger zone, do not proceed
A bold title with code
content
console.log('hi')
See the guide
content
提示
提示内容
详情内容
content
Custom
content
Custom
content
content
content
still needs its summary
content
{{ this will be displayed as-is }}
Wraps in a <div class="vp-raw">
const a = 1
const a: number = 1
Outer
outer content
inner content
WARNING
no closing fence
TIP
content
::: unknown content :::
" `) }) }) describe('node/markdown/plugins/containers (github alerts)', () => { test('renders github alerts like containers', async () => { const src = [ '> [!NOTE]', '> note content', '', '> [!TIP]', '> tip content', '', '> [!IMPORTANT]', '> important content', '', '> [!WARNING]', '> warning content', '', '> [!CAUTION]', '> caution content' ].join('\n') expect(await render(src)).toMatchInlineSnapshot(` "NOTE
note content
TIP
tip content
IMPORTANT
important content
WARNING
warning content
CAUTION
caution content
TIP
content
Custom Title
content
提示
content
NOTE
first paragraph lazy continuation
const a = 1
NOTE
just a quote
[!FOO] not an alert
paragraph [!NOTE] not at blockquote start
" `) }) test('can be disabled via gfmAlerts: false', async () => { expect(await render('> [!NOTE]\n> content', { gfmAlerts: false })) .toMatchInlineSnapshot(` "" `) }) })[!NOTE] content