mirror of
https://github.com/pesde-pkg/pesde.git
synced 2024-12-12 02:50:37 +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.
|
@ -1,71 +1,71 @@
|
|||
{
|
||||
"name": "website",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "vite dev",
|
||||
"build": "vite build",
|
||||
"preview": "vite preview",
|
||||
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
||||
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
||||
"lint": "prettier --check . && eslint .",
|
||||
"format": "prettier --write ."
|
||||
},
|
||||
"devDependencies": {
|
||||
"@sveltejs/adapter-vercel": "^5.4.6",
|
||||
"@sveltejs/kit": "^2.7.3",
|
||||
"@sveltejs/vite-plugin-svelte": "^4.0.0",
|
||||
"@tailwindcss/typography": "^0.5.15",
|
||||
"@types/eslint": "^9.6.1",
|
||||
"@types/gunzip-maybe": "^1.4.2",
|
||||
"@types/tar-stream": "^3.1.3",
|
||||
"autoprefixer": "^10.4.20",
|
||||
"eslint": "^9.13.0",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
"eslint-plugin-svelte": "^2.46.0",
|
||||
"globals": "^15.11.0",
|
||||
"mdsvex": "^0.12.3",
|
||||
"prettier": "^3.3.3",
|
||||
"prettier-plugin-svelte": "^3.2.7",
|
||||
"prettier-plugin-tailwindcss": "^0.6.8",
|
||||
"svelte": "^5.1.4",
|
||||
"svelte-check": "^4.0.5",
|
||||
"tailwindcss": "^3.4.14",
|
||||
"typescript": "^5.6.3",
|
||||
"typescript-eslint": "^8.12.2",
|
||||
"vite": "^5.4.10"
|
||||
},
|
||||
"type": "module",
|
||||
"dependencies": {
|
||||
"@fontsource-variable/nunito-sans": "^5.1.0",
|
||||
"@shikijs/rehype": "^1.22.2",
|
||||
"@types/hast": "^3.0.4",
|
||||
"@types/unist": "^3.0.3",
|
||||
"bits-ui": "next",
|
||||
"date-fns": "^4.1.0",
|
||||
"gunzip-maybe": "^1.4.2",
|
||||
"hast-util-heading": "^3.0.0",
|
||||
"hast-util-heading-rank": "^3.0.0",
|
||||
"hast-util-to-text": "^4.0.2",
|
||||
"lucide-svelte": "^0.446.0",
|
||||
"rehype-infer-description-meta": "^2.0.0",
|
||||
"rehype-raw": "^7.0.0",
|
||||
"rehype-sanitize": "^6.0.0",
|
||||
"rehype-slug": "^6.0.0",
|
||||
"rehype-stringify": "^10.0.1",
|
||||
"remark-frontmatter": "^5.0.0",
|
||||
"remark-gemoji": "^8.0.0",
|
||||
"remark-gfm": "^4.0.0",
|
||||
"remark-parse": "^11.0.0",
|
||||
"remark-rehype": "^11.1.1",
|
||||
"shiki": "^1.22.2",
|
||||
"tar-stream": "^3.1.7",
|
||||
"unified": "^11.0.5",
|
||||
"unist-util-map": "^4.0.0",
|
||||
"vfile": "^6.0.3"
|
||||
},
|
||||
"patchedDependencies": {
|
||||
"@shikijs/rehype@1.22.0": "patches/@shikijs%2Frehype@1.22.0.patch"
|
||||
},
|
||||
"packageManager": "bun@1.1.33"
|
||||
"name": "website",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "vite dev",
|
||||
"build": "vite build",
|
||||
"preview": "vite preview",
|
||||
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
||||
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
||||
"lint": "prettier --check . && eslint .",
|
||||
"format": "prettier --write ."
|
||||
},
|
||||
"devDependencies": {
|
||||
"@sveltejs/adapter-vercel": "^5.4.6",
|
||||
"@sveltejs/kit": "^2.7.3",
|
||||
"@sveltejs/vite-plugin-svelte": "^4.0.0",
|
||||
"@tailwindcss/typography": "^0.5.15",
|
||||
"@types/eslint": "^9.6.1",
|
||||
"@types/gunzip-maybe": "^1.4.2",
|
||||
"@types/tar-stream": "^3.1.3",
|
||||
"autoprefixer": "^10.4.20",
|
||||
"eslint": "^9.13.0",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
"eslint-plugin-svelte": "^2.46.0",
|
||||
"globals": "^15.11.0",
|
||||
"mdsvex": "^0.12.3",
|
||||
"prettier": "^3.3.3",
|
||||
"prettier-plugin-svelte": "^3.2.7",
|
||||
"prettier-plugin-tailwindcss": "^0.6.8",
|
||||
"svelte": "^5.1.4",
|
||||
"svelte-check": "^4.0.5",
|
||||
"tailwindcss": "^3.4.14",
|
||||
"typescript": "^5.6.3",
|
||||
"typescript-eslint": "^8.12.2",
|
||||
"vite": "^5.4.10"
|
||||
},
|
||||
"type": "module",
|
||||
"dependencies": {
|
||||
"@fontsource-variable/nunito-sans": "^5.1.0",
|
||||
"@shikijs/rehype": "^1.22.2",
|
||||
"@types/hast": "^3.0.4",
|
||||
"@types/unist": "^3.0.3",
|
||||
"bits-ui": "next",
|
||||
"date-fns": "^4.1.0",
|
||||
"gunzip-maybe": "^1.4.2",
|
||||
"hast-util-heading": "^3.0.0",
|
||||
"hast-util-heading-rank": "^3.0.0",
|
||||
"hast-util-to-text": "^4.0.2",
|
||||
"lucide-svelte": "^0.446.0",
|
||||
"rehype-infer-description-meta": "^2.0.0",
|
||||
"rehype-raw": "^7.0.0",
|
||||
"rehype-sanitize": "^6.0.0",
|
||||
"rehype-slug": "^6.0.0",
|
||||
"rehype-stringify": "^10.0.1",
|
||||
"remark-frontmatter": "^5.0.0",
|
||||
"remark-gemoji": "^8.0.0",
|
||||
"remark-gfm": "^4.0.0",
|
||||
"remark-parse": "^11.0.0",
|
||||
"remark-rehype": "^11.1.1",
|
||||
"shiki": "^1.22.2",
|
||||
"tar-stream": "^3.1.7",
|
||||
"unified": "^11.0.5",
|
||||
"unist-util-map": "^4.0.0",
|
||||
"vfile": "^6.0.3"
|
||||
},
|
||||
"patchedDependencies": {
|
||||
"@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