Skip to content

Commit 4d20320

Browse files
committed
Fix test for custom grammars
Related-to: GH-35.
1 parent f0b2067 commit 4d20320

File tree

1 file changed

+13
-19
lines changed

1 file changed

+13
-19
lines changed

test.js

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
1-
/**
2-
* @import {LanguageFn} from 'lowlight'
3-
*/
4-
51
import assert from 'node:assert/strict'
62
import test from 'node:test'
7-
import {common} from 'lowlight'
83
import rehypeHighlight from 'rehype-highlight'
94
import rehypeParse from 'rehype-parse'
105
import rehypeStringify from 'rehype-stringify'
@@ -481,13 +476,23 @@ test('rehypeHighlight', async function (t) {
481476
await t.test('should register languages', async function () {
482477
const file = await unified()
483478
.use(rehypeParse, {fragment: true})
484-
.use(rehypeHighlight, {languages: {...common, test: testLang}})
479+
.use(rehypeHighlight, {
480+
languages: {
481+
test() {
482+
return {
483+
aliases: [],
484+
contains: [],
485+
keywords: {keyword: 'bravo'}
486+
}
487+
}
488+
}
489+
})
485490
.use(rehypeStringify)
486491
.process(
487492
[
488493
'<h1>Hello World!</h1>',
489494
'',
490-
'<pre><code class="language-scss">test normal text</code></pre>'
495+
'<pre><code class="language-test">alpha bravo charlie</code></pre>'
491496
].join('\n')
492497
)
493498

@@ -496,19 +501,8 @@ test('rehypeHighlight', async function (t) {
496501
[
497502
'<h1>Hello World!</h1>',
498503
'',
499-
'<pre><code class="hljs language-scss">test <span class="hljs-attribute">normal</span> <span class="hljs-selector-tag">text</span></code></pre>'
504+
'<pre><code class="hljs language-test">alpha <span class="hljs-keyword">bravo</span> charlie</code></pre>'
500505
].join('\n')
501506
)
502-
503-
/**
504-
* @type {LanguageFn}
505-
*/
506-
function testLang() {
507-
return {
508-
aliases: ['test'],
509-
contains: [],
510-
keywords: {keyword: 'test'}
511-
}
512-
}
513507
})
514508
})

0 commit comments

Comments
 (0)