UNPKG

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