fix: shiki fallback language (#1044)
parent
0407ef353f
commit
f76628d4ab
|
@ -32,10 +32,11 @@ export function useHightlighter(lang: Lang) {
|
|||
.then(() => {
|
||||
registeredLang.value.set(lang, true)
|
||||
})
|
||||
.catch((e) => {
|
||||
console.error(`[shiki] Failed to load language ${lang}`)
|
||||
console.error(e)
|
||||
registeredLang.value.set(lang, false)
|
||||
.catch(() => {
|
||||
const fallbackLang = 'md'
|
||||
shiki.value?.loadLanguage(fallbackLang).then(() => {
|
||||
registeredLang.value.set(fallbackLang, true)
|
||||
})
|
||||
})
|
||||
return undefined
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ function getDecorations({
|
|||
findChildren(doc, node => node.type.name === name)
|
||||
.forEach((block) => {
|
||||
let from = block.pos + 1
|
||||
const language = block.node.attrs.language || 'text'
|
||||
const language = block.node.attrs.language
|
||||
|
||||
const shiki = useHightlighter(language)
|
||||
|
||||
|
|
Loading…
Reference in New Issue