{"record":{"id":"7c70711649433b47","repo":"withastro/astro","slug":"unable-to-load-the-language-lang","errorCode":null,"errorMessage":"Unable to load the language: ${lang}","messagePattern":"Unable to load the language: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/astro-prism/src/highlighter.ts","lineNumber":29,"sourceCode":"\tlet classLanguage = `language-${lang}`;\n\tconst ensureLoaded = async (language: string) => {\n\t\tif (language && !Prism.languages[language]) {\n\t\t\tawait loadLanguages([language]);\n\t\t}\n\t};\n\n\tif (languageMap.has(lang)) {\n\t\tawait ensureLoaded(languageMap.get(lang)!);\n\t} else if (lang === 'astro') {\n\t\tawait ensureLoaded('typescript');\n\t\taddAstro(Prism);\n\t} else {\n\t\tawait ensureLoaded('markup-templating'); // Prism expects this to exist for a number of other langs\n\t\tawait ensureLoaded(lang);\n\t}\n\n\tif (lang && !Prism.languages[lang]) {\n\t\tconsole.warn(`Unable to load the language: ${lang}`);\n\t}\n\n\tconst grammar = Prism.languages[lang];\n\tlet html = code;\n\tif (grammar) {\n\t\thtml = Prism.highlight(code, grammar, lang);\n\t}\n\n\treturn { classLanguage, html };\n}\n","sourceCodeStart":11,"sourceCodeEnd":40,"githubUrl":"https://github.com/withastro/astro/blob/52e6c34790cc8ac4e69e6135ace06049867e5c4a/packages/astro-prism/src/highlighter.ts#L11-L40","documentation":"astro-prism highlights fenced code blocks during static generation using Prism. After attempting to load the requested language id (including the markup-templating dependency Prism expects), if `Prism.languages[lang]` is still undefined it warns 'Unable to load the language' and emits the code unhighlighted — wrapped only in the language class. Markdown rendering continues; only syntax coloring is lost.","triggerScenarios":"A fenced block with a language id that is not a Prism language (typo like ```javscipt, a custom DSL like ```mylang), or an id not shipped in the prismjs components the project bundles.","commonSituations":"Docs sites with custom fence languages; simple typos in language tags; niche languages without a Prism grammar.","solutions":["Use a valid Prism language id or alias (ts, js, sh, yaml) in the fence","Register a custom grammar on `Prism.languages.mylang` before rendering if you need highlighting for a DSL","Accept plain output if the language genuinely has no grammar — nothing else breaks"],"exampleFix":"// before\n```myquery\nSELECT 1;\n```\n\n// after (grammar exists in Prism)\n```sql\nSELECT 1;\n```","handlingStrategy":"type-guard","validationCode":"// Before rendering, check the fence language is a loaded Prism grammar\nimport Prism from 'prismjs';\nconst lang = fenceInfo.language;\nif (!(lang in Prism.languages)) {\n  return renderPlain(code); // skip highlighting instead of warning per build\n}","typeGuard":"import type Prism from 'prismjs';\nconst isPrismLanguage = (lang: string): lang is keyof typeof Prism.languages =>\n  lang !== 'extend' && lang !== 'insertBefore' && lang !== 'DFS' && lang in Prism.languages;","tryCatchPattern":null,"preventionTips":["Use well-known Prism ids and aliases (ts, js, sh, bash, yaml, json)","Register custom DSL grammars on Prism.languages before markdown rendering","Lint code-fence languages in CI to catch typos at the source"],"tags":["prism","syntax-highlighting","markdown","ssg"],"backgroundTag":"prism-language-unsupported","analyzedSha":"52e6c34790cc8ac4e69e6135ace06049867e5c4a","analyzedAt":"2026-08-18T18:48:03.901Z","contentChangedAt":"2026-08-18T18:48:03.901Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}