UNPKG

7.03 kBJavaScriptView Raw
1(function () {
2
3 if (typeof Prism === 'undefined' || typeof document === 'undefined') {
4 return;
5 }
6
7 if (!Prism.plugins.toolbar) {
8 console.warn('Show Languages plugin loaded before Toolbar plugin.');
9
10 return;
11 }
12
13 /* eslint-disable */
14
15 // The languages map is built automatically with gulp
16 var Languages = /*languages_placeholder[*/{
17 "none": "Plain text",
18 "plain": "Plain text",
19 "plaintext": "Plain text",
20 "text": "Plain text",
21 "txt": "Plain text",
22 "html": "HTML",
23 "xml": "XML",
24 "svg": "SVG",
25 "mathml": "MathML",
26 "ssml": "SSML",
27 "rss": "RSS",
28 "css": "CSS",
29 "clike": "C-like",
30 "js": "JavaScript",
31 "abap": "ABAP",
32 "abnf": "ABNF",
33 "al": "AL",
34 "antlr4": "ANTLR4",
35 "g4": "ANTLR4",
36 "apacheconf": "Apache Configuration",
37 "apl": "APL",
38 "aql": "AQL",
39 "arff": "ARFF",
40 "asciidoc": "AsciiDoc",
41 "adoc": "AsciiDoc",
42 "aspnet": "ASP.NET (C#)",
43 "asm6502": "6502 Assembly",
44 "autohotkey": "AutoHotkey",
45 "autoit": "AutoIt",
46 "avisynth": "AviSynth",
47 "avs": "AviSynth",
48 "avro-idl": "Avro IDL",
49 "avdl": "Avro IDL",
50 "basic": "BASIC",
51 "bbcode": "BBcode",
52 "bnf": "BNF",
53 "rbnf": "RBNF",
54 "bsl": "BSL (1C:Enterprise)",
55 "oscript": "OneScript",
56 "csharp": "C#",
57 "cs": "C#",
58 "dotnet": "C#",
59 "cpp": "C++",
60 "cfscript": "CFScript",
61 "cfc": "CFScript",
62 "cil": "CIL",
63 "cmake": "CMake",
64 "cobol": "COBOL",
65 "coffee": "CoffeeScript",
66 "conc": "Concurnas",
67 "csp": "Content-Security-Policy",
68 "css-extras": "CSS Extras",
69 "csv": "CSV",
70 "dataweave": "DataWeave",
71 "dax": "DAX",
72 "django": "Django/Jinja2",
73 "jinja2": "Django/Jinja2",
74 "dns-zone-file": "DNS zone file",
75 "dns-zone": "DNS zone file",
76 "dockerfile": "Docker",
77 "dot": "DOT (Graphviz)",
78 "gv": "DOT (Graphviz)",
79 "ebnf": "EBNF",
80 "editorconfig": "EditorConfig",
81 "ejs": "EJS",
82 "etlua": "Embedded Lua templating",
83 "erb": "ERB",
84 "excel-formula": "Excel Formula",
85 "xlsx": "Excel Formula",
86 "xls": "Excel Formula",
87 "fsharp": "F#",
88 "firestore-security-rules": "Firestore security rules",
89 "ftl": "FreeMarker Template Language",
90 "gml": "GameMaker Language",
91 "gamemakerlanguage": "GameMaker Language",
92 "gap": "GAP (CAS)",
93 "gcode": "G-code",
94 "gdscript": "GDScript",
95 "gedcom": "GEDCOM",
96 "glsl": "GLSL",
97 "gn": "GN",
98 "gni": "GN",
99 "graphql": "GraphQL",
100 "hbs": "Handlebars",
101 "hs": "Haskell",
102 "hcl": "HCL",
103 "hlsl": "HLSL",
104 "http": "HTTP",
105 "hpkp": "HTTP Public-Key-Pins",
106 "hsts": "HTTP Strict-Transport-Security",
107 "ichigojam": "IchigoJam",
108 "icu-message-format": "ICU Message Format",
109 "idr": "Idris",
110 "ignore": ".ignore",
111 "gitignore": ".gitignore",
112 "hgignore": ".hgignore",
113 "npmignore": ".npmignore",
114 "inform7": "Inform 7",
115 "javadoc": "JavaDoc",
116 "javadoclike": "JavaDoc-like",
117 "javastacktrace": "Java stack trace",
118 "jq": "JQ",
119 "jsdoc": "JSDoc",
120 "js-extras": "JS Extras",
121 "json": "JSON",
122 "webmanifest": "Web App Manifest",
123 "json5": "JSON5",
124 "jsonp": "JSONP",
125 "jsstacktrace": "JS stack trace",
126 "js-templates": "JS Templates",
127 "kts": "Kotlin Script",
128 "kt": "Kotlin",
129 "kumir": "KuMir (КуМир)",
130 "kum": "KuMir (КуМир)",
131 "latex": "LaTeX",
132 "tex": "TeX",
133 "context": "ConTeXt",
134 "lilypond": "LilyPond",
135 "ly": "LilyPond",
136 "emacs": "Lisp",
137 "elisp": "Lisp",
138 "emacs-lisp": "Lisp",
139 "llvm": "LLVM IR",
140 "log": "Log file",
141 "lolcode": "LOLCODE",
142 "magma": "Magma (CAS)",
143 "md": "Markdown",
144 "markup-templating": "Markup templating",
145 "matlab": "MATLAB",
146 "maxscript": "MAXScript",
147 "mel": "MEL",
148 "mongodb": "MongoDB",
149 "moon": "MoonScript",
150 "n1ql": "N1QL",
151 "n4js": "N4JS",
152 "n4jsd": "N4JS",
153 "nand2tetris-hdl": "Nand To Tetris HDL",
154 "naniscript": "Naninovel Script",
155 "nani": "Naninovel Script",
156 "nasm": "NASM",
157 "neon": "NEON",
158 "nginx": "nginx",
159 "nsis": "NSIS",
160 "objectivec": "Objective-C",
161 "objc": "Objective-C",
162 "ocaml": "OCaml",
163 "opencl": "OpenCL",
164 "openqasm": "OpenQasm",
165 "qasm": "OpenQasm",
166 "parigp": "PARI/GP",
167 "objectpascal": "Object Pascal",
168 "psl": "PATROL Scripting Language",
169 "pcaxis": "PC-Axis",
170 "px": "PC-Axis",
171 "peoplecode": "PeopleCode",
172 "pcode": "PeopleCode",
173 "php": "PHP",
174 "phpdoc": "PHPDoc",
175 "php-extras": "PHP Extras",
176 "plsql": "PL/SQL",
177 "powerquery": "PowerQuery",
178 "pq": "PowerQuery",
179 "mscript": "PowerQuery",
180 "powershell": "PowerShell",
181 "promql": "PromQL",
182 "properties": ".properties",
183 "protobuf": "Protocol Buffers",
184 "purebasic": "PureBasic",
185 "pbfasm": "PureBasic",
186 "purs": "PureScript",
187 "py": "Python",
188 "qsharp": "Q#",
189 "qs": "Q#",
190 "q": "Q (kdb+ database)",
191 "qml": "QML",
192 "rkt": "Racket",
193 "cshtml": "Razor C#",
194 "razor": "Razor C#",
195 "jsx": "React JSX",
196 "tsx": "React TSX",
197 "renpy": "Ren'py",
198 "rpy": "Ren'py",
199 "rest": "reST (reStructuredText)",
200 "robotframework": "Robot Framework",
201 "robot": "Robot Framework",
202 "rb": "Ruby",
203 "sas": "SAS",
204 "sass": "Sass (Sass)",
205 "scss": "Sass (Scss)",
206 "shell-session": "Shell session",
207 "sh-session": "Shell session",
208 "shellsession": "Shell session",
209 "sml": "SML",
210 "smlnj": "SML/NJ",
211 "solidity": "Solidity (Ethereum)",
212 "sol": "Solidity (Ethereum)",
213 "solution-file": "Solution file",
214 "sln": "Solution file",
215 "soy": "Soy (Closure Template)",
216 "sparql": "SPARQL",
217 "rq": "SPARQL",
218 "splunk-spl": "Splunk SPL",
219 "sqf": "SQF: Status Quo Function (Arma 3)",
220 "sql": "SQL",
221 "iecst": "Structured Text (IEC 61131-3)",
222 "systemd": "Systemd configuration file",
223 "t4-templating": "T4 templating",
224 "t4-cs": "T4 Text Templates (C#)",
225 "t4": "T4 Text Templates (C#)",
226 "t4-vb": "T4 Text Templates (VB)",
227 "tap": "TAP",
228 "tt2": "Template Toolkit 2",
229 "toml": "TOML",
230 "trig": "TriG",
231 "ts": "TypeScript",
232 "tsconfig": "TSConfig",
233 "uscript": "UnrealScript",
234 "uc": "UnrealScript",
235 "uri": "URI",
236 "url": "URL",
237 "vbnet": "VB.Net",
238 "vhdl": "VHDL",
239 "vim": "vim",
240 "visual-basic": "Visual Basic",
241 "vba": "VBA",
242 "vb": "Visual Basic",
243 "wasm": "WebAssembly",
244 "wiki": "Wiki markup",
245 "wolfram": "Wolfram language",
246 "nb": "Mathematica Notebook",
247 "wl": "Wolfram language",
248 "xeoracube": "XeoraCube",
249 "xml-doc": "XML doc (.net)",
250 "xojo": "Xojo (REALbasic)",
251 "xquery": "XQuery",
252 "yaml": "YAML",
253 "yml": "YAML",
254 "yang": "YANG"
255 }/*]*/;
256
257 /* eslint-enable */
258
259 Prism.plugins.toolbar.registerButton('show-language', function (env) {
260 var pre = env.element.parentNode;
261 if (!pre || !/pre/i.test(pre.nodeName)) {
262 return;
263 }
264
265 /**
266 * Tries to guess the name of a language given its id.
267 *
268 * @param {string} id The language id.
269 * @returns {string}
270 */
271 function guessTitle(id) {
272 if (!id) {
273 return id;
274 }
275 return (id.substring(0, 1).toUpperCase() + id.substring(1)).replace(/s(?=cript)/, 'S');
276 }
277
278 var language = pre.getAttribute('data-language') || Languages[env.language] || guessTitle(env.language);
279
280 if (!language) {
281 return;
282 }
283 var element = document.createElement('span');
284 element.textContent = language;
285
286 return element;
287 });
288
289}());