-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
33 lines (29 loc) · 762 Bytes
/
index.ts
File metadata and controls
33 lines (29 loc) · 762 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
* @dimerapp/shiki
*
* (c) DimerApp
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { map } from 'unist-util-map'
import type { Code, Node } from '@dimerapp/markdown/types'
import { Shiki } from './src/shiki.js'
export { Shiki }
export type { Theme, IShikiTheme, Highlighter, ILanguageRegistration } from 'shiki'
/**
* Remark plugin to transform codeblocks using shiki
*/
export function codeblocks(renderer: Shiki) {
return (tree: Node) => {
return map(tree as any, (node) => {
if (node.type !== 'code') {
return node
}
/**
* Render plain text to code
*/
return renderer.render(node as Code)
})
}
}