mirror of
https://github.com/pesde-pkg/pesde.git
synced 2025-05-04 02:23:51 +01:00
fix(website): code block with an unknown language
This commit is contained in:
parent
4c268e1f05
commit
bc9df65c89
3 changed files with 29 additions and 0 deletions
Binary file not shown.
|
@ -53,5 +53,8 @@
|
|||
"shiki": "^1.22.0",
|
||||
"tar-stream": "^3.1.7",
|
||||
"unified": "^11.0.5"
|
||||
},
|
||||
"patchedDependencies": {
|
||||
"@shikijs/rehype@1.22.0": "patches/@shikijs%2Frehype@1.22.0.patch"
|
||||
}
|
||||
}
|
||||
|
|
26
website/patches/@shikijs%2Frehype@1.22.0.patch
Normal file
26
website/patches/@shikijs%2Frehype@1.22.0.patch
Normal file
|
@ -0,0 +1,26 @@
|
|||
@shikis/rehype doesn't use the `fallbackLanguage` if `lazy` is used.
|
||||
|
||||
--- a/dist/core.mjs
|
||||
+++ b/dist/core.mjs
|
||||
@@ -1,6 +1,8 @@
|
||||
import { visit } from 'unist-util-visit';
|
||||
import { toString } from 'hast-util-to-string';
|
||||
|
||||
+import { bundledLanguages } from 'shiki';
|
||||
+
|
||||
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)
|
||||
return defaultLanguage;
|
||||
+
|
||||
+ if (!(lang in bundledLanguages))
|
||||
+ return fallbackLanguage;
|
||||
+
|
||||
if (highlighter.getLoadedLanguages().includes(lang))
|
||||
return lang;
|
||||
if (lazy) {
|
Loading…
Add table
Reference in a new issue