mirror of
https://github.com/pesde-pkg/pesde.git
synced 2024-12-12 11:00:36 +00:00
fix(website): shiki fallback language patch (#5)
This commit is contained in:
parent
236edff6a0
commit
1640dab0c4
3 changed files with 75 additions and 79 deletions
Binary file not shown.
|
@ -65,7 +65,7 @@
|
|||
"vfile": "^6.0.3"
|
||||
},
|
||||
"patchedDependencies": {
|
||||
"@shikijs/rehype@1.22.0": "patches/@shikijs%2Frehype@1.22.0.patch"
|
||||
"@shikijs/rehype@1.22.2": "patches/@shikijs%2Frehype@1.22.2.patch"
|
||||
},
|
||||
"packageManager": "bun@1.1.33"
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
--- a/dist/core.mjs
|
||||
+++ b/dist/core.mjs
|
||||
@@ -1,6 +1,8 @@
|
||||
@@ -2,6 +2,8 @@ import { isSpecialLang } from 'shiki/core';
|
||||
import { visit } from 'unist-util-visit';
|
||||
import { toString } from 'hast-util-to-string';
|
||||
|
||||
|
@ -11,16 +11,12 @@
|
|||
const InlineCodeHandlers = {
|
||||
"tailing-curly-colon": (_tree, node) => {
|
||||
const raw = toString(node);
|
||||
@@ -90,8 +92,12 @@ function rehypeShikiFromHighlighter(highlighter, options) {
|
||||
const languageQueue = [];
|
||||
const queue = [];
|
||||
function getLanguage(lang) {
|
||||
if (!lang)
|
||||
@@ -95,6 +97,8 @@ function rehypeShikiFromHighlighter(highlighter, options) {
|
||||
return defaultLanguage;
|
||||
+
|
||||
if (highlighter.getLoadedLanguages().includes(lang) || isSpecialLang(lang))
|
||||
return lang;
|
||||
+ if (!(lang in bundledLanguages))
|
||||
+ return fallbackLanguage;
|
||||
+
|
||||
if (highlighter.getLoadedLanguages().includes(lang))
|
||||
return lang;
|
||||
if (lazy) {
|
||||
languageQueue.push(lang);
|
||||
return lang;
|
Loading…
Reference in a new issue