-
-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathlanguageIds.ts
More file actions
33 lines (31 loc) · 866 Bytes
/
languageIds.ts
File metadata and controls
33 lines (31 loc) · 866 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { bundledLanguages, bundledLanguagesAlias } from "shiki";
const LANGUAGE_ID_OVERRIDES: Record<string, string> = {
"bun.lockb": "text",
"code-text-binary": "text",
cfmhtml: "html",
csharp: "c#",
"django-html": "html",
esphome: "yaml",
"go.mod": "go",
"go.work": "go",
"json-tmlanguage": "json",
javascriptreact: "jsx",
"manifest-yaml": "yaml",
plaintext: "text",
proto3: "protobuf",
rmd: "md",
restructuredtext: "rst",
swagger: "yaml",
typescriptreact: "tsx",
"yaml-tmlanguage": "yaml",
};
export function normalizeLanguageIdForHighlighting(languageId: string): string {
const normalized = languageId.toLowerCase();
if (
Object.hasOwn(bundledLanguages, normalized) ||
Object.hasOwn(bundledLanguagesAlias, normalized)
) {
return normalized;
}
return LANGUAGE_ID_OVERRIDES[normalized] ?? normalized;
}