Commit 1ae0596 1 parent 3b890e8 commit 1ae0596 Copy full SHA for 1ae0596
File tree 1 file changed +14
-1
lines changed
src/node/markdown/plugins
1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change
1
+ import { customAlphabet } from 'nanoid'
2
+ import c from 'picocolors'
1
3
import type { HtmlRendererOptions , IThemeRegistration } from 'shiki'
2
4
import {
3
5
addClass ,
@@ -10,7 +12,6 @@ import {
10
12
type Processor
11
13
} from 'shiki-processor'
12
14
import type { ThemeOptions } from '../markdown'
13
- import { customAlphabet } from 'nanoid'
14
15
15
16
const nanoid = customAlphabet ( 'abcdefghijklmnopqrstuvwxyz' , 10 )
16
17
@@ -85,6 +86,18 @@ export async function highlight(
85
86
lang =
86
87
lang . replace ( lineNoRE , '' ) . replace ( vueRE , '' ) . toLowerCase ( ) || defaultLang
87
88
89
+ const langLoaded = highlighter . getLoadedLanguages ( ) . includes ( lang as any )
90
+ if ( ! langLoaded ) {
91
+ console . warn (
92
+ c . yellow (
93
+ `The language '${ lang } ' is not loaded, falling back to '${
94
+ defaultLang || 'txt'
95
+ } ' for syntax highlighting.`
96
+ )
97
+ )
98
+ lang = defaultLang
99
+ }
100
+
88
101
const lineOptions = attrsToLines ( attrs )
89
102
const cleanup = ( str : string ) =>
90
103
str
You can’t perform that action at this time.
0 commit comments