UNPKG

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