From bc9df65c896e280354a211dc9d18cfcf84158270 Mon Sep 17 00:00:00 2001 From: LukaDev <47296785+lukadev-0@users.noreply.github.com> Date: Mon, 14 Oct 2024 16:10:47 +0200 Subject: [PATCH] fix(website): code block with an unknown language --- website/bun.lockb | Bin 215081 -> 215280 bytes website/package.json | 3 ++ .../patches/@shikijs%2Frehype@1.22.0.patch | 26 ++++++++++++++++++ 3 files changed, 29 insertions(+) create mode 100644 website/patches/@shikijs%2Frehype@1.22.0.patch diff --git a/website/bun.lockb b/website/bun.lockb index 88cf96b0a4b5dea374a565a56135921494fbd0e4..0d891c390ce0f7691a6fac515e9a57ff03954676 100755 GIT binary patch delta 211 zcmZ2Ef%n5i-U)t82_B6BtpSWn1DNJAZr>g_m&sw3UqNC?az<*gzC&?FW_D&)v8s_< zQEEnIL8^nHo{^EBfgV@^0~8cEmN;j)rnvlYXNHJ)Kxi(TQZo}f1&iqyXETZ0GcasY zy?98|idn@2DxUyXS6q~=mzh^wl9-dDmy@5IotBxCsuuuuM2bslft`Yp3CIv(3CUFq Z3~CGv4KS-U3)5aLJm||ZJ#hl#1OT|TI}-o^ delta 33 rcmV++0N(%bkqxPk4UkR(nMZ+8g-`*dPy(F+k+)Hu0zj&lVUPis;`|L1 diff --git a/website/package.json b/website/package.json index f2fd583..6f41d22 100644 --- a/website/package.json +++ b/website/package.json @@ -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" } } diff --git a/website/patches/@shikijs%2Frehype@1.22.0.patch b/website/patches/@shikijs%2Frehype@1.22.0.patch new file mode 100644 index 0000000..a2e86a8 --- /dev/null +++ b/website/patches/@shikijs%2Frehype@1.22.0.patch @@ -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) {