File size: 2,560 Bytes
31dd200
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/**

 * Maps file extensions to highlight.js language identifiers

 */
export function getLanguageFromFilename(filename: string): string {
	const extension = filename.toLowerCase().substring(filename.lastIndexOf('.'));

	switch (extension) {
		// JavaScript / TypeScript
		case '.js':
		case '.mjs':
		case '.cjs':
			return 'javascript';
		case '.ts':
		case '.mts':
		case '.cts':
			return 'typescript';
		case '.jsx':
			return 'javascript';
		case '.tsx':
			return 'typescript';

		// Web
		case '.html':
		case '.htm':
			return 'html';
		case '.css':
			return 'css';
		case '.scss':
			return 'scss';
		case '.less':
			return 'less';
		case '.vue':
			return 'html';
		case '.svelte':
			return 'html';

		// Data formats
		case '.json':
			return 'json';
		case '.xml':
			return 'xml';
		case '.yaml':
		case '.yml':
			return 'yaml';
		case '.toml':
			return 'ini';
		case '.csv':
			return 'plaintext';

		// Programming languages
		case '.py':
			return 'python';
		case '.java':
			return 'java';
		case '.kt':
		case '.kts':
			return 'kotlin';
		case '.scala':
			return 'scala';
		case '.cpp':
		case '.cc':
		case '.cxx':
		case '.c++':
			return 'cpp';
		case '.c':
			return 'c';
		case '.h':
		case '.hpp':
			return 'cpp';
		case '.cs':
			return 'csharp';
		case '.go':
			return 'go';
		case '.rs':
			return 'rust';
		case '.rb':
			return 'ruby';
		case '.php':
			return 'php';
		case '.swift':
			return 'swift';
		case '.dart':
			return 'dart';
		case '.r':
			return 'r';
		case '.lua':
			return 'lua';
		case '.pl':
		case '.pm':
			return 'perl';

		// Shell
		case '.sh':
		case '.bash':
		case '.zsh':
			return 'bash';
		case '.bat':
		case '.cmd':
			return 'dos';
		case '.ps1':
			return 'powershell';

		// Database
		case '.sql':
			return 'sql';

		// Markup / Documentation
		case '.md':
		case '.markdown':
			return 'markdown';
		case '.tex':
		case '.latex':
			return 'latex';
		case '.adoc':
		case '.asciidoc':
			return 'asciidoc';

		// Config
		case '.ini':
		case '.cfg':
		case '.conf':
			return 'ini';
		case '.dockerfile':
			return 'dockerfile';
		case '.nginx':
			return 'nginx';

		// Other
		case '.graphql':
		case '.gql':
			return 'graphql';
		case '.proto':
			return 'protobuf';
		case '.diff':
		case '.patch':
			return 'diff';
		case '.log':
			return 'plaintext';
		case '.txt':
			return 'plaintext';

		default:
			return 'plaintext';
	}
}