@expressive-code/plugin-shiki
Advanced tools
Comparing version 0.33.3 to 0.33.4
@@ -41,21 +41,13 @@ // src/index.ts | ||
async function ensureLanguageIsLoaded(highlighter, language) { | ||
const loadedLanguages = new Set(highlighter.getLoadedLanguages()); | ||
const isLoaded = loadedLanguages.has(language); | ||
const isSpecial = isSpecialLang(language); | ||
const isBundled = Object.keys(bundledLanguages).includes(language); | ||
const isAvailable = isLoaded || isSpecial || isBundled; | ||
if (!isAvailable) | ||
return "txt"; | ||
if (isLoaded || isSpecial) | ||
return language; | ||
const loadedLanguage = await memoizeHighlighterTask(highlighter, `loadLanguage:${language}`, async () => { | ||
const loadedLanguages = new Set(highlighter.getLoadedLanguages()); | ||
const isLoaded = loadedLanguages.has(language); | ||
const isSpecial = isSpecialLang(language); | ||
const isBundled = Object.keys(bundledLanguages).includes(language); | ||
const isAvailable = isLoaded || isSpecial || isBundled; | ||
if (!isAvailable) | ||
return "txt"; | ||
const langsToLoad = []; | ||
if (["md", "markdown", "mdx"].includes(language)) { | ||
const bundledLang = (await bundledLanguages[language]()).default; | ||
const embeddedLangsLazy = [...new Set(bundledLang.flatMap((lang) => lang.embeddedLangsLazy ?? []))]; | ||
const missingEmbeddedLangs = embeddedLangsLazy.filter((lang) => !loadedLanguages.has(lang)); | ||
langsToLoad.push(...missingEmbeddedLangs); | ||
} | ||
if (!isLoaded && !isSpecial) | ||
langsToLoad.push(language); | ||
if (langsToLoad.length) | ||
await highlighter.loadLanguage(...langsToLoad); | ||
await highlighter.loadLanguage(language); | ||
return language; | ||
@@ -62,0 +54,0 @@ }); |
{ | ||
"name": "@expressive-code/plugin-shiki", | ||
"version": "0.33.3", | ||
"version": "0.33.4", | ||
"description": "Shiki syntax highlighting plugin for Expressive Code, a text marking & annotation engine for presenting source code on the web.", | ||
@@ -26,3 +26,3 @@ "keywords": [], | ||
"dependencies": { | ||
"@expressive-code/core": "^0.33.3", | ||
"@expressive-code/core": "^0.33.4", | ||
"shiki": "^1.1.7" | ||
@@ -29,0 +29,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
56790
435