diff options
author | 2025-06-05 14:25:23 +0000 | |
---|---|---|
committer | 2025-06-05 14:25:23 +0000 | |
commit | e586d7d704d475afe3373a1de6ae20d504f79d6d (patch) | |
tree | 7e3fa24807cebd48a86bd40f866d792181191ee9 /packages/markdown/remark/test/highlight.test.js | |
download | astro-e586d7d704d475afe3373a1de6ae20d504f79d6d.tar.gz astro-e586d7d704d475afe3373a1de6ae20d504f79d6d.tar.zst astro-e586d7d704d475afe3373a1de6ae20d504f79d6d.zip |
Sync from a8e1c0a7402940e0fc5beef669522b315052df1blatest
Diffstat (limited to 'packages/markdown/remark/test/highlight.test.js')
-rw-r--r-- | packages/markdown/remark/test/highlight.test.js | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/packages/markdown/remark/test/highlight.test.js b/packages/markdown/remark/test/highlight.test.js new file mode 100644 index 000000000..bcd2086b5 --- /dev/null +++ b/packages/markdown/remark/test/highlight.test.js @@ -0,0 +1,52 @@ +import assert from 'node:assert/strict'; +import { describe, it } from 'node:test'; +import { createMarkdownProcessor } from '../dist/index.js'; + +describe('highlight', () => { + it('highlights using shiki by default', async () => { + const processor = await createMarkdownProcessor(); + const { code } = await processor.render('```js\nconsole.log("Hello, world!");\n```'); + assert.match(code, /background-color:/); + }); + + it('does not highlight math code blocks by default', async () => { + const processor = await createMarkdownProcessor(); + const { code } = await processor.render('```math\n\\frac{1}{2}\n```'); + + assert.ok(!code.includes('background-color:')); + }); + + it('highlights using prism', async () => { + const processor = await createMarkdownProcessor({ + syntaxHighlight: { + type: 'prism', + }, + }); + const { code } = await processor.render('```js\nconsole.log("Hello, world!");\n```'); + assert.ok(code.includes('token')); + }); + + it('supports excludeLangs', async () => { + const processor = await createMarkdownProcessor({ + syntaxHighlight: { + type: 'shiki', + excludeLangs: ['mermaid'], + }, + }); + const { code } = await processor.render('```mermaid\ngraph TD\nA --> B\n```'); + + assert.ok(!code.includes('background-color:')); + }); + + it('supports excludeLangs with prism', async () => { + const processor = await createMarkdownProcessor({ + syntaxHighlight: { + type: 'prism', + excludeLangs: ['mermaid'], + }, + }); + const { code } = await processor.render('```mermaid\ngraph TD\nA --> B\n```'); + + assert.ok(!code.includes('token')); + }); +}); |