PluginProbe
Code Block Pro – Beautiful Syntax Highlighting / 1.11.1
Code Block Pro – Beautiful Syntax Highlighting v1.11.1
1.27.1 1.27.2 1.27.3 1.27.4 1.27.5 1.27.6 1.27.7 1.28.0 1.3.0 1.4.0 1.5.0 1.5.1 1.5.2 1.6.0 1.7.0 1.8.0 1.9.0 1.9.1 1.9.2 1.9.3 trunk 1.1.0 1.10.0 1.11.0 1.11.1 All 63 releases
code-block-pro / src / util / languages.ts

languages.ts in Code Block Pro – Beautiful Syntax Highlighting 1.11.1, at src/util/languages.ts

64 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { Lang } from 'shiki';
2 import defaultLanguages from '../defaultLanguages.json';
3
4 export const codeAliases = {
5 'actionscript-3': ['as3'],
6 cpp: ['arduino'],
7 xml: ['coldfusion'],
8 pascal: ['delphi'],
9 java: ['javafx'],
10 javascript: ['jscript', 'js'],
11 matlab: ['matlabkey'],
12 'objective-c': ['objc'],
13 bat: ['batch'],
14 berry: ['be'],
15 cadence: ['cdc'],
16 clojure: ['clj'],
17 csharp: ['c#'],
18 erlang: ['erl'],
19 fsharp: ['f#'],
20 haskell: ['hs'],
21 handlebars: ['hbs'],
22 jssm: ['fsl'],
23 make: ['makefile'],
24 markdown: ['md'],
25 powershell: ['ps', 'ps1'],
26 pug: ['jade'],
27 python: ['py'],
28 raku: ['perl6'],
29 ruby: ['rb'],
30 rust: ['rs'],
31 'html-ruby-erb': ['erb'],
32 shaderlab: ['shader'],
33 shellscript: ['shell', 'bash', 'sh', 'zsh'],
34 stylus: ['styl'],
35 typescript: ['ts'],
36 vb: ['cmd'],
37 viml: ['vim', 'vimscript'],
38 wenyan: ['文言'],
39 codeql: ['ql'],
40 };
41
42 export const getMainAlias = (
43 languageAltName: string | undefined,
44 ): string | undefined => {
45 if (!languageAltName) return;
46 return Object.keys(codeAliases).find((key) =>
47 codeAliases[key as keyof typeof codeAliases].includes(languageAltName),
48 );
49 };
50
51 export const removeAliases = (
52 langs: typeof defaultLanguages,
53 ): Partial<typeof defaultLanguages> => {
54 const aliasesToRemove = Object.values(codeAliases).flat();
55 return Object.keys(langs).reduce((acc, key) => {
56 if (!aliasesToRemove.includes(key)) {
57 acc[key as Lang] = langs[key as Lang];
58 }
59 return acc;
60 }, {} as Partial<typeof defaultLanguages>);
61 };
62
63 export const languages = removeAliases(defaultLanguages);
64