Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

highlightingExtensions.ts

22 lines910 Bytes

1import {
2 EXTENSION_TO_FILE_FORMAT,
3 getCustomExtensionsMap,
4 setCustomExtension,
5} from "@pierre/diffs/utils/getFiletypeFromFileName";
6​
7// The default .s mapping is riscv, which the Highlights backend does not support.
8for (const extension of ["asm", "ASM", "s", "S", "nasm", "NASM"]) {
9 setCustomExtension(extension, "asm");
11​
12// Highlights has no lexer for these dialects, so they use their base language's.
13setCustomExtension("luau", "lua");
14setCustomExtension("xsl", "xml");
15setCustomExtension("xslt", "xml");
16​
17// Extensions are matched case-sensitively, so MAIN.PY or DATA.JSON would show as plain text.
18const knownExtensions = { ...EXTENSION_TO_FILE_FORMAT, ...getCustomExtensionsMap() };
19for (const [extension, language] of Object.entries(knownExtensions)) {
20 const upper = extension.toUpperCase();
21 if (language && !Object.hasOwn(knownExtensions, upper)) setCustomExtension(upper, language);