mirror of
https://github.com/elk-zone/elk.git
synced 2024-11-22 01:15:25 +03:00
fix: shiki fallback language (#1044)
This commit is contained in:
parent
0407ef353f
commit
f76628d4ab
2 changed files with 6 additions and 5 deletions
|
@ -32,10 +32,11 @@ export function useHightlighter(lang: Lang) {
|
||||||
.then(() => {
|
.then(() => {
|
||||||
registeredLang.value.set(lang, true)
|
registeredLang.value.set(lang, true)
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch(() => {
|
||||||
console.error(`[shiki] Failed to load language ${lang}`)
|
const fallbackLang = 'md'
|
||||||
console.error(e)
|
shiki.value?.loadLanguage(fallbackLang).then(() => {
|
||||||
registeredLang.value.set(lang, false)
|
registeredLang.value.set(fallbackLang, true)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ function getDecorations({
|
||||||
findChildren(doc, node => node.type.name === name)
|
findChildren(doc, node => node.type.name === name)
|
||||||
.forEach((block) => {
|
.forEach((block) => {
|
||||||
let from = block.pos + 1
|
let from = block.pos + 1
|
||||||
const language = block.node.attrs.language || 'text'
|
const language = block.node.attrs.language
|
||||||
|
|
||||||
const shiki = useHightlighter(language)
|
const shiki = useHightlighter(language)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue