1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | var Prism = function () {
|
18 | var uniqueId = 0;
|
19 | var _ = {
|
20 | util: {
|
21 | encode: function (tokens) {
|
22 | if (tokens instanceof Token) {
|
23 | return new Token(tokens.type, _.util.encode(tokens.content), tokens.alias);
|
24 | } else if (_.util.type(tokens) === "Array") {
|
25 | return tokens.map(_.util.encode);
|
26 | } else {
|
27 | return tokens.replace(/&/g, "&").replace(/</g, "<").replace(/\u00a0/g, " ");
|
28 | }
|
29 | },
|
30 | type: function (o) {
|
31 | return Object.prototype.toString.call(o).match(/\[object (\w+)\]/)[1];
|
32 | },
|
33 | objId: function (obj) {
|
34 | if (!obj["__id"]) {
|
35 | Object.defineProperty(obj, "__id", {
|
36 | value: ++uniqueId
|
37 | });
|
38 | }
|
39 |
|
40 | return obj["__id"];
|
41 | },
|
42 |
|
43 | clone: function (o, visited) {
|
44 | var type = _.util.type(o);
|
45 |
|
46 | visited = visited || {};
|
47 |
|
48 | switch (type) {
|
49 | case "Object":
|
50 | if (visited[_.util.objId(o)]) {
|
51 | return visited[_.util.objId(o)];
|
52 | }
|
53 |
|
54 | var clone = {};
|
55 | visited[_.util.objId(o)] = clone;
|
56 |
|
57 | for (var key in o) {
|
58 | if (o.hasOwnProperty(key)) {
|
59 | clone[key] = _.util.clone(o[key], visited);
|
60 | }
|
61 | }
|
62 |
|
63 | return clone;
|
64 |
|
65 | case "Array":
|
66 | if (visited[_.util.objId(o)]) {
|
67 | return visited[_.util.objId(o)];
|
68 | }
|
69 |
|
70 | var clone = [];
|
71 | visited[_.util.objId(o)] = clone;
|
72 | o.forEach(function (v, i) {
|
73 | clone[i] = _.util.clone(v, visited);
|
74 | });
|
75 | return clone;
|
76 | }
|
77 |
|
78 | return o;
|
79 | }
|
80 | },
|
81 | languages: {
|
82 | extend: function (id, redef) {
|
83 | var lang = _.util.clone(_.languages[id]);
|
84 |
|
85 | for (var key in redef) {
|
86 | lang[key] = redef[key];
|
87 | }
|
88 |
|
89 | return lang;
|
90 | },
|
91 |
|
92 | |
93 |
|
94 |
|
95 |
|
96 |
|
97 |
|
98 |
|
99 |
|
100 |
|
101 | insertBefore: function (inside, before, insert, root) {
|
102 | root = root || _.languages;
|
103 | var grammar = root[inside];
|
104 |
|
105 | if (arguments.length == 2) {
|
106 | insert = arguments[1];
|
107 |
|
108 | for (var newToken in insert) {
|
109 | if (insert.hasOwnProperty(newToken)) {
|
110 | grammar[newToken] = insert[newToken];
|
111 | }
|
112 | }
|
113 |
|
114 | return grammar;
|
115 | }
|
116 |
|
117 | var ret = {};
|
118 |
|
119 | for (var token in grammar) {
|
120 | if (grammar.hasOwnProperty(token)) {
|
121 | if (token == before) {
|
122 | for (var newToken in insert) {
|
123 | if (insert.hasOwnProperty(newToken)) {
|
124 | ret[newToken] = insert[newToken];
|
125 | }
|
126 | }
|
127 | }
|
128 |
|
129 | ret[token] = grammar[token];
|
130 | }
|
131 | }
|
132 |
|
133 |
|
134 | _.languages.DFS(_.languages, function (key, value) {
|
135 | if (value === root[inside] && key != inside) {
|
136 | this[key] = ret;
|
137 | }
|
138 | });
|
139 |
|
140 | return root[inside] = ret;
|
141 | },
|
142 |
|
143 | DFS: function (o, callback, type, visited) {
|
144 | visited = visited || {};
|
145 |
|
146 | for (var i in o) {
|
147 | if (o.hasOwnProperty(i)) {
|
148 | callback.call(o, i, o[i], type || i);
|
149 |
|
150 | if (_.util.type(o[i]) === "Object" && !visited[_.util.objId(o[i])]) {
|
151 | visited[_.util.objId(o[i])] = true;
|
152 |
|
153 | _.languages.DFS(o[i], callback, null, visited);
|
154 | } else if (_.util.type(o[i]) === "Array" && !visited[_.util.objId(o[i])]) {
|
155 | visited[_.util.objId(o[i])] = true;
|
156 |
|
157 | _.languages.DFS(o[i], callback, i, visited);
|
158 | }
|
159 | }
|
160 | }
|
161 | }
|
162 | },
|
163 | plugins: {},
|
164 | highlight: function (text, grammar, language) {
|
165 | var env = {
|
166 | code: text,
|
167 | grammar: grammar,
|
168 | language: language
|
169 | };
|
170 | env.tokens = _.tokenize(env.code, env.grammar);
|
171 | return Token.stringify(_.util.encode(env.tokens), env.language);
|
172 | },
|
173 | matchGrammar: function (text, strarr, grammar, index, startPos, oneshot, target) {
|
174 | var Token = _.Token;
|
175 |
|
176 | for (var token in grammar) {
|
177 | if (!grammar.hasOwnProperty(token) || !grammar[token]) {
|
178 | continue;
|
179 | }
|
180 |
|
181 | if (token == target) {
|
182 | return;
|
183 | }
|
184 |
|
185 | var patterns = grammar[token];
|
186 | patterns = _.util.type(patterns) === "Array" ? patterns : [patterns];
|
187 |
|
188 | for (var j = 0; j < patterns.length; ++j) {
|
189 | var pattern = patterns[j],
|
190 | inside = pattern.inside,
|
191 | lookbehind = !!pattern.lookbehind,
|
192 | greedy = !!pattern.greedy,
|
193 | lookbehindLength = 0,
|
194 | alias = pattern.alias;
|
195 |
|
196 | if (greedy && !pattern.pattern.global) {
|
197 |
|
198 | var flags = pattern.pattern.toString().match(/[imuy]*$/)[0];
|
199 | pattern.pattern = RegExp(pattern.pattern.source, flags + "g");
|
200 | }
|
201 |
|
202 | pattern = pattern.pattern || pattern;
|
203 |
|
204 | for (var i = index, pos = startPos; i < strarr.length; pos += strarr[i].length, ++i) {
|
205 | var str = strarr[i];
|
206 |
|
207 | if (strarr.length > text.length) {
|
208 |
|
209 | return;
|
210 | }
|
211 |
|
212 | if (str instanceof Token) {
|
213 | continue;
|
214 | }
|
215 |
|
216 | if (greedy && i != strarr.length - 1) {
|
217 | pattern.lastIndex = pos;
|
218 | var match = pattern.exec(text);
|
219 |
|
220 | if (!match) {
|
221 | break;
|
222 | }
|
223 |
|
224 | var from = match.index + (lookbehind ? match[1].length : 0),
|
225 | to = match.index + match[0].length,
|
226 | k = i,
|
227 | p = pos;
|
228 |
|
229 | for (var len = strarr.length; k < len && (p < to || !strarr[k].type && !strarr[k - 1].greedy); ++k) {
|
230 | p += strarr[k].length;
|
231 |
|
232 | if (from >= p) {
|
233 | ++i;
|
234 | pos = p;
|
235 | }
|
236 | }
|
237 |
|
238 |
|
239 | if (strarr[i] instanceof Token) {
|
240 | continue;
|
241 | }
|
242 |
|
243 |
|
244 | delNum = k - i;
|
245 | str = text.slice(pos, p);
|
246 | match.index -= pos;
|
247 | } else {
|
248 | pattern.lastIndex = 0;
|
249 | var match = pattern.exec(str),
|
250 | delNum = 1;
|
251 | }
|
252 |
|
253 | if (!match) {
|
254 | if (oneshot) {
|
255 | break;
|
256 | }
|
257 |
|
258 | continue;
|
259 | }
|
260 |
|
261 | if (lookbehind) {
|
262 | lookbehindLength = match[1] ? match[1].length : 0;
|
263 | }
|
264 |
|
265 | var from = match.index + lookbehindLength,
|
266 | match = match[0].slice(lookbehindLength),
|
267 | to = from + match.length,
|
268 | before = str.slice(0, from),
|
269 | after = str.slice(to);
|
270 | var args = [i, delNum];
|
271 |
|
272 | if (before) {
|
273 | ++i;
|
274 | pos += before.length;
|
275 | args.push(before);
|
276 | }
|
277 |
|
278 | var wrapped = new Token(token, inside ? _.tokenize(match, inside) : match, alias, match, greedy);
|
279 | args.push(wrapped);
|
280 |
|
281 | if (after) {
|
282 | args.push(after);
|
283 | }
|
284 |
|
285 | Array.prototype.splice.apply(strarr, args);
|
286 |
|
287 | if (delNum != 1) {
|
288 | _.matchGrammar(text, strarr, grammar, i, pos, true, token);
|
289 | }
|
290 |
|
291 | if (oneshot) {
|
292 | break;
|
293 | }
|
294 | }
|
295 | }
|
296 | }
|
297 | },
|
298 | hooks: {
|
299 | add: function () {}
|
300 | },
|
301 | tokenize: function (text, grammar, language) {
|
302 | var strarr = [text];
|
303 | var rest = grammar.rest;
|
304 |
|
305 | if (rest) {
|
306 | for (var token in rest) {
|
307 | grammar[token] = rest[token];
|
308 | }
|
309 |
|
310 | delete grammar.rest;
|
311 | }
|
312 |
|
313 | _.matchGrammar(text, strarr, grammar, 0, 0, false);
|
314 |
|
315 | return strarr;
|
316 | }
|
317 | };
|
318 |
|
319 | var Token = _.Token = function (type, content, alias, matchedStr, greedy) {
|
320 | this.type = type;
|
321 | this.content = content;
|
322 | this.alias = alias;
|
323 |
|
324 | this.length = (matchedStr || "").length | 0;
|
325 | this.greedy = !!greedy;
|
326 | };
|
327 |
|
328 | Token.stringify = function (o, language, parent) {
|
329 | if (typeof o == "string") {
|
330 | return o;
|
331 | }
|
332 |
|
333 | if (_.util.type(o) === "Array") {
|
334 | return o.map(function (element) {
|
335 | return Token.stringify(element, language, o);
|
336 | }).join("");
|
337 | }
|
338 |
|
339 | var env = {
|
340 | type: o.type,
|
341 | content: Token.stringify(o.content, language, parent),
|
342 | tag: "span",
|
343 | classes: ["token", o.type],
|
344 | attributes: {},
|
345 | language: language,
|
346 | parent: parent
|
347 | };
|
348 |
|
349 | if (o.alias) {
|
350 | var aliases = _.util.type(o.alias) === "Array" ? o.alias : [o.alias];
|
351 | Array.prototype.push.apply(env.classes, aliases);
|
352 | }
|
353 |
|
354 | var attributes = Object.keys(env.attributes).map(function (name) {
|
355 | return name + '="' + (env.attributes[name] || "").replace(/"/g, """) + '"';
|
356 | }).join(" ");
|
357 | return "<" + env.tag + ' class="' + env.classes.join(" ") + '"' + (attributes ? " " + attributes : "") + ">" + env.content + "</" + env.tag + ">";
|
358 | };
|
359 |
|
360 | return _;
|
361 | }();
|
362 |
|
363 |
|
364 |
|
365 |
|
366 |
|
367 | Prism.languages.markup = {
|
368 | 'comment': /<!--[\s\S]*?-->/,
|
369 | 'prolog': /<\?[\s\S]+?\?>/,
|
370 | 'doctype': /<!DOCTYPE[\s\S]+?>/i,
|
371 | 'cdata': /<!\[CDATA\[[\s\S]*?]]>/i,
|
372 | 'tag': {
|
373 | pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/i,
|
374 | greedy: true,
|
375 | inside: {
|
376 | 'tag': {
|
377 | pattern: /^<\/?[^\s>\/]+/i,
|
378 | inside: {
|
379 | 'punctuation': /^<\/?/,
|
380 | 'namespace': /^[^\s>\/:]+:/
|
381 | }
|
382 | },
|
383 | 'attr-value': {
|
384 | pattern: /=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/i,
|
385 | inside: {
|
386 | 'punctuation': [/^=/, {
|
387 | pattern: /^(\s*)["']|["']$/,
|
388 | lookbehind: true
|
389 | }]
|
390 | }
|
391 | },
|
392 | 'punctuation': /\/?>/,
|
393 | 'attr-name': {
|
394 | pattern: /[^\s>\/]+/,
|
395 | inside: {
|
396 | 'namespace': /^[^\s>\/:]+:/
|
397 | }
|
398 | }
|
399 | }
|
400 | },
|
401 | 'entity': /&#?[\da-z]{1,8};/i
|
402 | };
|
403 | Prism.languages.markup['tag'].inside['attr-value'].inside['entity'] = Prism.languages.markup['entity'];
|
404 |
|
405 | Prism.hooks.add('wrap', function (env) {
|
406 | if (env.type === 'entity') {
|
407 | env.attributes['title'] = env.content.replace(/&/, '&');
|
408 | }
|
409 | });
|
410 | Object.defineProperty(Prism.languages.markup.tag, 'addInlined', {
|
411 | |
412 |
|
413 |
|
414 |
|
415 |
|
416 |
|
417 |
|
418 |
|
419 |
|
420 |
|
421 |
|
422 | value: function addInlined(tagName, lang) {
|
423 | var includedCdataInside = {};
|
424 | includedCdataInside['language-' + lang] = {
|
425 | pattern: /(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,
|
426 | lookbehind: true,
|
427 | inside: Prism.languages[lang]
|
428 | };
|
429 | includedCdataInside['cdata'] = /^<!\[CDATA\[|\]\]>$/i;
|
430 | var inside = {
|
431 | 'included-cdata': {
|
432 | pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
|
433 | inside: includedCdataInside
|
434 | }
|
435 | };
|
436 | inside['language-' + lang] = {
|
437 | pattern: /[\s\S]+/,
|
438 | inside: Prism.languages[lang]
|
439 | };
|
440 | var def = {};
|
441 | def[tagName] = {
|
442 | pattern: RegExp(/(<__[\s\S]*?>)(?:<!\[CDATA\[[\s\S]*?\]\]>\s*|[\s\S])*?(?=<\/__>)/.source.replace(/__/g, tagName), 'i'),
|
443 | lookbehind: true,
|
444 | greedy: true,
|
445 | inside: inside
|
446 | };
|
447 | Prism.languages.insertBefore('markup', 'cdata', def);
|
448 | }
|
449 | });
|
450 | Prism.languages.xml = Prism.languages.extend('markup', {});
|
451 | Prism.languages.html = Prism.languages.markup;
|
452 | Prism.languages.mathml = Prism.languages.markup;
|
453 | Prism.languages.svg = Prism.languages.markup;
|
454 |
|
455 |
|
456 | (function (Prism) {
|
457 |
|
458 |
|
459 |
|
460 |
|
461 | var envVars = '\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b';
|
462 | var insideString = {
|
463 | 'environment': {
|
464 | pattern: RegExp("\\$" + envVars),
|
465 | alias: 'constant'
|
466 | },
|
467 | 'variable': [
|
468 | {
|
469 | pattern: /\$?\(\([\s\S]+?\)\)/,
|
470 | greedy: true,
|
471 | inside: {
|
472 |
|
473 | 'variable': [{
|
474 | pattern: /(^\$\(\([\s\S]+)\)\)/,
|
475 | lookbehind: true
|
476 | }, /^\$\(\(/],
|
477 | 'number': /\b0x[\dA-Fa-f]+\b|(?:\b\d+\.?\d*|\B\.\d+)(?:[Ee]-?\d+)?/,
|
478 |
|
479 | 'operator': /--?|-=|\+\+?|\+=|!=?|~|\*\*?|\*=|\/=?|%=?|<<=?|>>=?|<=?|>=?|==?|&&?|&=|\^=?|\|\|?|\|=|\?|:/,
|
480 |
|
481 | 'punctuation': /\(\(?|\)\)?|,|;/
|
482 | }
|
483 | },
|
484 | {
|
485 | pattern: /\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,
|
486 | greedy: true,
|
487 | inside: {
|
488 | 'variable': /^\$\(|^`|\)$|`$/
|
489 | }
|
490 | },
|
491 | {
|
492 | pattern: /\$\{[^}]+\}/,
|
493 | greedy: true,
|
494 | inside: {
|
495 | 'operator': /:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,
|
496 | 'punctuation': /[\[\]]/,
|
497 | 'environment': {
|
498 | pattern: RegExp("(\\{)" + envVars),
|
499 | lookbehind: true,
|
500 | alias: 'constant'
|
501 | }
|
502 | }
|
503 | }, /\$(?:\w+|[#?*!@$])/],
|
504 |
|
505 | 'entity': /\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|x[0-9a-fA-F]{1,2}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8})/
|
506 | };
|
507 | Prism.languages.bash = {
|
508 | 'shebang': {
|
509 | pattern: /^#!\s*\/.*/,
|
510 | alias: 'important'
|
511 | },
|
512 | 'comment': {
|
513 | pattern: /(^|[^"{\\$])#.*/,
|
514 | lookbehind: true
|
515 | },
|
516 | 'function-name': [
|
517 |
|
518 |
|
519 |
|
520 | {
|
521 |
|
522 | pattern: /(\bfunction\s+)\w+(?=(?:\s*\(?:\s*\))?\s*\{)/,
|
523 | lookbehind: true,
|
524 | alias: 'function'
|
525 | }, {
|
526 |
|
527 | pattern: /\b\w+(?=\s*\(\s*\)\s*\{)/,
|
528 | alias: 'function'
|
529 | }],
|
530 |
|
531 | 'for-or-select': {
|
532 | pattern: /(\b(?:for|select)\s+)\w+(?=\s+in\s)/,
|
533 | alias: 'variable',
|
534 | lookbehind: true
|
535 | },
|
536 |
|
537 |
|
538 | 'assign-left': {
|
539 | pattern: /(^|[\s;|&]|[<>]\()\w+(?=\+?=)/,
|
540 | inside: {
|
541 | 'environment': {
|
542 | pattern: RegExp("(^|[\\s;|&]|[<>]\\()" + envVars),
|
543 | lookbehind: true,
|
544 | alias: 'constant'
|
545 | }
|
546 | },
|
547 | alias: 'variable',
|
548 | lookbehind: true
|
549 | },
|
550 | 'string': [
|
551 | {
|
552 | pattern: /((?:^|[^<])<<-?\s*)(\w+?)\s*(?:\r?\n|\r)(?:[\s\S])*?(?:\r?\n|\r)\2/,
|
553 | lookbehind: true,
|
554 | greedy: true,
|
555 | inside: insideString
|
556 | },
|
557 |
|
558 | {
|
559 | pattern: /((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s*(?:\r?\n|\r)(?:[\s\S])*?(?:\r?\n|\r)\3/,
|
560 | lookbehind: true,
|
561 | greedy: true
|
562 | },
|
563 | {
|
564 | pattern: /(["'])(?:\\[\s\S]|\$\([^)]+\)|`[^`]+`|(?!\1)[^\\])*\1/,
|
565 | greedy: true,
|
566 | inside: insideString
|
567 | }],
|
568 | 'environment': {
|
569 | pattern: RegExp("\\$?" + envVars),
|
570 | alias: 'constant'
|
571 | },
|
572 | 'variable': insideString.variable,
|
573 | 'function': {
|
574 | pattern: /(^|[\s;|&]|[<>]\()(?:add|apropos|apt|aptitude|apt-cache|apt-get|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,
|
575 | lookbehind: true
|
576 | },
|
577 | 'keyword': {
|
578 | pattern: /(^|[\s;|&]|[<>]\()(?:if|then|else|elif|fi|for|while|in|case|esac|function|select|do|done|until)(?=$|[)\s;|&])/,
|
579 | lookbehind: true
|
580 | },
|
581 |
|
582 | 'builtin': {
|
583 | pattern: /(^|[\s;|&]|[<>]\()(?:\.|:|break|cd|continue|eval|exec|exit|export|getopts|hash|pwd|readonly|return|shift|test|times|trap|umask|unset|alias|bind|builtin|caller|command|declare|echo|enable|help|let|local|logout|mapfile|printf|read|readarray|source|type|typeset|ulimit|unalias|set|shopt)(?=$|[)\s;|&])/,
|
584 | lookbehind: true,
|
585 |
|
586 | alias: 'class-name'
|
587 | },
|
588 | 'boolean': {
|
589 | pattern: /(^|[\s;|&]|[<>]\()(?:true|false)(?=$|[)\s;|&])/,
|
590 | lookbehind: true
|
591 | },
|
592 | 'file-descriptor': {
|
593 | pattern: /\B&\d\b/,
|
594 | alias: 'important'
|
595 | },
|
596 | 'operator': {
|
597 |
|
598 | pattern: /\d?<>|>\||\+=|==?|!=?|=~|<<[<-]?|[&\d]?>>|\d?[<>]&?|&[>&]?|\|[&|]?|<=?|>=?/,
|
599 | inside: {
|
600 | 'file-descriptor': {
|
601 | pattern: /^\d/,
|
602 | alias: 'important'
|
603 | }
|
604 | }
|
605 | },
|
606 | 'punctuation': /\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,
|
607 | 'number': {
|
608 | pattern: /(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,
|
609 | lookbehind: true
|
610 | }
|
611 | };
|
612 |
|
613 |
|
614 | var toBeCopied = ['comment', 'function-name', 'for-or-select', 'assign-left', 'string', 'environment', 'function', 'keyword', 'builtin', 'boolean', 'file-descriptor', 'operator', 'punctuation', 'number'];
|
615 | var inside = insideString.variable[1].inside;
|
616 |
|
617 | for (var i = 0; i < toBeCopied.length; i++) {
|
618 | inside[toBeCopied[i]] = Prism.languages.bash[toBeCopied[i]];
|
619 | }
|
620 |
|
621 | Prism.languages.shell = Prism.languages.bash;
|
622 | })(Prism);
|
623 |
|
624 |
|
625 |
|
626 | Prism.languages.clike = {
|
627 | 'comment': [{
|
628 | pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
|
629 | lookbehind: true
|
630 | }, {
|
631 | pattern: /(^|[^\\:])\/\/.*/,
|
632 | lookbehind: true,
|
633 | greedy: true
|
634 | }],
|
635 | 'string': {
|
636 | pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
|
637 | greedy: true
|
638 | },
|
639 | 'class-name': {
|
640 | pattern: /((?:\b(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[\w.\\]+/i,
|
641 | lookbehind: true,
|
642 | inside: {
|
643 | punctuation: /[.\\]/
|
644 | }
|
645 | },
|
646 | 'keyword': /\b(?:if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,
|
647 | 'boolean': /\b(?:true|false)\b/,
|
648 | 'function': /\w+(?=\()/,
|
649 | 'number': /\b0x[\da-f]+\b|(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?/i,
|
650 | 'operator': /--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*|\/|~|\^|%/,
|
651 | 'punctuation': /[{}[\];(),.:]/
|
652 | };
|
653 |
|
654 |
|
655 | Prism.languages.c = Prism.languages.extend('clike', {
|
656 | 'class-name': {
|
657 | pattern: /(\b(?:enum|struct)\s+)\w+/,
|
658 | lookbehind: true
|
659 | },
|
660 | 'keyword': /\b(?:_Alignas|_Alignof|_Atomic|_Bool|_Complex|_Generic|_Imaginary|_Noreturn|_Static_assert|_Thread_local|asm|typeof|inline|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|union|unsigned|void|volatile|while)\b/,
|
661 | 'operator': />>=?|<<=?|->|([-+&|:])\1|[?:~]|[-+*/%&|^!=<>]=?/,
|
662 | 'number': /(?:\b0x(?:[\da-f]+\.?[\da-f]*|\.[\da-f]+)(?:p[+-]?\d+)?|(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?)[ful]*/i
|
663 | });
|
664 | Prism.languages.insertBefore('c', 'string', {
|
665 | 'macro': {
|
666 |
|
667 |
|
668 | pattern: /(^\s*)#\s*[a-z]+(?:[^\r\n\\]|\\(?:\r\n|[\s\S]))*/im,
|
669 | lookbehind: true,
|
670 | alias: 'property',
|
671 | inside: {
|
672 |
|
673 | 'string': {
|
674 | pattern: /(#\s*include\s*)(?:<.+?>|("|')(?:\\?.)+?\2)/,
|
675 | lookbehind: true
|
676 | },
|
677 |
|
678 | 'directive': {
|
679 | pattern: /(#\s*)\b(?:define|defined|elif|else|endif|error|ifdef|ifndef|if|import|include|line|pragma|undef|using)\b/,
|
680 | lookbehind: true,
|
681 | alias: 'keyword'
|
682 | }
|
683 | }
|
684 | },
|
685 |
|
686 | 'constant': /\b(?:__FILE__|__LINE__|__DATE__|__TIME__|__TIMESTAMP__|__func__|EOF|NULL|SEEK_CUR|SEEK_END|SEEK_SET|stdin|stdout|stderr)\b/
|
687 | });
|
688 | delete Prism.languages.c['boolean'];
|
689 |
|
690 |
|
691 | Prism.languages.cpp = Prism.languages.extend('c', {
|
692 | 'class-name': {
|
693 | pattern: /(\b(?:class|enum|struct)\s+)\w+/,
|
694 | lookbehind: true
|
695 | },
|
696 | 'keyword': /\b(?:alignas|alignof|asm|auto|bool|break|case|catch|char|char16_t|char32_t|class|compl|const|constexpr|const_cast|continue|decltype|default|delete|do|double|dynamic_cast|else|enum|explicit|export|extern|float|for|friend|goto|if|inline|int|int8_t|int16_t|int32_t|int64_t|uint8_t|uint16_t|uint32_t|uint64_t|long|mutable|namespace|new|noexcept|nullptr|operator|private|protected|public|register|reinterpret_cast|return|short|signed|sizeof|static|static_assert|static_cast|struct|switch|template|this|thread_local|throw|try|typedef|typeid|typename|union|unsigned|using|virtual|void|volatile|wchar_t|while)\b/,
|
697 | 'number': {
|
698 | pattern: /(?:\b0b[01']+|\b0x(?:[\da-f']+\.?[\da-f']*|\.[\da-f']+)(?:p[+-]?[\d']+)?|(?:\b[\d']+\.?[\d']*|\B\.[\d']+)(?:e[+-]?[\d']+)?)[ful]*/i,
|
699 | greedy: true
|
700 | },
|
701 | 'operator': />>=?|<<=?|->|([-+&|:])\1|[?:~]|[-+*/%&|^!=<>]=?|\b(?:and|and_eq|bitand|bitor|not|not_eq|or|or_eq|xor|xor_eq)\b/,
|
702 | 'boolean': /\b(?:true|false)\b/
|
703 | });
|
704 | Prism.languages.insertBefore('cpp', 'string', {
|
705 | 'raw-string': {
|
706 | pattern: /R"([^()\\ ]{0,16})\([\s\S]*?\)\1"/,
|
707 | alias: 'string',
|
708 | greedy: true
|
709 | }
|
710 | });
|
711 |
|
712 |
|
713 | (function (Prism) {
|
714 | var string = /("|')(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/;
|
715 | Prism.languages.css = {
|
716 | 'comment': /\/\*[\s\S]*?\*\//,
|
717 | 'atrule': {
|
718 | pattern: /@[\w-]+[\s\S]*?(?:;|(?=\s*\{))/,
|
719 | inside: {
|
720 | 'rule': /@[\w-]+/
|
721 |
|
722 | }
|
723 | },
|
724 | 'url': {
|
725 | pattern: RegExp('url\\((?:' + string.source + '|[^\n\r()]*)\\)', 'i'),
|
726 | inside: {
|
727 | 'function': /^url/i,
|
728 | 'punctuation': /^\(|\)$/
|
729 | }
|
730 | },
|
731 | 'selector': RegExp('[^{}\\s](?:[^{};"\']|' + string.source + ')*?(?=\\s*\\{)'),
|
732 | 'string': {
|
733 | pattern: string,
|
734 | greedy: true
|
735 | },
|
736 | 'property': /[-_a-z\xA0-\uFFFF][-\w\xA0-\uFFFF]*(?=\s*:)/i,
|
737 | 'important': /!important\b/i,
|
738 | 'function': /[-a-z0-9]+(?=\()/i,
|
739 | 'punctuation': /[(){};:,]/
|
740 | };
|
741 | Prism.languages.css['atrule'].inside.rest = Prism.languages.css;
|
742 | var markup = Prism.languages.markup;
|
743 |
|
744 | if (markup) {
|
745 | markup.tag.addInlined('style', 'css');
|
746 | Prism.languages.insertBefore('inside', 'attr-value', {
|
747 | 'style-attr': {
|
748 | pattern: /\s*style=("|')(?:\\[\s\S]|(?!\1)[^\\])*\1/i,
|
749 | inside: {
|
750 | 'attr-name': {
|
751 | pattern: /^\s*style/i,
|
752 | inside: markup.tag.inside
|
753 | },
|
754 | 'punctuation': /^\s*=\s*['"]|['"]\s*$/,
|
755 | 'attr-value': {
|
756 | pattern: /.+/i,
|
757 | inside: Prism.languages.css
|
758 | }
|
759 | },
|
760 | alias: 'language-css'
|
761 | }
|
762 | }, markup.tag);
|
763 | }
|
764 | })(Prism);
|
765 |
|
766 |
|
767 |
|
768 | Prism.languages.css.selector = {
|
769 | pattern: Prism.languages.css.selector,
|
770 | inside: {
|
771 | 'pseudo-element': /:(?:after|before|first-letter|first-line|selection)|::[-\w]+/,
|
772 | 'pseudo-class': /:[-\w]+/,
|
773 | 'class': /\.[-:.\w]+/,
|
774 | 'id': /#[-:.\w]+/,
|
775 | 'attribute': {
|
776 | pattern: /\[(?:[^[\]"']|("|')(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1)*\]/,
|
777 | greedy: true,
|
778 | inside: {
|
779 | 'punctuation': /^\[|\]$/,
|
780 | 'case-sensitivity': {
|
781 | pattern: /(\s)[si]$/i,
|
782 | lookbehind: true,
|
783 | alias: 'keyword'
|
784 | },
|
785 | 'namespace': {
|
786 | pattern: /^(\s*)[-*\w\xA0-\uFFFF]*\|(?!=)/,
|
787 | lookbehind: true,
|
788 | inside: {
|
789 | 'punctuation': /\|$/
|
790 | }
|
791 | },
|
792 | 'attribute': {
|
793 | pattern: /^(\s*)[-\w\xA0-\uFFFF]+/,
|
794 | lookbehind: true
|
795 | },
|
796 | 'value': [/("|')(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/, {
|
797 | pattern: /(=\s*)[-\w\xA0-\uFFFF]+(?=\s*$)/,
|
798 | lookbehind: true
|
799 | }],
|
800 | 'operator': /[|~*^$]?=/
|
801 | }
|
802 | },
|
803 | 'n-th': [{
|
804 | pattern: /(\(\s*)[+-]?\d*[\dn](?:\s*[+-]\s*\d+)?(?=\s*\))/,
|
805 | lookbehind: true,
|
806 | inside: {
|
807 | 'number': /[\dn]+/,
|
808 | 'operator': /[+-]/
|
809 | }
|
810 | }, {
|
811 | pattern: /(\(\s*)(?:even|odd)(?=\s*\))/i,
|
812 | lookbehind: true
|
813 | }],
|
814 | 'punctuation': /[()]/
|
815 | }
|
816 | };
|
817 | Prism.languages.insertBefore('css', 'property', {
|
818 | 'variable': {
|
819 | pattern: /(^|[^-\w\xA0-\uFFFF])--[-_a-z\xA0-\uFFFF][-\w\xA0-\uFFFF]*/i,
|
820 | lookbehind: true
|
821 | }
|
822 | });
|
823 | Prism.languages.insertBefore('css', 'function', {
|
824 | 'operator': {
|
825 | pattern: /(\s)[+\-*\/](?=\s)/,
|
826 | lookbehind: true
|
827 | },
|
828 | 'hexcode': /#[\da-f]{3,8}/i,
|
829 | 'entity': /\\[\da-f]{1,8}/i,
|
830 | 'unit': {
|
831 | pattern: /(\d)(?:%|[a-z]+)/,
|
832 | lookbehind: true
|
833 | },
|
834 | 'number': /-?[\d.]+/
|
835 | });
|
836 |
|
837 |
|
838 | Prism.languages.javascript = Prism.languages.extend('clike', {
|
839 | 'class-name': [Prism.languages.clike['class-name'], {
|
840 | pattern: /(^|[^$\w\xA0-\uFFFF])[_$A-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\.(?:prototype|constructor))/,
|
841 | lookbehind: true
|
842 | }],
|
843 | 'keyword': [{
|
844 | pattern: /((?:^|})\s*)(?:catch|finally)\b/,
|
845 | lookbehind: true
|
846 | }, {
|
847 | pattern: /(^|[^.])\b(?:as|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,
|
848 | lookbehind: true
|
849 | }],
|
850 | 'number': /\b(?:(?:0[xX](?:[\dA-Fa-f](?:_[\dA-Fa-f])?)+|0[bB](?:[01](?:_[01])?)+|0[oO](?:[0-7](?:_[0-7])?)+)n?|(?:\d(?:_\d)?)+n|NaN|Infinity)\b|(?:\b(?:\d(?:_\d)?)+\.?(?:\d(?:_\d)?)*|\B\.(?:\d(?:_\d)?)+)(?:[Ee][+-]?(?:\d(?:_\d)?)+)?/,
|
851 |
|
852 | 'function': /#?[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,
|
853 | 'operator': /-[-=]?|\+[+=]?|!=?=?|<<?=?|>>?>?=?|=(?:==?|>)?|&[&=]?|\|[|=]?|\*\*?=?|\/=?|~|\^=?|%=?|\?|\.{3}/
|
854 | });
|
855 | Prism.languages.javascript['class-name'][0].pattern = /(\b(?:class|interface|extends|implements|instanceof|new)\s+)[\w.\\]+/;
|
856 | Prism.languages.insertBefore('javascript', 'keyword', {
|
857 | 'regex': {
|
858 | pattern: /((?:^|[^$\w\xA0-\uFFFF."'\])\s])\s*)\/(\[(?:[^\]\\\r\n]|\\.)*]|\\.|[^/\\\[\r\n])+\/[gimyus]{0,6}(?=\s*($|[\r\n,.;})\]]))/,
|
859 | lookbehind: true,
|
860 | greedy: true
|
861 | },
|
862 |
|
863 | 'function-variable': {
|
864 | pattern: /#?[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)\s*=>))/,
|
865 | alias: 'function'
|
866 | },
|
867 | 'parameter': [{
|
868 | pattern: /(function(?:\s+[_$A-Za-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)?\s*\(\s*)(?!\s)(?:[^()]|\([^()]*\))+?(?=\s*\))/,
|
869 | lookbehind: true,
|
870 | inside: Prism.languages.javascript
|
871 | }, {
|
872 | pattern: /[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*=>)/i,
|
873 | inside: Prism.languages.javascript
|
874 | }, {
|
875 | pattern: /(\(\s*)(?!\s)(?:[^()]|\([^()]*\))+?(?=\s*\)\s*=>)/,
|
876 | lookbehind: true,
|
877 | inside: Prism.languages.javascript
|
878 | }, {
|
879 | pattern: /((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:[_$A-Za-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*\s*)\(\s*)(?!\s)(?:[^()]|\([^()]*\))+?(?=\s*\)\s*\{)/,
|
880 | lookbehind: true,
|
881 | inside: Prism.languages.javascript
|
882 | }],
|
883 | 'constant': /\b[A-Z](?:[A-Z_]|\dx?)*\b/
|
884 | });
|
885 | Prism.languages.insertBefore('javascript', 'string', {
|
886 | 'template-string': {
|
887 | pattern: /`(?:\\[\s\S]|\${(?:[^{}]|{(?:[^{}]|{[^}]*})*})+}|(?!\${)[^\\`])*`/,
|
888 | greedy: true,
|
889 | inside: {
|
890 | 'template-punctuation': {
|
891 | pattern: /^`|`$/,
|
892 | alias: 'string'
|
893 | },
|
894 | 'interpolation': {
|
895 | pattern: /((?:^|[^\\])(?:\\{2})*)\${(?:[^{}]|{(?:[^{}]|{[^}]*})*})+}/,
|
896 | lookbehind: true,
|
897 | inside: {
|
898 | 'interpolation-punctuation': {
|
899 | pattern: /^\${|}$/,
|
900 | alias: 'punctuation'
|
901 | },
|
902 | rest: Prism.languages.javascript
|
903 | }
|
904 | },
|
905 | 'string': /[\s\S]+/
|
906 | }
|
907 | }
|
908 | });
|
909 |
|
910 | if (Prism.languages.markup) {
|
911 | Prism.languages.markup.tag.addInlined('script', 'javascript');
|
912 | }
|
913 |
|
914 | Prism.languages.js = Prism.languages.javascript;
|
915 |
|
916 |
|
917 | (function (Prism) {
|
918 | var javascript = Prism.util.clone(Prism.languages.javascript);
|
919 | Prism.languages.jsx = Prism.languages.extend('markup', javascript);
|
920 | Prism.languages.jsx.tag.pattern = /<\/?(?:[\w.:-]+\s*(?:\s+(?:[\w.:-]+(?:=(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s{'">=]+|\{(?:\{(?:\{[^}]*\}|[^{}])*\}|[^{}])+\}))?|\{\.{3}[a-z_$][\w$]*(?:\.[a-z_$][\w$]*)*\}))*\s*\/?)?>/i;
|
921 | Prism.languages.jsx.tag.inside['tag'].pattern = /^<\/?[^\s>\/]*/i;
|
922 | Prism.languages.jsx.tag.inside['attr-value'].pattern = /=(?!\{)(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s'">]+)/i;
|
923 | Prism.languages.jsx.tag.inside['tag'].inside['class-name'] = /^[A-Z]\w*(?:\.[A-Z]\w*)*$/;
|
924 | Prism.languages.insertBefore('inside', 'attr-name', {
|
925 | 'spread': {
|
926 | pattern: /\{\.{3}[a-z_$][\w$]*(?:\.[a-z_$][\w$]*)*\}/,
|
927 | inside: {
|
928 | 'punctuation': /\.{3}|[{}.]/,
|
929 | 'attr-value': /\w+/
|
930 | }
|
931 | }
|
932 | }, Prism.languages.jsx.tag);
|
933 | Prism.languages.insertBefore('inside', 'attr-value', {
|
934 | 'script': {
|
935 |
|
936 | pattern: /=(\{(?:\{(?:\{[^}]*\}|[^}])*\}|[^}])+\})/i,
|
937 | inside: {
|
938 | 'script-punctuation': {
|
939 | pattern: /^=(?={)/,
|
940 | alias: 'punctuation'
|
941 | },
|
942 | rest: Prism.languages.jsx
|
943 | },
|
944 | 'alias': 'language-javascript'
|
945 | }
|
946 | }, Prism.languages.jsx.tag);
|
947 |
|
948 | var stringifyToken = function (token) {
|
949 | if (!token) {
|
950 | return '';
|
951 | }
|
952 |
|
953 | if (typeof token === 'string') {
|
954 | return token;
|
955 | }
|
956 |
|
957 | if (typeof token.content === 'string') {
|
958 | return token.content;
|
959 | }
|
960 |
|
961 | return token.content.map(stringifyToken).join('');
|
962 | };
|
963 |
|
964 | var walkTokens = function (tokens) {
|
965 | var openedTags = [];
|
966 |
|
967 | for (var i = 0; i < tokens.length; i++) {
|
968 | var token = tokens[i];
|
969 | var notTagNorBrace = false;
|
970 |
|
971 | if (typeof token !== 'string') {
|
972 | if (token.type === 'tag' && token.content[0] && token.content[0].type === 'tag') {
|
973 |
|
974 | if (token.content[0].content[0].content === '</') {
|
975 |
|
976 | if (openedTags.length > 0 && openedTags[openedTags.length - 1].tagName === stringifyToken(token.content[0].content[1])) {
|
977 |
|
978 | openedTags.pop();
|
979 | }
|
980 | } else {
|
981 | if (token.content[token.content.length - 1].content === '/>') ; else {
|
982 |
|
983 | openedTags.push({
|
984 | tagName: stringifyToken(token.content[0].content[1]),
|
985 | openedBraces: 0
|
986 | });
|
987 | }
|
988 | }
|
989 | } else if (openedTags.length > 0 && token.type === 'punctuation' && token.content === '{') {
|
990 |
|
991 | openedTags[openedTags.length - 1].openedBraces++;
|
992 | } else if (openedTags.length > 0 && openedTags[openedTags.length - 1].openedBraces > 0 && token.type === 'punctuation' && token.content === '}') {
|
993 |
|
994 | openedTags[openedTags.length - 1].openedBraces--;
|
995 | } else {
|
996 | notTagNorBrace = true;
|
997 | }
|
998 | }
|
999 |
|
1000 | if (notTagNorBrace || typeof token === 'string') {
|
1001 | if (openedTags.length > 0 && openedTags[openedTags.length - 1].openedBraces === 0) {
|
1002 |
|
1003 |
|
1004 | var plainText = stringifyToken(token);
|
1005 |
|
1006 | if (i < tokens.length - 1 && (typeof tokens[i + 1] === 'string' || tokens[i + 1].type === 'plain-text')) {
|
1007 | plainText += stringifyToken(tokens[i + 1]);
|
1008 | tokens.splice(i + 1, 1);
|
1009 | }
|
1010 |
|
1011 | if (i > 0 && (typeof tokens[i - 1] === 'string' || tokens[i - 1].type === 'plain-text')) {
|
1012 | plainText = stringifyToken(tokens[i - 1]) + plainText;
|
1013 | tokens.splice(i - 1, 1);
|
1014 | i--;
|
1015 | }
|
1016 |
|
1017 | tokens[i] = new Prism.Token('plain-text', plainText, null, plainText);
|
1018 | }
|
1019 | }
|
1020 |
|
1021 | if (token.content && typeof token.content !== 'string') {
|
1022 | walkTokens(token.content);
|
1023 | }
|
1024 | }
|
1025 | };
|
1026 |
|
1027 | Prism.hooks.add('after-tokenize', function (env) {
|
1028 | if (env.language !== 'jsx' && env.language !== 'tsx') {
|
1029 | return;
|
1030 | }
|
1031 |
|
1032 | walkTokens(env.tokens);
|
1033 | });
|
1034 | })(Prism);
|
1035 |
|
1036 |
|
1037 |
|
1038 | (function (Prism) {
|
1039 | var javaDocLike = Prism.languages.javadoclike = {
|
1040 | 'parameter': {
|
1041 | pattern: /(^\s*(?:\/{3}|\*|\/\*\*)\s*@(?:param|arg|arguments)\s+)\w+/m,
|
1042 | lookbehind: true
|
1043 | },
|
1044 | 'keyword': {
|
1045 |
|
1046 |
|
1047 | pattern: /(^\s*(?:\/{3}|\*|\/\*\*)\s*|\{)@[a-z][a-zA-Z-]+\b/m,
|
1048 | lookbehind: true
|
1049 | },
|
1050 | 'punctuation': /[{}]/
|
1051 | };
|
1052 | |
1053 |
|
1054 |
|
1055 |
|
1056 |
|
1057 |
|
1058 |
|
1059 | function docCommentSupport(lang, callback) {
|
1060 | var tokenName = 'doc-comment';
|
1061 | var grammar = Prism.languages[lang];
|
1062 |
|
1063 | if (!grammar) {
|
1064 | return;
|
1065 | }
|
1066 |
|
1067 | var token = grammar[tokenName];
|
1068 |
|
1069 | if (!token) {
|
1070 |
|
1071 | var definition = {};
|
1072 | definition[tokenName] = {
|
1073 | pattern: /(^|[^\\])\/\*\*[^/][\s\S]*?(?:\*\/|$)/,
|
1074 | alias: 'comment'
|
1075 | };
|
1076 | grammar = Prism.languages.insertBefore(lang, 'comment', definition);
|
1077 | token = grammar[tokenName];
|
1078 | }
|
1079 |
|
1080 | if (token instanceof RegExp) {
|
1081 |
|
1082 | token = grammar[tokenName] = {
|
1083 | pattern: token
|
1084 | };
|
1085 | }
|
1086 |
|
1087 | if (Array.isArray(token)) {
|
1088 | for (var i = 0, l = token.length; i < l; i++) {
|
1089 | if (token[i] instanceof RegExp) {
|
1090 | token[i] = {
|
1091 | pattern: token[i]
|
1092 | };
|
1093 | }
|
1094 |
|
1095 | callback(token[i]);
|
1096 | }
|
1097 | } else {
|
1098 | callback(token);
|
1099 | }
|
1100 | }
|
1101 | |
1102 |
|
1103 |
|
1104 |
|
1105 |
|
1106 |
|
1107 |
|
1108 |
|
1109 | function addSupport(languages, docLanguage) {
|
1110 | if (typeof languages === 'string') {
|
1111 | languages = [languages];
|
1112 | }
|
1113 |
|
1114 | languages.forEach(function (lang) {
|
1115 | docCommentSupport(lang, function (pattern) {
|
1116 | if (!pattern.inside) {
|
1117 | pattern.inside = {};
|
1118 | }
|
1119 |
|
1120 | pattern.inside.rest = docLanguage;
|
1121 | });
|
1122 | });
|
1123 | }
|
1124 |
|
1125 | Object.defineProperty(javaDocLike, 'addSupport', {
|
1126 | value: addSupport
|
1127 | });
|
1128 | javaDocLike.addSupport(['java', 'javascript', 'php'], javaDocLike);
|
1129 | })(Prism);
|
1130 |
|
1131 |
|
1132 |
|
1133 | (function (Prism) {
|
1134 | var keywords = /\b(?:abstract|continue|for|new|switch|assert|default|goto|package|synchronized|boolean|do|if|private|this|break|double|implements|protected|throw|byte|else|import|public|throws|case|enum|instanceof|return|transient|catch|extends|int|short|try|char|final|interface|static|void|class|finally|long|strictfp|volatile|const|float|native|super|while|var|null|exports|module|open|opens|provides|requires|to|transitive|uses|with)\b/;
|
1135 |
|
1136 | var className = /\b[A-Z](?:\w*[a-z]\w*)?\b/;
|
1137 | Prism.languages.java = Prism.languages.extend('clike', {
|
1138 | 'class-name': [className,
|
1139 |
|
1140 | /\b[A-Z]\w*(?=\s+\w+\s*[;,=())])/],
|
1141 | 'keyword': keywords,
|
1142 | 'function': [Prism.languages.clike.function, {
|
1143 | pattern: /(\:\:)[a-z_]\w*/,
|
1144 | lookbehind: true
|
1145 | }],
|
1146 | 'number': /\b0b[01][01_]*L?\b|\b0x[\da-f_]*\.?[\da-f_p+-]+\b|(?:\b\d[\d_]*\.?[\d_]*|\B\.\d[\d_]*)(?:e[+-]?\d[\d_]*)?[dfl]?/i,
|
1147 | 'operator': {
|
1148 | pattern: /(^|[^.])(?:<<=?|>>>?=?|->|([-+&|])\2|[?:~]|[-+*/%&|^!=<>]=?)/m,
|
1149 | lookbehind: true
|
1150 | }
|
1151 | });
|
1152 | Prism.languages.insertBefore('java', 'class-name', {
|
1153 | 'annotation': {
|
1154 | alias: 'punctuation',
|
1155 | pattern: /(^|[^.])@\w+/,
|
1156 | lookbehind: true
|
1157 | },
|
1158 | 'namespace': {
|
1159 | pattern: /(\b(?:exports|import(?:\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\s+)[a-z]\w*(\.[a-z]\w*)+/,
|
1160 | lookbehind: true,
|
1161 | inside: {
|
1162 | 'punctuation': /\./
|
1163 | }
|
1164 | },
|
1165 | 'generics': {
|
1166 | pattern: /<(?:[\w\s,.&?]|<(?:[\w\s,.&?]|<(?:[\w\s,.&?]|<[\w\s,.&?]*>)*>)*>)*>/,
|
1167 | inside: {
|
1168 | 'class-name': className,
|
1169 | 'keyword': keywords,
|
1170 | 'punctuation': /[<>(),.:]/,
|
1171 | 'operator': /[?&|]/
|
1172 | }
|
1173 | }
|
1174 | });
|
1175 | })(Prism);
|
1176 |
|
1177 |
|
1178 |
|
1179 | (function (Prism) {
|
1180 | |
1181 |
|
1182 |
|
1183 |
|
1184 |
|
1185 |
|
1186 |
|
1187 | function getPlaceholder(language, index) {
|
1188 | return '___' + language.toUpperCase() + index + '___';
|
1189 | }
|
1190 |
|
1191 | Object.defineProperties(Prism.languages['markup-templating'] = {}, {
|
1192 | buildPlaceholders: {
|
1193 | |
1194 |
|
1195 |
|
1196 |
|
1197 |
|
1198 |
|
1199 |
|
1200 |
|
1201 |
|
1202 |
|
1203 |
|
1204 | value: function (env, language, placeholderPattern, replaceFilter) {
|
1205 | if (env.language !== language) {
|
1206 | return;
|
1207 | }
|
1208 |
|
1209 | var tokenStack = env.tokenStack = [];
|
1210 | env.code = env.code.replace(placeholderPattern, function (match) {
|
1211 | if (typeof replaceFilter === 'function' && !replaceFilter(match)) {
|
1212 | return match;
|
1213 | }
|
1214 |
|
1215 | var i = tokenStack.length;
|
1216 | var placeholder;
|
1217 |
|
1218 | while (env.code.indexOf(placeholder = getPlaceholder(language, i)) !== -1) {
|
1219 | ++i;
|
1220 | }
|
1221 |
|
1222 |
|
1223 | tokenStack[i] = match;
|
1224 | return placeholder;
|
1225 | });
|
1226 |
|
1227 | env.grammar = Prism.languages.markup;
|
1228 | }
|
1229 | },
|
1230 | tokenizePlaceholders: {
|
1231 | |
1232 |
|
1233 |
|
1234 |
|
1235 |
|
1236 |
|
1237 | value: function (env, language) {
|
1238 | if (env.language !== language || !env.tokenStack) {
|
1239 | return;
|
1240 | }
|
1241 |
|
1242 |
|
1243 | env.grammar = Prism.languages[language];
|
1244 | var j = 0;
|
1245 | var keys = Object.keys(env.tokenStack);
|
1246 |
|
1247 | function walkTokens(tokens) {
|
1248 | for (var i = 0; i < tokens.length; i++) {
|
1249 |
|
1250 | if (j >= keys.length) {
|
1251 | break;
|
1252 | }
|
1253 |
|
1254 | var token = tokens[i];
|
1255 |
|
1256 | if (typeof token === 'string' || token.content && typeof token.content === 'string') {
|
1257 | var k = keys[j];
|
1258 | var t = env.tokenStack[k];
|
1259 | var s = typeof token === 'string' ? token : token.content;
|
1260 | var placeholder = getPlaceholder(language, k);
|
1261 | var index = s.indexOf(placeholder);
|
1262 |
|
1263 | if (index > -1) {
|
1264 | ++j;
|
1265 | var before = s.substring(0, index);
|
1266 | var middle = new Prism.Token(language, Prism.tokenize(t, env.grammar), 'language-' + language, t);
|
1267 | var after = s.substring(index + placeholder.length);
|
1268 | var replacement = [];
|
1269 |
|
1270 | if (before) {
|
1271 | replacement.push.apply(replacement, walkTokens([before]));
|
1272 | }
|
1273 |
|
1274 | replacement.push(middle);
|
1275 |
|
1276 | if (after) {
|
1277 | replacement.push.apply(replacement, walkTokens([after]));
|
1278 | }
|
1279 |
|
1280 | if (typeof token === 'string') {
|
1281 | tokens.splice.apply(tokens, [i, 1].concat(replacement));
|
1282 | } else {
|
1283 | token.content = replacement;
|
1284 | }
|
1285 | }
|
1286 | } else if (token.content
|
1287 |
|
1288 | ) {
|
1289 | walkTokens(token.content);
|
1290 | }
|
1291 | }
|
1292 |
|
1293 | return tokens;
|
1294 | }
|
1295 |
|
1296 | walkTokens(env.tokens);
|
1297 | }
|
1298 | }
|
1299 | });
|
1300 | })(Prism);
|
1301 |
|
1302 |
|
1303 |
|
1304 |
|
1305 |
|
1306 |
|
1307 |
|
1308 |
|
1309 |
|
1310 |
|
1311 |
|
1312 |
|
1313 |
|
1314 |
|
1315 |
|
1316 |
|
1317 | (function (Prism) {
|
1318 | Prism.languages.php = Prism.languages.extend('clike', {
|
1319 | 'keyword': /\b(?:__halt_compiler|abstract|and|array|as|break|callable|case|catch|class|clone|const|continue|declare|default|die|do|echo|else|elseif|empty|enddeclare|endfor|endforeach|endif|endswitch|endwhile|eval|exit|extends|final|finally|for|foreach|function|global|goto|if|implements|include|include_once|instanceof|insteadof|interface|isset|list|namespace|new|or|parent|print|private|protected|public|require|require_once|return|static|switch|throw|trait|try|unset|use|var|while|xor|yield)\b/i,
|
1320 | 'boolean': {
|
1321 | pattern: /\b(?:false|true)\b/i,
|
1322 | alias: 'constant'
|
1323 | },
|
1324 | 'constant': [/\b[A-Z_][A-Z0-9_]*\b/, /\b(?:null)\b/i],
|
1325 | 'comment': {
|
1326 | pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|\/\/.*)/,
|
1327 | lookbehind: true
|
1328 | }
|
1329 | });
|
1330 | Prism.languages.insertBefore('php', 'string', {
|
1331 | 'shell-comment': {
|
1332 | pattern: /(^|[^\\])#.*/,
|
1333 | lookbehind: true,
|
1334 | alias: 'comment'
|
1335 | }
|
1336 | });
|
1337 | Prism.languages.insertBefore('php', 'comment', {
|
1338 | 'delimiter': {
|
1339 | pattern: /\?>$|^<\?(?:php(?=\s)|=)?/i,
|
1340 | alias: 'important'
|
1341 | }
|
1342 | });
|
1343 | Prism.languages.insertBefore('php', 'keyword', {
|
1344 | 'variable': /\$+(?:\w+\b|(?={))/i,
|
1345 | 'package': {
|
1346 | pattern: /(\\|namespace\s+|use\s+)[\w\\]+/,
|
1347 | lookbehind: true,
|
1348 | inside: {
|
1349 | punctuation: /\\/
|
1350 | }
|
1351 | }
|
1352 | });
|
1353 |
|
1354 | Prism.languages.insertBefore('php', 'operator', {
|
1355 | 'property': {
|
1356 | pattern: /(->)[\w]+/,
|
1357 | lookbehind: true
|
1358 | }
|
1359 | });
|
1360 | var string_interpolation = {
|
1361 | pattern: /{\$(?:{(?:{[^{}]+}|[^{}]+)}|[^{}])+}|(^|[^\\{])\$+(?:\w+(?:\[.+?]|->\w+)*)/,
|
1362 | lookbehind: true,
|
1363 | inside: {
|
1364 | rest: Prism.languages.php
|
1365 | }
|
1366 | };
|
1367 | Prism.languages.insertBefore('php', 'string', {
|
1368 | 'nowdoc-string': {
|
1369 | pattern: /<<<'([^']+)'(?:\r\n?|\n)(?:.*(?:\r\n?|\n))*?\1;/,
|
1370 | greedy: true,
|
1371 | alias: 'string',
|
1372 | inside: {
|
1373 | 'delimiter': {
|
1374 | pattern: /^<<<'[^']+'|[a-z_]\w*;$/i,
|
1375 | alias: 'symbol',
|
1376 | inside: {
|
1377 | 'punctuation': /^<<<'?|[';]$/
|
1378 | }
|
1379 | }
|
1380 | }
|
1381 | },
|
1382 | 'heredoc-string': {
|
1383 | pattern: /<<<(?:"([^"]+)"(?:\r\n?|\n)(?:.*(?:\r\n?|\n))*?\1;|([a-z_]\w*)(?:\r\n?|\n)(?:.*(?:\r\n?|\n))*?\2;)/i,
|
1384 | greedy: true,
|
1385 | alias: 'string',
|
1386 | inside: {
|
1387 | 'delimiter': {
|
1388 | pattern: /^<<<(?:"[^"]+"|[a-z_]\w*)|[a-z_]\w*;$/i,
|
1389 | alias: 'symbol',
|
1390 | inside: {
|
1391 | 'punctuation': /^<<<"?|[";]$/
|
1392 | }
|
1393 | },
|
1394 | 'interpolation': string_interpolation
|
1395 |
|
1396 | }
|
1397 | },
|
1398 | 'single-quoted-string': {
|
1399 | pattern: /'(?:\\[\s\S]|[^\\'])*'/,
|
1400 | greedy: true,
|
1401 | alias: 'string'
|
1402 | },
|
1403 | 'double-quoted-string': {
|
1404 | pattern: /"(?:\\[\s\S]|[^\\"])*"/,
|
1405 | greedy: true,
|
1406 | alias: 'string',
|
1407 | inside: {
|
1408 | 'interpolation': string_interpolation
|
1409 |
|
1410 | }
|
1411 | }
|
1412 | });
|
1413 |
|
1414 | delete Prism.languages.php['string'];
|
1415 | Prism.hooks.add('before-tokenize', function (env) {
|
1416 | if (!/<\?/.test(env.code)) {
|
1417 | return;
|
1418 | }
|
1419 |
|
1420 | var phpPattern = /<\?(?:[^"'/#]|\/(?![*/])|("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|(?:\/\/|#)(?:[^?\n\r]|\?(?!>))*|\/\*[\s\S]*?(?:\*\/|$))*?(?:\?>|$)/ig;
|
1421 | Prism.languages['markup-templating'].buildPlaceholders(env, 'php', phpPattern);
|
1422 | });
|
1423 | Prism.hooks.add('after-tokenize', function (env) {
|
1424 | Prism.languages['markup-templating'].tokenizePlaceholders(env, 'php');
|
1425 | });
|
1426 | })(Prism);
|
1427 |
|
1428 |
|
1429 |
|
1430 | (function (Prism) {
|
1431 | var javascript = Prism.languages.javascript;
|
1432 | var type = /{(?:[^{}]|{(?:[^{}]|{[^{}]*})*})+}/.source;
|
1433 | var parameterPrefix = '(@(?:param|arg|argument|property)\\s+(?:' + type + '\\s+)?)';
|
1434 | Prism.languages.jsdoc = Prism.languages.extend('javadoclike', {
|
1435 | 'parameter': {
|
1436 |
|
1437 | pattern: RegExp(parameterPrefix + /[$\w\xA0-\uFFFF.]+(?=\s|$)/.source),
|
1438 | lookbehind: true,
|
1439 | inside: {
|
1440 | 'punctuation': /\./
|
1441 | }
|
1442 | }
|
1443 | });
|
1444 | Prism.languages.insertBefore('jsdoc', 'keyword', {
|
1445 | 'optional-parameter': {
|
1446 |
|
1447 | pattern: RegExp(parameterPrefix + /\[[$\w\xA0-\uFFFF.]+(?:=[^[\]]+)?\](?=\s|$)/.source),
|
1448 | lookbehind: true,
|
1449 | inside: {
|
1450 | 'parameter': {
|
1451 | pattern: /(^\[)[$\w\xA0-\uFFFF\.]+/,
|
1452 | lookbehind: true,
|
1453 | inside: {
|
1454 | 'punctuation': /\./
|
1455 | }
|
1456 | },
|
1457 | 'code': {
|
1458 | pattern: /(=)[\s\S]*(?=\]$)/,
|
1459 | lookbehind: true,
|
1460 | inside: javascript,
|
1461 | alias: 'language-javascript'
|
1462 | },
|
1463 | 'punctuation': /[=[\]]/
|
1464 | }
|
1465 | },
|
1466 | 'class-name': [{
|
1467 | pattern: RegExp('(@[a-z]+\\s+)' + type),
|
1468 | lookbehind: true,
|
1469 | inside: {
|
1470 | 'punctuation': /[.,:?=<>|{}()[\]]/
|
1471 | }
|
1472 | }, {
|
1473 | pattern: /(@(?:augments|extends|class|interface|memberof!?|this)\s+)[A-Z]\w*(?:\.[A-Z]\w*)*/,
|
1474 | lookbehind: true,
|
1475 | inside: {
|
1476 | 'punctuation': /\./
|
1477 | }
|
1478 | }],
|
1479 | 'example': {
|
1480 | pattern: /(@example\s+)[^@]+?(?=\s*(?:\*\s*)?(?:@\w|\*\/))/,
|
1481 | lookbehind: true,
|
1482 | inside: {
|
1483 | 'code': {
|
1484 | pattern: /^(\s*(?:\*\s*)?).+$/m,
|
1485 | lookbehind: true,
|
1486 | inside: javascript,
|
1487 | alias: 'language-javascript'
|
1488 | }
|
1489 | }
|
1490 | }
|
1491 | });
|
1492 | Prism.languages.javadoclike.addSupport('javascript', Prism.languages.jsdoc);
|
1493 | })(Prism);
|
1494 |
|
1495 |
|
1496 |
|
1497 | Prism.languages.actionscript = Prism.languages.extend('javascript', {
|
1498 | 'keyword': /\b(?:as|break|case|catch|class|const|default|delete|do|else|extends|finally|for|function|if|implements|import|in|instanceof|interface|internal|is|native|new|null|package|private|protected|public|return|super|switch|this|throw|try|typeof|use|var|void|while|with|dynamic|each|final|get|include|namespace|native|override|set|static)\b/,
|
1499 | 'operator': /\+\+|--|(?:[+\-*\/%^]|&&?|\|\|?|<<?|>>?>?|[!=]=?)=?|[~?@]/
|
1500 | });
|
1501 | Prism.languages.actionscript['class-name'].alias = 'function';
|
1502 |
|
1503 | if (Prism.languages.markup) {
|
1504 | Prism.languages.insertBefore('actionscript', 'string', {
|
1505 | 'xml': {
|
1506 | pattern: /(^|[^.])<\/?\w+(?:\s+[^\s>\/=]+=("|')(?:\\[\s\S]|(?!\2)[^\\])*\2)*\s*\/?>/,
|
1507 | lookbehind: true,
|
1508 | inside: {
|
1509 | rest: Prism.languages.markup
|
1510 | }
|
1511 | }
|
1512 | });
|
1513 | }
|
1514 |
|
1515 |
|
1516 |
|
1517 | (function (Prism) {
|
1518 |
|
1519 | var comment = /#(?!\{).+/,
|
1520 | interpolation = {
|
1521 | pattern: /#\{[^}]+\}/,
|
1522 | alias: 'variable'
|
1523 | };
|
1524 | Prism.languages.coffeescript = Prism.languages.extend('javascript', {
|
1525 | 'comment': comment,
|
1526 | 'string': [
|
1527 | {
|
1528 | pattern: /'(?:\\[\s\S]|[^\\'])*'/,
|
1529 | greedy: true
|
1530 | }, {
|
1531 |
|
1532 | pattern: /"(?:\\[\s\S]|[^\\"])*"/,
|
1533 | greedy: true,
|
1534 | inside: {
|
1535 | 'interpolation': interpolation
|
1536 | }
|
1537 | }],
|
1538 | 'keyword': /\b(?:and|break|by|catch|class|continue|debugger|delete|do|each|else|extend|extends|false|finally|for|if|in|instanceof|is|isnt|let|loop|namespace|new|no|not|null|of|off|on|or|own|return|super|switch|then|this|throw|true|try|typeof|undefined|unless|until|when|while|window|with|yes|yield)\b/,
|
1539 | 'class-member': {
|
1540 | pattern: /@(?!\d)\w+/,
|
1541 | alias: 'variable'
|
1542 | }
|
1543 | });
|
1544 | Prism.languages.insertBefore('coffeescript', 'comment', {
|
1545 | 'multiline-comment': {
|
1546 | pattern: /###[\s\S]+?###/,
|
1547 | alias: 'comment'
|
1548 | },
|
1549 |
|
1550 | 'block-regex': {
|
1551 | pattern: /\/{3}[\s\S]*?\/{3}/,
|
1552 | alias: 'regex',
|
1553 | inside: {
|
1554 | 'comment': comment,
|
1555 | 'interpolation': interpolation
|
1556 | }
|
1557 | }
|
1558 | });
|
1559 | Prism.languages.insertBefore('coffeescript', 'string', {
|
1560 | 'inline-javascript': {
|
1561 | pattern: /`(?:\\[\s\S]|[^\\`])*`/,
|
1562 | inside: {
|
1563 | 'delimiter': {
|
1564 | pattern: /^`|`$/,
|
1565 | alias: 'punctuation'
|
1566 | },
|
1567 | rest: Prism.languages.javascript
|
1568 | }
|
1569 | },
|
1570 |
|
1571 | 'multiline-string': [{
|
1572 | pattern: /'''[\s\S]*?'''/,
|
1573 | greedy: true,
|
1574 | alias: 'string'
|
1575 | }, {
|
1576 | pattern: /"""[\s\S]*?"""/,
|
1577 | greedy: true,
|
1578 | alias: 'string',
|
1579 | inside: {
|
1580 | interpolation: interpolation
|
1581 | }
|
1582 | }]
|
1583 | });
|
1584 | Prism.languages.insertBefore('coffeescript', 'keyword', {
|
1585 |
|
1586 | 'property': /(?!\d)\w+(?=\s*:(?!:))/
|
1587 | });
|
1588 | delete Prism.languages.coffeescript['template-string'];
|
1589 | Prism.languages.coffee = Prism.languages.coffeescript;
|
1590 | })(Prism);
|
1591 |
|
1592 |
|
1593 |
|
1594 | (function (Prism) {
|
1595 | Prism.languages.insertBefore('javascript', 'function-variable', {
|
1596 | 'method-variable': {
|
1597 | pattern: RegExp('(\\.\\s*)' + Prism.languages.javascript['function-variable'].pattern.source),
|
1598 | lookbehind: true,
|
1599 | alias: ['function-variable', 'method', 'function', 'property-access']
|
1600 | }
|
1601 | });
|
1602 | Prism.languages.insertBefore('javascript', 'function', {
|
1603 | 'method': {
|
1604 | pattern: RegExp('(\\.\\s*)' + Prism.languages.javascript['function'].source),
|
1605 | lookbehind: true,
|
1606 | alias: ['function', 'property-access']
|
1607 | }
|
1608 | });
|
1609 | Prism.languages.insertBefore('javascript', 'constant', {
|
1610 | 'known-class-name': [{
|
1611 |
|
1612 |
|
1613 | pattern: /\b(?:(?:(?:Uint|Int)(?:8|16|32)|Uint8Clamped|Float(?:32|64))?Array|ArrayBuffer|BigInt|Boolean|DataView|Date|Error|Function|Intl|JSON|Math|Number|Object|Promise|Proxy|Reflect|RegExp|String|Symbol|(?:Weak)?(?:Set|Map)|WebAssembly)\b/,
|
1614 | alias: 'class-name'
|
1615 | }, {
|
1616 |
|
1617 | pattern: /\b(?:[A-Z]\w*)Error\b/,
|
1618 | alias: 'class-name'
|
1619 | }]
|
1620 | });
|
1621 | Prism.languages.javascript['keyword'].unshift({
|
1622 | pattern: /\b(?:as|default|export|from|import)\b/,
|
1623 | alias: 'module'
|
1624 | }, {
|
1625 | pattern: /\bnull\b/,
|
1626 | alias: ['null', 'nil']
|
1627 | }, {
|
1628 | pattern: /\bundefined\b/,
|
1629 | alias: 'nil'
|
1630 | });
|
1631 | Prism.languages.insertBefore('javascript', 'operator', {
|
1632 | 'spread': {
|
1633 | pattern: /\.{3}/,
|
1634 | alias: 'operator'
|
1635 | },
|
1636 | 'arrow': {
|
1637 | pattern: /=>/,
|
1638 | alias: 'operator'
|
1639 | }
|
1640 | });
|
1641 | Prism.languages.insertBefore('javascript', 'punctuation', {
|
1642 | 'property-access': {
|
1643 | pattern: /(\.\s*)#?[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*/,
|
1644 | lookbehind: true
|
1645 | },
|
1646 | 'maybe-class-name': {
|
1647 | pattern: /(^|[^$\w\xA0-\uFFFF])[A-Z][$\w\xA0-\uFFFF]+/,
|
1648 | lookbehind: true
|
1649 | },
|
1650 | 'dom': {
|
1651 |
|
1652 | pattern: /\b(?:document|location|navigator|performance|(?:local|session)Storage|window)\b/,
|
1653 | alias: 'variable'
|
1654 | },
|
1655 | 'console': {
|
1656 | pattern: /\bconsole(?=\s*\.)/,
|
1657 | alias: 'class-name'
|
1658 | }
|
1659 | });
|
1660 |
|
1661 | var maybeClassNameTokens = ['function', 'function-variable', 'method', 'method-variable', 'property-access'];
|
1662 |
|
1663 | for (var i = 0; i < maybeClassNameTokens.length; i++) {
|
1664 | var token = maybeClassNameTokens[i];
|
1665 | var value = Prism.languages.javascript[token];
|
1666 |
|
1667 | if (Prism.util.type(value) === 'RegExp') {
|
1668 | value = Prism.languages.javascript[token] = {
|
1669 | pattern: value
|
1670 | };
|
1671 | }
|
1672 |
|
1673 |
|
1674 | var inside = value.inside || {};
|
1675 | value.inside = inside;
|
1676 | inside['maybe-class-name'] = /^[A-Z][\s\S]*/;
|
1677 | }
|
1678 | })(Prism);
|
1679 |
|
1680 |
|
1681 |
|
1682 | (function (Prism) {
|
1683 | Prism.languages.flow = Prism.languages.extend('javascript', {});
|
1684 | Prism.languages.insertBefore('flow', 'keyword', {
|
1685 | 'type': [{
|
1686 | pattern: /\b(?:[Nn]umber|[Ss]tring|[Bb]oolean|Function|any|mixed|null|void)\b/,
|
1687 | alias: 'tag'
|
1688 | }]
|
1689 | });
|
1690 | Prism.languages.flow['function-variable'].pattern = /[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*=\s*(?:function\b|(?:\([^()]*\)(?:\s*:\s*\w+)?|[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)\s*=>))/i;
|
1691 | delete Prism.languages.flow['parameter'];
|
1692 | Prism.languages.insertBefore('flow', 'operator', {
|
1693 | 'flow-punctuation': {
|
1694 | pattern: /\{\||\|\}/,
|
1695 | alias: 'punctuation'
|
1696 | }
|
1697 | });
|
1698 |
|
1699 | if (!Array.isArray(Prism.languages.flow.keyword)) {
|
1700 | Prism.languages.flow.keyword = [Prism.languages.flow.keyword];
|
1701 | }
|
1702 |
|
1703 | Prism.languages.flow.keyword.unshift({
|
1704 | pattern: /(^|[^$]\b)(?:type|opaque|declare|Class)\b(?!\$)/,
|
1705 | lookbehind: true
|
1706 | }, {
|
1707 | pattern: /(^|[^$]\B)\$(?:await|Diff|Exact|Keys|ObjMap|PropertyType|Shape|Record|Supertype|Subtype|Enum)\b(?!\$)/,
|
1708 | lookbehind: true
|
1709 | });
|
1710 | })(Prism);
|
1711 |
|
1712 |
|
1713 |
|
1714 | Prism.languages.n4js = Prism.languages.extend('javascript', {
|
1715 |
|
1716 | 'keyword': /\b(?:any|Array|boolean|break|case|catch|class|const|constructor|continue|debugger|declare|default|delete|do|else|enum|export|extends|false|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|module|new|null|number|package|private|protected|public|return|set|static|string|super|switch|this|throw|true|try|typeof|var|void|while|with|yield)\b/
|
1717 | });
|
1718 | Prism.languages.insertBefore('n4js', 'constant', {
|
1719 |
|
1720 | 'annotation': {
|
1721 | pattern: /@+\w+/,
|
1722 | alias: 'operator'
|
1723 | }
|
1724 | });
|
1725 | Prism.languages.n4jsd = Prism.languages.n4js;
|
1726 |
|
1727 |
|
1728 | Prism.languages.typescript = Prism.languages.extend('javascript', {
|
1729 |
|
1730 | 'keyword': /\b(?:abstract|as|async|await|break|case|catch|class|const|constructor|continue|debugger|declare|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|is|keyof|let|module|namespace|new|null|of|package|private|protected|public|readonly|return|require|set|static|super|switch|this|throw|try|type|typeof|var|void|while|with|yield)\b/,
|
1731 | 'builtin': /\b(?:string|Function|any|number|boolean|Array|symbol|console|Promise|unknown|never)\b/
|
1732 | });
|
1733 | Prism.languages.ts = Prism.languages.typescript;
|
1734 |
|
1735 |
|
1736 | (function (Prism) {
|
1737 | var templateString = Prism.languages.javascript['template-string'];
|
1738 |
|
1739 | var templateLiteralPattern = templateString.pattern.source;
|
1740 | var interpolationObject = templateString.inside['interpolation'];
|
1741 | var interpolationPunctuationObject = interpolationObject.inside['interpolation-punctuation'];
|
1742 | var interpolationPattern = interpolationObject.pattern.source;
|
1743 | |
1744 |
|
1745 |
|
1746 |
|
1747 |
|
1748 |
|
1749 |
|
1750 |
|
1751 |
|
1752 |
|
1753 |
|
1754 |
|
1755 | function createTemplate(language, tag) {
|
1756 | if (!Prism.languages[language]) {
|
1757 | return undefined;
|
1758 | }
|
1759 |
|
1760 | return {
|
1761 | pattern: RegExp('((?:' + tag + ')\\s*)' + templateLiteralPattern),
|
1762 | lookbehind: true,
|
1763 | greedy: true,
|
1764 | inside: {
|
1765 | 'template-punctuation': {
|
1766 | pattern: /^`|`$/,
|
1767 | alias: 'string'
|
1768 | },
|
1769 | 'embedded-code': {
|
1770 | pattern: /[\s\S]+/,
|
1771 | alias: language
|
1772 | }
|
1773 | }
|
1774 | };
|
1775 | }
|
1776 |
|
1777 | Prism.languages.javascript['template-string'] = [
|
1778 |
|
1779 |
|
1780 |
|
1781 | createTemplate('css', /\b(?:styled(?:\([^)]*\))?(?:\s*\.\s*\w+(?:\([^)]*\))*)*|css(?:\s*\.\s*(?:global|resolve))?|createGlobalStyle|keyframes)/.source),
|
1782 |
|
1783 | createTemplate('html', /\bhtml|\.\s*(?:inner|outer)HTML\s*\+?=/.source), // svg`<path fill="#fff" d="M55.37 ..."/>`
|
1784 | createTemplate('svg', /\bsvg/.source), // md`# h1`, markdown`## h2`
|
1785 | createTemplate('markdown', /\b(?:md|markdown)/.source),
|
1786 | createTemplate('graphql', /\b(?:gql|graphql(?:\s*\.\s*experimental)?)/.source),
|
1787 | templateString].filter(Boolean);
|
1788 | |
1789 |
|
1790 |
|
1791 |
|
1792 |
|
1793 |
|
1794 |
|
1795 |
|
1796 | function getPlaceholder(counter, language) {
|
1797 | return '___' + language.toUpperCase() + '_' + counter + '___';
|
1798 | }
|
1799 | |
1800 |
|
1801 |
|
1802 |
|
1803 |
|
1804 |
|
1805 |
|
1806 |
|
1807 |
|
1808 |
|
1809 | function tokenizeWithHooks(code, grammar, language) {
|
1810 | var env = {
|
1811 | code: code,
|
1812 | grammar: grammar,
|
1813 | language: language
|
1814 | };
|
1815 | Prism.hooks.run('before-tokenize', env);
|
1816 | env.tokens = Prism.tokenize(env.code, env.grammar);
|
1817 | Prism.hooks.run('after-tokenize', env);
|
1818 | return env.tokens;
|
1819 | }
|
1820 | |
1821 |
|
1822 |
|
1823 |
|
1824 |
|
1825 |
|
1826 |
|
1827 |
|
1828 | function tokenizeInterpolationExpression(expression) {
|
1829 | var tempGrammar = {};
|
1830 | tempGrammar['interpolation-punctuation'] = interpolationPunctuationObject;
|
1831 |
|
1832 |
|
1833 | var tokens = Prism.tokenize(expression, tempGrammar);
|
1834 |
|
1835 | if (tokens.length === 3) {
|
1836 | |
1837 |
|
1838 |
|
1839 |
|
1840 |
|
1841 |
|
1842 |
|
1843 |
|
1844 | var args = [1, 1];
|
1845 | args.push.apply(args, tokenizeWithHooks(tokens[1], Prism.languages.javascript, 'javascript'));
|
1846 | tokens.splice.apply(tokens, args);
|
1847 | }
|
1848 |
|
1849 | return new Prism.Token('interpolation', tokens, interpolationObject.alias, expression);
|
1850 | }
|
1851 | |
1852 |
|
1853 |
|
1854 |
|
1855 |
|
1856 |
|
1857 |
|
1858 |
|
1859 |
|
1860 |
|
1861 |
|
1862 |
|
1863 |
|
1864 |
|
1865 |
|
1866 |
|
1867 |
|
1868 |
|
1869 |
|
1870 | function tokenizeEmbedded(code, grammar, language) {
|
1871 |
|
1872 |
|
1873 |
|
1874 |
|
1875 | var _tokens = Prism.tokenize(code, {
|
1876 | 'interpolation': {
|
1877 | pattern: RegExp(interpolationPattern),
|
1878 | lookbehind: true
|
1879 | }
|
1880 | });
|
1881 |
|
1882 |
|
1883 | var placeholderCounter = 0;
|
1884 |
|
1885 |
|
1886 | var placeholderMap = {};
|
1887 |
|
1888 | var embeddedCode = _tokens.map(function (token) {
|
1889 | if (typeof token === 'string') {
|
1890 | return token;
|
1891 | } else {
|
1892 | var interpolationExpression = token.content;
|
1893 | var placeholder;
|
1894 |
|
1895 | while (code.indexOf(placeholder = getPlaceholder(placeholderCounter++, language)) !== -1) {}
|
1896 |
|
1897 | placeholderMap[placeholder] = interpolationExpression;
|
1898 | return placeholder;
|
1899 | }
|
1900 | }).join('');
|
1901 |
|
1902 |
|
1903 | var embeddedTokens = tokenizeWithHooks(embeddedCode, grammar, language);
|
1904 |
|
1905 | var placeholders = Object.keys(placeholderMap);
|
1906 | placeholderCounter = 0;
|
1907 | |
1908 |
|
1909 |
|
1910 |
|
1911 |
|
1912 |
|
1913 | function walkTokens(tokens) {
|
1914 | for (var i = 0; i < tokens.length; i++) {
|
1915 | if (placeholderCounter >= placeholders.length) {
|
1916 | return;
|
1917 | }
|
1918 |
|
1919 | var token = tokens[i];
|
1920 |
|
1921 | if (typeof token === 'string' || typeof token.content === 'string') {
|
1922 | var placeholder = placeholders[placeholderCounter];
|
1923 | var s = typeof token === 'string' ? token :
|
1924 |
|
1925 | token.content;
|
1926 | var index = s.indexOf(placeholder);
|
1927 |
|
1928 | if (index !== -1) {
|
1929 | ++placeholderCounter;
|
1930 | var before = s.substring(0, index);
|
1931 | var middle = tokenizeInterpolationExpression(placeholderMap[placeholder]);
|
1932 | var after = s.substring(index + placeholder.length);
|
1933 | var replacement = [];
|
1934 |
|
1935 | if (before) {
|
1936 | replacement.push(before);
|
1937 | }
|
1938 |
|
1939 | replacement.push(middle);
|
1940 |
|
1941 | if (after) {
|
1942 | var afterTokens = [after];
|
1943 | walkTokens(afterTokens);
|
1944 | replacement.push.apply(replacement, afterTokens);
|
1945 | }
|
1946 |
|
1947 | if (typeof token === 'string') {
|
1948 | tokens.splice.apply(tokens, [i, 1].concat(replacement));
|
1949 | i += replacement.length - 1;
|
1950 | } else {
|
1951 | token.content = replacement;
|
1952 | }
|
1953 | }
|
1954 | } else {
|
1955 | var content = token.content;
|
1956 |
|
1957 | if (Array.isArray(content)) {
|
1958 | walkTokens(content);
|
1959 | } else {
|
1960 | walkTokens([content]);
|
1961 | }
|
1962 | }
|
1963 | }
|
1964 | }
|
1965 |
|
1966 | walkTokens(embeddedTokens);
|
1967 | return new Prism.Token(language, embeddedTokens, 'language-' + language, code);
|
1968 | }
|
1969 | |
1970 |
|
1971 |
|
1972 |
|
1973 |
|
1974 |
|
1975 |
|
1976 | var supportedLanguages = {
|
1977 | 'javascript': true,
|
1978 | 'js': true,
|
1979 | 'typescript': true,
|
1980 | 'ts': true,
|
1981 | 'jsx': true,
|
1982 | 'tsx': true
|
1983 | };
|
1984 | Prism.hooks.add('after-tokenize', function (env) {
|
1985 | if (!(env.language in supportedLanguages)) {
|
1986 | return;
|
1987 | }
|
1988 | |
1989 |
|
1990 |
|
1991 |
|
1992 |
|
1993 |
|
1994 |
|
1995 |
|
1996 | function findTemplateStrings(tokens) {
|
1997 | for (var i = 0, l = tokens.length; i < l; i++) {
|
1998 | var token = tokens[i];
|
1999 |
|
2000 | if (typeof token === 'string') {
|
2001 | continue;
|
2002 | }
|
2003 |
|
2004 | var content = token.content;
|
2005 |
|
2006 | if (!Array.isArray(content)) {
|
2007 | if (typeof content !== 'string') {
|
2008 | findTemplateStrings([content]);
|
2009 | }
|
2010 |
|
2011 | continue;
|
2012 | }
|
2013 |
|
2014 | if (token.type === 'template-string') {
|
2015 | |
2016 |
|
2017 |
|
2018 |
|
2019 |
|
2020 |
|
2021 |
|
2022 |
|
2023 |
|
2024 |
|
2025 |
|
2026 |
|
2027 |
|
2028 |
|
2029 | var embedded = content[1];
|
2030 |
|
2031 | if (content.length === 3 && typeof embedded !== 'string' && embedded.type === 'embedded-code') {
|
2032 |
|
2033 | var code = stringContent(embedded);
|
2034 | var alias = embedded.alias;
|
2035 | var language = Array.isArray(alias) ? alias[0] : alias;
|
2036 | var grammar = Prism.languages[language];
|
2037 |
|
2038 | if (!grammar) {
|
2039 |
|
2040 | continue;
|
2041 | }
|
2042 |
|
2043 | content[1] = tokenizeEmbedded(code, grammar, language);
|
2044 | }
|
2045 | } else {
|
2046 | findTemplateStrings(content);
|
2047 | }
|
2048 | }
|
2049 | }
|
2050 |
|
2051 | findTemplateStrings(env.tokens);
|
2052 | });
|
2053 | |
2054 |
|
2055 |
|
2056 |
|
2057 |
|
2058 |
|
2059 |
|
2060 | function stringContent(value) {
|
2061 | if (typeof value === 'string') {
|
2062 | return value;
|
2063 | } else if (Array.isArray(value)) {
|
2064 | return value.map(stringContent).join('');
|
2065 | } else {
|
2066 | return stringContent(value.content);
|
2067 | }
|
2068 | }
|
2069 | })(Prism);
|
2070 |
|
2071 |
|
2072 |
|
2073 | Prism.languages.graphql = {
|
2074 | 'comment': /#.*/,
|
2075 | 'string': {
|
2076 | pattern: /"(?:\\.|[^\\"\r\n])*"/,
|
2077 | greedy: true
|
2078 | },
|
2079 | 'number': /(?:\B-|\b)\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,
|
2080 | 'boolean': /\b(?:true|false)\b/,
|
2081 | 'variable': /\$[a-z_]\w*/i,
|
2082 | 'directive': {
|
2083 | pattern: /@[a-z_]\w*/i,
|
2084 | alias: 'function'
|
2085 | },
|
2086 | 'attr-name': {
|
2087 | pattern: /[a-z_]\w*(?=\s*(?:\((?:[^()"]|"(?:\\.|[^\\"\r\n])*")*\))?:)/i,
|
2088 | greedy: true
|
2089 | },
|
2090 | 'class-name': {
|
2091 | pattern: /(\b(?:enum|implements|interface|on|scalar|type|union)\s+)[a-zA-Z_]\w*/,
|
2092 | lookbehind: true
|
2093 | },
|
2094 | 'fragment': {
|
2095 | pattern: /(\bfragment\s+|\.{3}\s*(?!on\b))[a-zA-Z_]\w*/,
|
2096 | lookbehind: true,
|
2097 | alias: 'function'
|
2098 | },
|
2099 | 'keyword': /\b(?:enum|fragment|implements|input|interface|mutation|on|query|scalar|schema|type|union)\b/,
|
2100 | 'operator': /[!=|]|\.{3}/,
|
2101 | 'punctuation': /[!(){}\[\]:=,]/,
|
2102 | 'constant': /\b(?!ID\b)[A-Z][A-Z_\d]*\b/
|
2103 | };
|
2104 |
|
2105 |
|
2106 | (function (Prism) {
|
2107 |
|
2108 | var inner = /(?:\\.|[^\\\n\r]|(?:\r?\n|\r)(?!\r?\n|\r))/.source;
|
2109 | |
2110 |
|
2111 |
|
2112 |
|
2113 |
|
2114 |
|
2115 |
|
2116 |
|
2117 |
|
2118 |
|
2119 |
|
2120 |
|
2121 | function createInline(pattern, starAlternative) {
|
2122 | pattern = pattern.replace(/<inner>/g, inner);
|
2123 |
|
2124 | if (starAlternative) {
|
2125 | pattern = pattern + '|' + pattern.replace(/_/g, '\\*');
|
2126 | }
|
2127 |
|
2128 | return RegExp(/((?:^|[^\\])(?:\\{2})*)/.source + '(?:' + pattern + ')');
|
2129 | }
|
2130 |
|
2131 | var tableCell = /(?:\\.|``.+?``|`[^`\r\n]+`|[^\\|\r\n`])+/.source;
|
2132 | var tableRow = /\|?__(?:\|__)+\|?(?:(?:\r?\n|\r)|$)/.source.replace(/__/g, tableCell);
|
2133 | var tableLine = /\|?[ \t]*:?-{3,}:?[ \t]*(?:\|[ \t]*:?-{3,}:?[ \t]*)+\|?(?:\r?\n|\r)/.source;
|
2134 | Prism.languages.markdown = Prism.languages.extend('markup', {});
|
2135 | Prism.languages.insertBefore('markdown', 'prolog', {
|
2136 | 'blockquote': {
|
2137 |
|
2138 | pattern: /^>(?:[\t ]*>)*/m,
|
2139 | alias: 'punctuation'
|
2140 | },
|
2141 | 'table': {
|
2142 | pattern: RegExp('^' + tableRow + tableLine + '(?:' + tableRow + ')*', 'm'),
|
2143 | inside: {
|
2144 | 'table-data-rows': {
|
2145 | pattern: RegExp('^(' + tableRow + tableLine + ')(?:' + tableRow + ')*$'),
|
2146 | lookbehind: true,
|
2147 | inside: {
|
2148 | 'table-data': {
|
2149 | pattern: RegExp(tableCell),
|
2150 | inside: Prism.languages.markdown
|
2151 | },
|
2152 | 'punctuation': /\|/
|
2153 | }
|
2154 | },
|
2155 | 'table-line': {
|
2156 | pattern: RegExp('^(' + tableRow + ')' + tableLine + '$'),
|
2157 | lookbehind: true,
|
2158 | inside: {
|
2159 | 'punctuation': /\||:?-{3,}:?/
|
2160 | }
|
2161 | },
|
2162 | 'table-header-row': {
|
2163 | pattern: RegExp('^' + tableRow + '$'),
|
2164 | inside: {
|
2165 | 'table-header': {
|
2166 | pattern: RegExp(tableCell),
|
2167 | alias: 'important',
|
2168 | inside: Prism.languages.markdown
|
2169 | },
|
2170 | 'punctuation': /\|/
|
2171 | }
|
2172 | }
|
2173 | }
|
2174 | },
|
2175 | 'code': [{
|
2176 |
|
2177 | pattern: /(^[ \t]*(?:\r?\n|\r))(?: {4}|\t).+(?:(?:\r?\n|\r)(?: {4}|\t).+)*/m,
|
2178 | lookbehind: true,
|
2179 | alias: 'keyword'
|
2180 | }, {
|
2181 |
|
2182 |
|
2183 | pattern: /``.+?``|`[^`\r\n]+`/,
|
2184 | alias: 'keyword'
|
2185 | }, {
|
2186 |
|
2187 |
|
2188 |
|
2189 | pattern: /^```[\s\S]*?^```$/m,
|
2190 | greedy: true,
|
2191 | inside: {
|
2192 | 'code-block': {
|
2193 | pattern: /^(```.*(?:\r?\n|\r))[\s\S]+?(?=(?:\r?\n|\r)^```$)/m,
|
2194 | lookbehind: true
|
2195 | },
|
2196 | 'code-language': {
|
2197 | pattern: /^(```).+/,
|
2198 | lookbehind: true
|
2199 | },
|
2200 | 'punctuation': /```/
|
2201 | }
|
2202 | }],
|
2203 | 'title': [{
|
2204 |
|
2205 |
|
2206 |
|
2207 |
|
2208 | pattern: /\S.*(?:\r?\n|\r)(?:==+|--+)(?=[ \t]*$)/m,
|
2209 | alias: 'important',
|
2210 | inside: {
|
2211 | punctuation: /==+$|--+$/
|
2212 | }
|
2213 | }, {
|
2214 |
|
2215 |
|
2216 | pattern: /(^\s*)#+.+/m,
|
2217 | lookbehind: true,
|
2218 | alias: 'important',
|
2219 | inside: {
|
2220 | punctuation: /^#+|#+$/
|
2221 | }
|
2222 | }],
|
2223 | 'hr': {
|
2224 |
|
2225 |
|
2226 |
|
2227 |
|
2228 | pattern: /(^\s*)([*-])(?:[\t ]*\2){2,}(?=\s*$)/m,
|
2229 | lookbehind: true,
|
2230 | alias: 'punctuation'
|
2231 | },
|
2232 | 'list': {
|
2233 |
|
2234 |
|
2235 |
|
2236 |
|
2237 | pattern: /(^\s*)(?:[*+-]|\d+\.)(?=[\t ].)/m,
|
2238 | lookbehind: true,
|
2239 | alias: 'punctuation'
|
2240 | },
|
2241 | 'url-reference': {
|
2242 |
|
2243 |
|
2244 |
|
2245 |
|
2246 | pattern: /!?\[[^\]]+\]:[\t ]+(?:\S+|<(?:\\.|[^>\\])+>)(?:[\t ]+(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\((?:\\.|[^)\\])*\)))?/,
|
2247 | inside: {
|
2248 | 'variable': {
|
2249 | pattern: /^(!?\[)[^\]]+/,
|
2250 | lookbehind: true
|
2251 | },
|
2252 | 'string': /(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\((?:\\.|[^)\\])*\))$/,
|
2253 | 'punctuation': /^[\[\]!:]|[<>]/
|
2254 | },
|
2255 | alias: 'url'
|
2256 | },
|
2257 | 'bold': {
|
2258 |
|
2259 |
|
2260 |
|
2261 | pattern: createInline(/__(?:(?!_)<inner>|_(?:(?!_)<inner>)+_)+__/.source, true),
|
2262 | lookbehind: true,
|
2263 | greedy: true,
|
2264 | inside: {
|
2265 | 'content': {
|
2266 | pattern: /(^..)[\s\S]+(?=..$)/,
|
2267 | lookbehind: true,
|
2268 | inside: {}
|
2269 |
|
2270 | },
|
2271 | 'punctuation': /\*\*|__/
|
2272 | }
|
2273 | },
|
2274 | 'italic': {
|
2275 |
|
2276 |
|
2277 |
|
2278 | pattern: createInline(/_(?:(?!_)<inner>|__(?:(?!_)<inner>)+__)+_/.source, true),
|
2279 | lookbehind: true,
|
2280 | greedy: true,
|
2281 | inside: {
|
2282 | 'content': {
|
2283 | pattern: /(^.)[\s\S]+(?=.$)/,
|
2284 | lookbehind: true,
|
2285 | inside: {}
|
2286 |
|
2287 | },
|
2288 | 'punctuation': /[*_]/
|
2289 | }
|
2290 | },
|
2291 | 'strike': {
|
2292 |
|
2293 |
|
2294 | pattern: createInline(/(~~?)(?:(?!~)<inner>)+?\2/.source, false),
|
2295 | lookbehind: true,
|
2296 | greedy: true,
|
2297 | inside: {
|
2298 | 'content': {
|
2299 | pattern: /(^~~?)[\s\S]+(?=\1$)/,
|
2300 | lookbehind: true,
|
2301 | inside: {}
|
2302 |
|
2303 | },
|
2304 | 'punctuation': /~~?/
|
2305 | }
|
2306 | },
|
2307 | 'url': {
|
2308 |
|
2309 |
|
2310 |
|
2311 | pattern: createInline(/!?\[(?:(?!\])<inner>)+\](?:\([^\s)]+(?:[\t ]+"(?:\\.|[^"\\])*")?\)| ?\[(?:(?!\])<inner>)+\])/.source, false),
|
2312 | lookbehind: true,
|
2313 | greedy: true,
|
2314 | inside: {
|
2315 | 'variable': {
|
2316 | pattern: /(\[)[^\]]+(?=\]$)/,
|
2317 | lookbehind: true
|
2318 | },
|
2319 | 'content': {
|
2320 | pattern: /(^!?\[)[^\]]+(?=\])/,
|
2321 | lookbehind: true,
|
2322 | inside: {}
|
2323 |
|
2324 | },
|
2325 | 'string': {
|
2326 | pattern: /"(?:\\.|[^"\\])*"(?=\)$)/
|
2327 | }
|
2328 | }
|
2329 | }
|
2330 | });
|
2331 | ['url', 'bold', 'italic', 'strike'].forEach(function (token) {
|
2332 | ['url', 'bold', 'italic', 'strike'].forEach(function (inside) {
|
2333 | if (token !== inside) {
|
2334 | Prism.languages.markdown[token].inside.content.inside[inside] = Prism.languages.markdown[inside];
|
2335 | }
|
2336 | });
|
2337 | });
|
2338 | Prism.hooks.add('after-tokenize', function (env) {
|
2339 | if (env.language !== 'markdown' && env.language !== 'md') {
|
2340 | return;
|
2341 | }
|
2342 |
|
2343 | function walkTokens(tokens) {
|
2344 | if (!tokens || typeof tokens === 'string') {
|
2345 | return;
|
2346 | }
|
2347 |
|
2348 | for (var i = 0, l = tokens.length; i < l; i++) {
|
2349 | var token = tokens[i];
|
2350 |
|
2351 | if (token.type !== 'code') {
|
2352 | walkTokens(token.content);
|
2353 | continue;
|
2354 | }
|
2355 | |
2356 |
|
2357 |
|
2358 |
|
2359 |
|
2360 |
|
2361 |
|
2362 |
|
2363 |
|
2364 |
|
2365 |
|
2366 |
|
2367 |
|
2368 |
|
2369 |
|
2370 | var codeLang = token.content[1];
|
2371 | var codeBlock = token.content[3];
|
2372 |
|
2373 | if (codeLang && codeBlock && codeLang.type === 'code-language' && codeBlock.type === 'code-block' && typeof codeLang.content === 'string') {
|
2374 |
|
2375 | var alias = 'language-' + codeLang.content.trim().split(/\s+/)[0].toLowerCase();
|
2376 |
|
2377 | if (!codeBlock.alias) {
|
2378 | codeBlock.alias = [alias];
|
2379 | } else if (typeof codeBlock.alias === 'string') {
|
2380 | codeBlock.alias = [codeBlock.alias, alias];
|
2381 | } else {
|
2382 | codeBlock.alias.push(alias);
|
2383 | }
|
2384 | }
|
2385 | }
|
2386 | }
|
2387 |
|
2388 | walkTokens(env.tokens);
|
2389 | });
|
2390 | Prism.hooks.add('wrap', function (env) {
|
2391 | if (env.type !== 'code-block') {
|
2392 | return;
|
2393 | }
|
2394 |
|
2395 | var codeLang = '';
|
2396 |
|
2397 | for (var i = 0, l = env.classes.length; i < l; i++) {
|
2398 | var cls = env.classes[i];
|
2399 | var match = /language-(.+)/.exec(cls);
|
2400 |
|
2401 | if (match) {
|
2402 | codeLang = match[1];
|
2403 | break;
|
2404 | }
|
2405 | }
|
2406 |
|
2407 | var grammar = Prism.languages[codeLang];
|
2408 |
|
2409 | if (!grammar) {
|
2410 | if (codeLang && codeLang !== 'none' && Prism.plugins.autoloader) {
|
2411 | var id = 'md-' + new Date().valueOf() + '-' + Math.floor(Math.random() * 1e16);
|
2412 | env.attributes['id'] = id;
|
2413 | Prism.plugins.autoloader.loadLanguages(codeLang, function () {
|
2414 | var ele = document.getElementById(id);
|
2415 |
|
2416 | if (ele) {
|
2417 | ele.innerHTML = Prism.highlight(ele.textContent, Prism.languages[codeLang], codeLang);
|
2418 | }
|
2419 | });
|
2420 | }
|
2421 | } else {
|
2422 |
|
2423 | var code = env.content.replace(/</g, '<').replace(/&/g, '&');
|
2424 | env.content = Prism.highlight(code, grammar, codeLang);
|
2425 | }
|
2426 | });
|
2427 | Prism.languages.md = Prism.languages.markdown;
|
2428 | })(Prism);
|
2429 |
|
2430 |
|
2431 |
|
2432 | (function (Prism) {
|
2433 | Prism.languages.diff = {
|
2434 | 'coord': [
|
2435 | /^(?:\*{3}|-{3}|\+{3}).*$/m,
|
2436 | /^@@.*@@$/m,
|
2437 | /^\d+.*$/m]
|
2438 |
|
2439 | };
|
2440 | |
2441 |
|
2442 |
|
2443 |
|
2444 |
|
2445 |
|
2446 | var PREFIXES = {
|
2447 | 'deleted-sign': '-',
|
2448 | 'deleted-arrow': '<',
|
2449 | 'inserted-sign': '+',
|
2450 | 'inserted-arrow': '>',
|
2451 | 'unchanged': ' ',
|
2452 | 'diff': '!'
|
2453 | };
|
2454 |
|
2455 | Object.keys(PREFIXES).forEach(function (name) {
|
2456 | var prefix = PREFIXES[name];
|
2457 | var alias = [];
|
2458 |
|
2459 | if (!/^\w+$/.test(name)) {
|
2460 |
|
2461 | alias.push(/\w+/.exec(name)[0]);
|
2462 | }
|
2463 |
|
2464 | if (name === "diff") {
|
2465 | alias.push("bold");
|
2466 | }
|
2467 |
|
2468 | Prism.languages.diff[name] = {
|
2469 |
|
2470 | pattern: RegExp('^(?:[' + prefix + '].*(?:\r\n?|\n|(?![\\s\\S])))+', 'm'),
|
2471 | alias: alias
|
2472 | };
|
2473 | });
|
2474 |
|
2475 | Object.defineProperty(Prism.languages.diff, 'PREFIXES', {
|
2476 | value: PREFIXES
|
2477 | });
|
2478 | })(Prism);
|
2479 |
|
2480 |
|
2481 |
|
2482 | Prism.languages.git = {
|
2483 | |
2484 |
|
2485 |
|
2486 |
|
2487 |
|
2488 |
|
2489 |
|
2490 |
|
2491 |
|
2492 | 'comment': /^#.*/m,
|
2493 |
|
2494 | |
2495 |
|
2496 |
|
2497 | 'deleted': /^[-–].*/m,
|
2498 | 'inserted': /^\+.*/m,
|
2499 |
|
2500 | |
2501 |
|
2502 |
|
2503 | 'string': /("|')(?:\\.|(?!\1)[^\\\r\n])*\1/m,
|
2504 |
|
2505 | |
2506 |
|
2507 |
|
2508 |
|
2509 |
|
2510 | 'command': {
|
2511 | pattern: /^.*\$ git .*$/m,
|
2512 | inside: {
|
2513 | |
2514 |
|
2515 |
|
2516 |
|
2517 |
|
2518 |
|
2519 | 'parameter': /\s--?\w+/m
|
2520 | }
|
2521 | },
|
2522 |
|
2523 | |
2524 |
|
2525 |
|
2526 |
|
2527 |
|
2528 |
|
2529 |
|
2530 |
|
2531 |
|
2532 |
|
2533 |
|
2534 |
|
2535 |
|
2536 | 'coord': /^@@.*@@$/m,
|
2537 |
|
2538 | |
2539 |
|
2540 |
|
2541 |
|
2542 |
|
2543 |
|
2544 |
|
2545 |
|
2546 |
|
2547 |
|
2548 | 'commit_sha1': /^commit \w{40}$/m
|
2549 | };
|
2550 |
|
2551 |
|
2552 | Prism.languages.go = Prism.languages.extend('clike', {
|
2553 | 'keyword': /\b(?:break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(?:to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/,
|
2554 | 'builtin': /\b(?:bool|byte|complex(?:64|128)|error|float(?:32|64)|rune|string|u?int(?:8|16|32|64)?|uintptr|append|cap|close|complex|copy|delete|imag|len|make|new|panic|print(?:ln)?|real|recover)\b/,
|
2555 | 'boolean': /\b(?:_|iota|nil|true|false)\b/,
|
2556 | 'operator': /[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,
|
2557 | 'number': /(?:\b0x[a-f\d]+|(?:\b\d+\.?\d*|\B\.\d+)(?:e[-+]?\d+)?)i?/i,
|
2558 | 'string': {
|
2559 | pattern: /(["'`])(\\[\s\S]|(?!\1)[^\\])*\1/,
|
2560 | greedy: true
|
2561 | }
|
2562 | });
|
2563 | delete Prism.languages.go['class-name'];
|
2564 |
|
2565 |
|
2566 | (function (Prism) {
|
2567 | Prism.languages.handlebars = {
|
2568 | 'comment': /\{\{![\s\S]*?\}\}/,
|
2569 | 'delimiter': {
|
2570 | pattern: /^\{\{\{?|\}\}\}?$/i,
|
2571 | alias: 'punctuation'
|
2572 | },
|
2573 | 'string': /(["'])(?:\\.|(?!\1)[^\\\r\n])*\1/,
|
2574 | 'number': /\b0x[\dA-Fa-f]+\b|(?:\b\d+\.?\d*|\B\.\d+)(?:[Ee][+-]?\d+)?/,
|
2575 | 'boolean': /\b(?:true|false)\b/,
|
2576 | 'block': {
|
2577 | pattern: /^(\s*~?\s*)[#\/]\S+?(?=\s*~?\s*$|\s)/i,
|
2578 | lookbehind: true,
|
2579 | alias: 'keyword'
|
2580 | },
|
2581 | 'brackets': {
|
2582 | pattern: /\[[^\]]+\]/,
|
2583 | inside: {
|
2584 | punctuation: /\[|\]/,
|
2585 | variable: /[\s\S]+/
|
2586 | }
|
2587 | },
|
2588 | 'punctuation': /[!"#%&'()*+,.\/;<=>@\[\\\]^`{|}~]/,
|
2589 | 'variable': /[^!"#%&'()*+,.\/;<=>@\[\\\]^`{|}~\s]+/
|
2590 | };
|
2591 | Prism.hooks.add('before-tokenize', function (env) {
|
2592 | var handlebarsPattern = /\{\{\{[\s\S]+?\}\}\}|\{\{[\s\S]+?\}\}/g;
|
2593 | Prism.languages['markup-templating'].buildPlaceholders(env, 'handlebars', handlebarsPattern);
|
2594 | });
|
2595 | Prism.hooks.add('after-tokenize', function (env) {
|
2596 | Prism.languages['markup-templating'].tokenizePlaceholders(env, 'handlebars');
|
2597 | });
|
2598 | })(Prism);
|
2599 |
|
2600 |
|
2601 |
|
2602 | Prism.languages.json = {
|
2603 | 'property': {
|
2604 | pattern: /"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,
|
2605 | greedy: true
|
2606 | },
|
2607 | 'string': {
|
2608 | pattern: /"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,
|
2609 | greedy: true
|
2610 | },
|
2611 | 'comment': /\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,
|
2612 | 'number': /-?\d+\.?\d*(e[+-]?\d+)?/i,
|
2613 | 'punctuation': /[{}[\],]/,
|
2614 | 'operator': /:/,
|
2615 | 'boolean': /\b(?:true|false)\b/,
|
2616 | 'null': {
|
2617 | pattern: /\bnull\b/,
|
2618 | alias: 'keyword'
|
2619 | }
|
2620 | };
|
2621 |
|
2622 |
|
2623 |
|
2624 |
|
2625 |
|
2626 |
|
2627 |
|
2628 |
|
2629 |
|
2630 |
|
2631 | Prism.languages.less = Prism.languages.extend('css', {
|
2632 | 'comment': [/\/\*[\s\S]*?\*\//, {
|
2633 | pattern: /(^|[^\\])\/\/.*/,
|
2634 | lookbehind: true
|
2635 | }],
|
2636 | 'atrule': {
|
2637 | pattern: /@[\w-]+?(?:\([^{}]+\)|[^(){};])*?(?=\s*\{)/i,
|
2638 | inside: {
|
2639 | 'punctuation': /[:()]/
|
2640 | }
|
2641 | },
|
2642 |
|
2643 | 'selector': {
|
2644 | pattern: /(?:@\{[\w-]+\}|[^{};\s@])(?:@\{[\w-]+\}|\([^{}]*\)|[^{};@])*?(?=\s*\{)/,
|
2645 | inside: {
|
2646 |
|
2647 | 'variable': /@+[\w-]+/
|
2648 | }
|
2649 | },
|
2650 | 'property': /(?:@\{[\w-]+\}|[\w-])+(?:\+_?)?(?=\s*:)/i,
|
2651 | 'operator': /[+\-*\/]/
|
2652 | });
|
2653 | Prism.languages.insertBefore('less', 'property', {
|
2654 | 'variable': [
|
2655 | {
|
2656 | pattern: /@[\w-]+\s*:/,
|
2657 | inside: {
|
2658 | "punctuation": /:/
|
2659 | }
|
2660 | },
|
2661 | /@@?[\w-]+/],
|
2662 | 'mixin-usage': {
|
2663 | pattern: /([{;]\s*)[.#](?!\d)[\w-]+.*?(?=[(;])/,
|
2664 | lookbehind: true,
|
2665 | alias: 'function'
|
2666 | }
|
2667 | });
|
2668 |
|
2669 |
|
2670 | Prism.languages.makefile = {
|
2671 | 'comment': {
|
2672 | pattern: /(^|[^\\])#(?:\\(?:\r\n|[\s\S])|[^\\\r\n])*/,
|
2673 | lookbehind: true
|
2674 | },
|
2675 | 'string': {
|
2676 | pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
|
2677 | greedy: true
|
2678 | },
|
2679 |
|
2680 | 'builtin': /\.[A-Z][^:#=\s]+(?=\s*:(?!=))/,
|
2681 |
|
2682 | 'symbol': {
|
2683 | pattern: /^[^:=\r\n]+(?=\s*:(?!=))/m,
|
2684 | inside: {
|
2685 | 'variable': /\$+(?:[^(){}:#=\s]+|(?=[({]))/
|
2686 | }
|
2687 | },
|
2688 | 'variable': /\$+(?:[^(){}:#=\s]+|\([@*%<^+?][DF]\)|(?=[({]))/,
|
2689 | 'keyword': [
|
2690 | /-include\b|\b(?:define|else|endef|endif|export|ifn?def|ifn?eq|include|override|private|sinclude|undefine|unexport|vpath)\b/,
|
2691 | {
|
2692 | pattern: /(\()(?:addsuffix|abspath|and|basename|call|dir|error|eval|file|filter(?:-out)?|findstring|firstword|flavor|foreach|guile|if|info|join|lastword|load|notdir|or|origin|patsubst|realpath|shell|sort|strip|subst|suffix|value|warning|wildcard|word(?:s|list)?)(?=[ \t])/,
|
2693 | lookbehind: true
|
2694 | }],
|
2695 | 'operator': /(?:::|[?:+!])?=|[|@]/,
|
2696 | 'punctuation': /[:;(){}]/
|
2697 | };
|
2698 |
|
2699 |
|
2700 | Prism.languages.objectivec = Prism.languages.extend('c', {
|
2701 | 'keyword': /\b(?:asm|typeof|inline|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|union|unsigned|void|volatile|while|in|self|super)\b|(?:@interface|@end|@implementation|@protocol|@class|@public|@protected|@private|@property|@try|@catch|@finally|@throw|@synthesize|@dynamic|@selector)\b/,
|
2702 | 'string': /("|')(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1|@"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"/,
|
2703 | 'operator': /-[->]?|\+\+?|!=?|<<?=?|>>?=?|==?|&&?|\|\|?|[~^%?*\/@]/
|
2704 | });
|
2705 | delete Prism.languages.objectivec['class-name'];
|
2706 |
|
2707 |
|
2708 | Prism.languages.ocaml = {
|
2709 | 'comment': /\(\*[\s\S]*?\*\)/,
|
2710 | 'string': [{
|
2711 | pattern: /"(?:\\.|[^\\\r\n"])*"/,
|
2712 | greedy: true
|
2713 | }, {
|
2714 | pattern: /(['`])(?:\\(?:\d+|x[\da-f]+|.)|(?!\1)[^\\\r\n])\1/i,
|
2715 | greedy: true
|
2716 | }],
|
2717 | 'number': /\b(?:0x[\da-f][\da-f_]+|(?:0[bo])?\d[\d_]*\.?[\d_]*(?:e[+-]?[\d_]+)?)/i,
|
2718 | 'type': {
|
2719 | pattern: /\B['`]\w*/,
|
2720 | alias: 'variable'
|
2721 | },
|
2722 | 'directive': {
|
2723 | pattern: /\B#\w+/,
|
2724 | alias: 'function'
|
2725 | },
|
2726 | 'keyword': /\b(?:as|assert|begin|class|constraint|do|done|downto|else|end|exception|external|for|fun|function|functor|if|in|include|inherit|initializer|lazy|let|match|method|module|mutable|new|object|of|open|prefix|private|rec|then|sig|struct|to|try|type|val|value|virtual|where|while|with)\b/,
|
2727 | 'boolean': /\b(?:false|true)\b/,
|
2728 |
|
2729 | 'operator': /:=|[=<>@^|&+\-*\/$%!?~][!$%&*+\-.\/:<=>?@^|~]*|\b(?:and|asr|land|lor|lxor|lsl|lsr|mod|nor|or)\b/,
|
2730 | 'punctuation': /[(){}\[\]|_.,:;]/
|
2731 | };
|
2732 |
|
2733 |
|
2734 | Prism.languages.python = {
|
2735 | 'comment': {
|
2736 | pattern: /(^|[^\\])#.*/,
|
2737 | lookbehind: true
|
2738 | },
|
2739 | 'string-interpolation': {
|
2740 | pattern: /(?:f|rf|fr)(?:("""|''')[\s\S]+?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2)/i,
|
2741 | greedy: true,
|
2742 | inside: {
|
2743 | 'interpolation': {
|
2744 |
|
2745 | pattern: /((?:^|[^{])(?:{{)*){(?!{)(?:[^{}]|{(?!{)(?:[^{}]|{(?!{)(?:[^{}])+})+})+}/,
|
2746 | lookbehind: true,
|
2747 | inside: {
|
2748 | 'format-spec': {
|
2749 | pattern: /(:)[^:(){}]+(?=}$)/,
|
2750 | lookbehind: true
|
2751 | },
|
2752 | 'conversion-option': {
|
2753 | pattern: /![sra](?=[:}]$)/,
|
2754 | alias: 'punctuation'
|
2755 | },
|
2756 | rest: null
|
2757 | }
|
2758 | },
|
2759 | 'string': /[\s\S]+/
|
2760 | }
|
2761 | },
|
2762 | 'triple-quoted-string': {
|
2763 | pattern: /(?:[rub]|rb|br)?("""|''')[\s\S]+?\1/i,
|
2764 | greedy: true,
|
2765 | alias: 'string'
|
2766 | },
|
2767 | 'string': {
|
2768 | pattern: /(?:[rub]|rb|br)?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/i,
|
2769 | greedy: true
|
2770 | },
|
2771 | 'function': {
|
2772 | pattern: /((?:^|\s)def[ \t]+)[a-zA-Z_]\w*(?=\s*\()/g,
|
2773 | lookbehind: true
|
2774 | },
|
2775 | 'class-name': {
|
2776 | pattern: /(\bclass\s+)\w+/i,
|
2777 | lookbehind: true
|
2778 | },
|
2779 | 'decorator': {
|
2780 | pattern: /(^\s*)@\w+(?:\.\w+)*/i,
|
2781 | lookbehind: true,
|
2782 | alias: ['annotation', 'punctuation'],
|
2783 | inside: {
|
2784 | 'punctuation': /\./
|
2785 | }
|
2786 | },
|
2787 | 'keyword': /\b(?:and|as|assert|async|await|break|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|nonlocal|not|or|pass|print|raise|return|try|while|with|yield)\b/,
|
2788 | 'builtin': /\b(?:__import__|abs|all|any|apply|ascii|basestring|bin|bool|buffer|bytearray|bytes|callable|chr|classmethod|cmp|coerce|compile|complex|delattr|dict|dir|divmod|enumerate|eval|execfile|file|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|intern|isinstance|issubclass|iter|len|list|locals|long|map|max|memoryview|min|next|object|oct|open|ord|pow|property|range|raw_input|reduce|reload|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|unichr|unicode|vars|xrange|zip)\b/,
|
2789 | 'boolean': /\b(?:True|False|None)\b/,
|
2790 | 'number': /(?:\b(?=\d)|\B(?=\.))(?:0[bo])?(?:(?:\d|0x[\da-f])[\da-f]*\.?\d*|\.\d+)(?:e[+-]?\d+)?j?\b/i,
|
2791 | 'operator': /[-+%=]=?|!=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/,
|
2792 | 'punctuation': /[{}[\];(),.:]/
|
2793 | };
|
2794 | Prism.languages.python['string-interpolation'].inside['interpolation'].inside.rest = Prism.languages.python;
|
2795 | Prism.languages.py = Prism.languages.python;
|
2796 |
|
2797 |
|
2798 | Prism.languages.reason = Prism.languages.extend('clike', {
|
2799 | 'comment': {
|
2800 | pattern: /(^|[^\\])\/\*[\s\S]*?\*\//,
|
2801 | lookbehind: true
|
2802 | },
|
2803 | 'string': {
|
2804 | pattern: /"(?:\\(?:\r\n|[\s\S])|[^\\\r\n"])*"/,
|
2805 | greedy: true
|
2806 | },
|
2807 |
|
2808 | 'class-name': /\b[A-Z]\w*/,
|
2809 | 'keyword': /\b(?:and|as|assert|begin|class|constraint|do|done|downto|else|end|exception|external|for|fun|function|functor|if|in|include|inherit|initializer|lazy|let|method|module|mutable|new|nonrec|object|of|open|or|private|rec|sig|struct|switch|then|to|try|type|val|virtual|when|while|with)\b/,
|
2810 | 'operator': /\.{3}|:[:=]|\|>|->|=(?:==?|>)?|<=?|>=?|[|^?'#!~`]|[+\-*\/]\.?|\b(?:mod|land|lor|lxor|lsl|lsr|asr)\b/
|
2811 | });
|
2812 | Prism.languages.insertBefore('reason', 'class-name', {
|
2813 | 'character': {
|
2814 | pattern: /'(?:\\x[\da-f]{2}|\\o[0-3][0-7][0-7]|\\\d{3}|\\.|[^'\\\r\n])'/,
|
2815 | alias: 'string'
|
2816 | },
|
2817 | 'constructor': {
|
2818 |
|
2819 | pattern: /\b[A-Z]\w*\b(?!\s*\.)/,
|
2820 | alias: 'variable'
|
2821 | },
|
2822 | 'label': {
|
2823 | pattern: /\b[a-z]\w*(?=::)/,
|
2824 | alias: 'symbol'
|
2825 | }
|
2826 | });
|
2827 |
|
2828 | delete Prism.languages.reason.function;
|
2829 |
|
2830 |
|
2831 | (function (Prism) {
|
2832 | Prism.languages.sass = Prism.languages.extend('css', {
|
2833 |
|
2834 | 'comment': {
|
2835 | pattern: /^([ \t]*)\/[\/*].*(?:(?:\r?\n|\r)\1[ \t]+.+)*/m,
|
2836 | lookbehind: true
|
2837 | }
|
2838 | });
|
2839 | Prism.languages.insertBefore('sass', 'atrule', {
|
2840 |
|
2841 | 'atrule-line': {
|
2842 |
|
2843 | pattern: /^(?:[ \t]*)[@+=].+/m,
|
2844 | inside: {
|
2845 | 'atrule': /(?:@[\w-]+|[+=])/m
|
2846 | }
|
2847 | }
|
2848 | });
|
2849 | delete Prism.languages.sass.atrule;
|
2850 | var variable = /\$[-\w]+|#\{\$[-\w]+\}/;
|
2851 | var operator = [/[+*\/%]|[=!]=|<=?|>=?|\b(?:and|or|not)\b/, {
|
2852 | pattern: /(\s+)-(?=\s)/,
|
2853 | lookbehind: true
|
2854 | }];
|
2855 | Prism.languages.insertBefore('sass', 'property', {
|
2856 |
|
2857 | 'variable-line': {
|
2858 | pattern: /^[ \t]*\$.+/m,
|
2859 | inside: {
|
2860 | 'punctuation': /:/,
|
2861 | 'variable': variable,
|
2862 | 'operator': operator
|
2863 | }
|
2864 | },
|
2865 |
|
2866 | 'property-line': {
|
2867 | pattern: /^[ \t]*(?:[^:\s]+ *:.*|:[^:\s]+.*)/m,
|
2868 | inside: {
|
2869 | 'property': [/[^:\s]+(?=\s*:)/, {
|
2870 | pattern: /(:)[^:\s]+/,
|
2871 | lookbehind: true
|
2872 | }],
|
2873 | 'punctuation': /:/,
|
2874 | 'variable': variable,
|
2875 | 'operator': operator,
|
2876 | 'important': Prism.languages.sass.important
|
2877 | }
|
2878 | }
|
2879 | });
|
2880 | delete Prism.languages.sass.property;
|
2881 | delete Prism.languages.sass.important;
|
2882 |
|
2883 |
|
2884 | Prism.languages.insertBefore('sass', 'punctuation', {
|
2885 | 'selector': {
|
2886 | pattern: /([ \t]*)\S(?:,?[^,\r\n]+)*(?:,(?:\r?\n|\r)\1[ \t]+\S(?:,?[^,\r\n]+)*)*/,
|
2887 | lookbehind: true
|
2888 | }
|
2889 | });
|
2890 | })(Prism);
|
2891 |
|
2892 |
|
2893 |
|
2894 | Prism.languages.scss = Prism.languages.extend('css', {
|
2895 | 'comment': {
|
2896 | pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|\/\/.*)/,
|
2897 | lookbehind: true
|
2898 | },
|
2899 | 'atrule': {
|
2900 | pattern: /@[\w-]+(?:\([^()]+\)|[^(])*?(?=\s+[{;])/,
|
2901 | inside: {
|
2902 | 'rule': /@[\w-]+/
|
2903 |
|
2904 | }
|
2905 | },
|
2906 |
|
2907 | 'url': /(?:[-a-z]+-)?url(?=\()/i,
|
2908 |
|
2909 |
|
2910 |
|
2911 |
|
2912 |
|
2913 |
|
2914 |
|
2915 | 'selector': {
|
2916 |
|
2917 | pattern: /(?=\S)[^@;{}()]?(?:[^@;{}()]|#\{\$[-\w]+\})+(?=\s*\{(?:\}|\s|[^}]+[:{][^}]+))/m,
|
2918 | inside: {
|
2919 | 'parent': {
|
2920 | pattern: /&/,
|
2921 | alias: 'important'
|
2922 | },
|
2923 | 'placeholder': /%[-\w]+/,
|
2924 | 'variable': /\$[-\w]+|#\{\$[-\w]+\}/
|
2925 | }
|
2926 | },
|
2927 | 'property': {
|
2928 | pattern: /(?:[\w-]|\$[-\w]+|#\{\$[-\w]+\})+(?=\s*:)/,
|
2929 | inside: {
|
2930 | 'variable': /\$[-\w]+|#\{\$[-\w]+\}/
|
2931 | }
|
2932 | }
|
2933 | });
|
2934 | Prism.languages.insertBefore('scss', 'atrule', {
|
2935 | 'keyword': [/@(?:if|else(?: if)?|for|each|while|import|extend|debug|warn|mixin|include|function|return|content)/i, {
|
2936 | pattern: /( +)(?:from|through)(?= )/,
|
2937 | lookbehind: true
|
2938 | }]
|
2939 | });
|
2940 | Prism.languages.insertBefore('scss', 'important', {
|
2941 |
|
2942 | 'variable': /\$[-\w]+|#\{\$[-\w]+\}/
|
2943 | });
|
2944 | Prism.languages.insertBefore('scss', 'function', {
|
2945 | 'placeholder': {
|
2946 | pattern: /%[-\w]+/,
|
2947 | alias: 'selector'
|
2948 | },
|
2949 | 'statement': {
|
2950 | pattern: /\B!(?:default|optional)\b/i,
|
2951 | alias: 'keyword'
|
2952 | },
|
2953 | 'boolean': /\b(?:true|false)\b/,
|
2954 | 'null': {
|
2955 | pattern: /\bnull\b/,
|
2956 | alias: 'keyword'
|
2957 | },
|
2958 | 'operator': {
|
2959 | pattern: /(\s)(?:[-+*\/%]|[=!]=|<=?|>=?|and|or|not)(?=\s)/,
|
2960 | lookbehind: true
|
2961 | }
|
2962 | });
|
2963 | Prism.languages.scss['atrule'].inside.rest = Prism.languages.scss;
|
2964 |
|
2965 |
|
2966 | Prism.languages.sql = {
|
2967 | 'comment': {
|
2968 | pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|(?:--|\/\/|#).*)/,
|
2969 | lookbehind: true
|
2970 | },
|
2971 | 'variable': [{
|
2972 | pattern: /@(["'`])(?:\\[\s\S]|(?!\1)[^\\])+\1/,
|
2973 | greedy: true
|
2974 | }, /@[\w.$]+/],
|
2975 | 'string': {
|
2976 | pattern: /(^|[^@\\])("|')(?:\\[\s\S]|(?!\2)[^\\]|\2\2)*\2/,
|
2977 | greedy: true,
|
2978 | lookbehind: true
|
2979 | },
|
2980 | 'function': /\b(?:AVG|COUNT|FIRST|FORMAT|LAST|LCASE|LEN|MAX|MID|MIN|MOD|NOW|ROUND|SUM|UCASE)(?=\s*\()/i,
|
2981 |
|
2982 | 'keyword': /\b(?:ACTION|ADD|AFTER|ALGORITHM|ALL|ALTER|ANALYZE|ANY|APPLY|AS|ASC|AUTHORIZATION|AUTO_INCREMENT|BACKUP|BDB|BEGIN|BERKELEYDB|BIGINT|BINARY|BIT|BLOB|BOOL|BOOLEAN|BREAK|BROWSE|BTREE|BULK|BY|CALL|CASCADED?|CASE|CHAIN|CHAR(?:ACTER|SET)?|CHECK(?:POINT)?|CLOSE|CLUSTERED|COALESCE|COLLATE|COLUMNS?|COMMENT|COMMIT(?:TED)?|COMPUTE|CONNECT|CONSISTENT|CONSTRAINT|CONTAINS(?:TABLE)?|CONTINUE|CONVERT|CREATE|CROSS|CURRENT(?:_DATE|_TIME|_TIMESTAMP|_USER)?|CURSOR|CYCLE|DATA(?:BASES?)?|DATE(?:TIME)?|DAY|DBCC|DEALLOCATE|DEC|DECIMAL|DECLARE|DEFAULT|DEFINER|DELAYED|DELETE|DELIMITERS?|DENY|DESC|DESCRIBE|DETERMINISTIC|DISABLE|DISCARD|DISK|DISTINCT|DISTINCTROW|DISTRIBUTED|DO|DOUBLE|DROP|DUMMY|DUMP(?:FILE)?|DUPLICATE|ELSE(?:IF)?|ENABLE|ENCLOSED|END|ENGINE|ENUM|ERRLVL|ERRORS|ESCAPED?|EXCEPT|EXEC(?:UTE)?|EXISTS|EXIT|EXPLAIN|EXTENDED|FETCH|FIELDS|FILE|FILLFACTOR|FIRST|FIXED|FLOAT|FOLLOWING|FOR(?: EACH ROW)?|FORCE|FOREIGN|FREETEXT(?:TABLE)?|FROM|FULL|FUNCTION|GEOMETRY(?:COLLECTION)?|GLOBAL|GOTO|GRANT|GROUP|HANDLER|HASH|HAVING|HOLDLOCK|HOUR|IDENTITY(?:_INSERT|COL)?|IF|IGNORE|IMPORT|INDEX|INFILE|INNER|INNODB|INOUT|INSERT|INT|INTEGER|INTERSECT|INTERVAL|INTO|INVOKER|ISOLATION|ITERATE|JOIN|KEYS?|KILL|LANGUAGE|LAST|LEAVE|LEFT|LEVEL|LIMIT|LINENO|LINES|LINESTRING|LOAD|LOCAL|LOCK|LONG(?:BLOB|TEXT)|LOOP|MATCH(?:ED)?|MEDIUM(?:BLOB|INT|TEXT)|MERGE|MIDDLEINT|MINUTE|MODE|MODIFIES|MODIFY|MONTH|MULTI(?:LINESTRING|POINT|POLYGON)|NATIONAL|NATURAL|NCHAR|NEXT|NO|NONCLUSTERED|NULLIF|NUMERIC|OFF?|OFFSETS?|ON|OPEN(?:DATASOURCE|QUERY|ROWSET)?|OPTIMIZE|OPTION(?:ALLY)?|ORDER|OUT(?:ER|FILE)?|OVER|PARTIAL|PARTITION|PERCENT|PIVOT|PLAN|POINT|POLYGON|PRECEDING|PRECISION|PREPARE|PREV|PRIMARY|PRINT|PRIVILEGES|PROC(?:EDURE)?|PUBLIC|PURGE|QUICK|RAISERROR|READS?|REAL|RECONFIGURE|REFERENCES|RELEASE|RENAME|REPEAT(?:ABLE)?|REPLACE|REPLICATION|REQUIRE|RESIGNAL|RESTORE|RESTRICT|RETURNS?|REVOKE|RIGHT|ROLLBACK|ROUTINE|ROW(?:COUNT|GUIDCOL|S)?|RTREE|RULE|SAVE(?:POINT)?|SCHEMA|SECOND|SELECT|SERIAL(?:IZABLE)?|SESSION(?:_USER)?|SET(?:USER)?|SHARE|SHOW|SHUTDOWN|SIMPLE|SMALLINT|SNAPSHOT|SOME|SONAME|SQL|START(?:ING)?|STATISTICS|STATUS|STRIPED|SYSTEM_USER|TABLES?|TABLESPACE|TEMP(?:ORARY|TABLE)?|TERMINATED|TEXT(?:SIZE)?|THEN|TIME(?:STAMP)?|TINY(?:BLOB|INT|TEXT)|TOP?|TRAN(?:SACTIONS?)?|TRIGGER|TRUNCATE|TSEQUAL|TYPES?|UNBOUNDED|UNCOMMITTED|UNDEFINED|UNION|UNIQUE|UNLOCK|UNPIVOT|UNSIGNED|UPDATE(?:TEXT)?|USAGE|USE|USER|USING|VALUES?|VAR(?:BINARY|CHAR|CHARACTER|YING)|VIEW|WAITFOR|WARNINGS|WHEN|WHERE|WHILE|WITH(?: ROLLUP|IN)?|WORK|WRITE(?:TEXT)?|YEAR)\b/i,
|
2983 | 'boolean': /\b(?:TRUE|FALSE|NULL)\b/i,
|
2984 | 'number': /\b0x[\da-f]+\b|\b\d+\.?\d*|\B\.\d+\b/i,
|
2985 | 'operator': /[-+*\/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?|\b(?:AND|BETWEEN|IN|LIKE|NOT|OR|IS|DIV|REGEXP|RLIKE|SOUNDS LIKE|XOR)\b/i,
|
2986 | 'punctuation': /[;[\]()`,.]/
|
2987 | };
|
2988 |
|
2989 |
|
2990 | (function (Prism) {
|
2991 | var inside = {
|
2992 | 'url': /url\((["']?).*?\1\)/i,
|
2993 | 'string': {
|
2994 | pattern: /("|')(?:(?!\1)[^\\\r\n]|\\(?:\r\n|[\s\S]))*\1/,
|
2995 | greedy: true
|
2996 | },
|
2997 | 'interpolation': null,
|
2998 |
|
2999 | 'func': null,
|
3000 |
|
3001 | 'important': /\B!(?:important|optional)\b/i,
|
3002 | 'keyword': {
|
3003 | pattern: /(^|\s+)(?:(?:if|else|for|return|unless)(?=\s+|$)|@[\w-]+)/,
|
3004 | lookbehind: true
|
3005 | },
|
3006 | 'hexcode': /#[\da-f]{3,6}/i,
|
3007 | 'number': /\b\d+(?:\.\d+)?%?/,
|
3008 | 'boolean': /\b(?:true|false)\b/,
|
3009 | 'operator': [
|
3010 |
|
3011 | /~|[+!\/%<>?=]=?|[-:]=|\*[*=]?|\.+|&&|\|\||\B-\B|\b(?:and|in|is(?: a| defined| not|nt)?|not|or)\b/],
|
3012 | 'punctuation': /[{}()\[\];:,]/
|
3013 | };
|
3014 | inside['interpolation'] = {
|
3015 | pattern: /\{[^\r\n}:]+\}/,
|
3016 | alias: 'variable',
|
3017 | inside: {
|
3018 | 'delimiter': {
|
3019 | pattern: /^{|}$/,
|
3020 | alias: 'punctuation'
|
3021 | },
|
3022 | rest: inside
|
3023 | }
|
3024 | };
|
3025 | inside['func'] = {
|
3026 | pattern: /[\w-]+\([^)]*\).*/,
|
3027 | inside: {
|
3028 | 'function': /^[^(]+/,
|
3029 | rest: inside
|
3030 | }
|
3031 | };
|
3032 | Prism.languages.stylus = {
|
3033 | 'comment': {
|
3034 | pattern: /(^|[^\\])(\/\*[\s\S]*?\*\/|\/\/.*)/,
|
3035 | lookbehind: true
|
3036 | },
|
3037 | 'atrule-declaration': {
|
3038 | pattern: /(^\s*)@.+/m,
|
3039 | lookbehind: true,
|
3040 | inside: {
|
3041 | 'atrule': /^@[\w-]+/,
|
3042 | rest: inside
|
3043 | }
|
3044 | },
|
3045 | 'variable-declaration': {
|
3046 | pattern: /(^[ \t]*)[\w$-]+\s*.?=[ \t]*(?:(?:\{[^}]*\}|.+)|$)/m,
|
3047 | lookbehind: true,
|
3048 | inside: {
|
3049 | 'variable': /^\S+/,
|
3050 | rest: inside
|
3051 | }
|
3052 | },
|
3053 | 'statement': {
|
3054 | pattern: /(^[ \t]*)(?:if|else|for|return|unless)[ \t]+.+/m,
|
3055 | lookbehind: true,
|
3056 | inside: {
|
3057 | keyword: /^\S+/,
|
3058 | rest: inside
|
3059 | }
|
3060 | },
|
3061 | // A property/value pair cannot end with a comma or a brace
|
3062 | // It cannot have indented content unless it ended with a semicolon
|
3063 | 'property-declaration': {
|
3064 | pattern: /((?:^|\{)([ \t]*))(?:[\w-]|\{[^}\r\n]+\})+(?:\s*:\s*|[ \t]+)[^{\r\n]*(?:;|[^{\r\n,](?=$)(?!(\r?\n|\r)(?:\{|\2[ \t]+)))/m,
|
3065 | lookbehind: true,
|
3066 | inside: {
|
3067 | 'property': {
|
3068 | pattern: /^[^\s:]+/,
|
3069 | inside: {
|
3070 | 'interpolation': inside.interpolation
|
3071 | }
|
3072 | },
|
3073 | rest: inside
|
3074 | }
|
3075 | },
|
3076 | // A selector can contain parentheses only as part of a pseudo-element
|
3077 | // It can span multiple lines.
|
3078 | // It must end with a comma or an accolade or have indented content.
|
3079 | 'selector': {
|
3080 | pattern: /(^[ \t]*)(?:(?=\S)(?:[^{}\r\n:()]|::?[\w-]+(?:\([^)\r\n]*\))?|\{[^}\r\n]+\})+)(?:(?:\r?\n|\r)(?:\1(?:(?=\S)(?:[^{}\r\n:()]|::?[\w-]+(?:\([^)\r\n]*\))?|\{[^}\r\n]+\})+)))*(?:,$|\{|(?=(?:\r?\n|\r)(?:\{|\1[ \t]+)))/m,
|
3081 | lookbehind: true,
|
3082 | inside: {
|
3083 | 'interpolation': inside.interpolation,
|
3084 | 'punctuation': /[{},]/
|
3085 | }
|
3086 | },
|
3087 | 'func': inside.func,
|
3088 | 'string': inside.string,
|
3089 | 'interpolation': inside.interpolation,
|
3090 | 'punctuation': /[{}()\[\];:.]/
|
3091 | };
|
3092 | })(Prism);
|
3093 | /* "prismjs/components/prism-wasm" */
|
3094 |
|
3095 |
|
3096 | Prism.languages.wasm = {
|
3097 | 'comment': [/\(;[\s\S]*?;\)/, {
|
3098 | pattern: /;;.*/,
|
3099 | greedy: true
|
3100 | }],
|
3101 | 'string': {
|
3102 | pattern: /"(?:\\[\s\S]|[^"\\])*"/,
|
3103 | greedy: true
|
3104 | },
|
3105 | 'keyword': [{
|
3106 | pattern: /\b(?:align|offset)=/,
|
3107 | inside: {
|
3108 | 'operator': /=/
|
3109 | }
|
3110 | }, {
|
3111 | pattern: /\b(?:(?:f32|f64|i32|i64)(?:\.(?:abs|add|and|ceil|clz|const|convert_[su]\/i(?:32|64)|copysign|ctz|demote\/f64|div(?:_[su])?|eqz?|extend_[su]\/i32|floor|ge(?:_[su])?|gt(?:_[su])?|le(?:_[su])?|load(?:(?:8|16|32)_[su])?|lt(?:_[su])?|max|min|mul|nearest|neg?|or|popcnt|promote\/f32|reinterpret\/[fi](?:32|64)|rem_[su]|rot[lr]|shl|shr_[su]|store(?:8|16|32)?|sqrt|sub|trunc(?:_[su]\/f(?:32|64))?|wrap\/i64|xor))?|memory\.(?:grow|size))\b/,
|
3112 | inside: {
|
3113 | 'punctuation': /\./
|
3114 | }
|
3115 | }, /\b(?:anyfunc|block|br(?:_if|_table)?|call(?:_indirect)?|data|drop|elem|else|end|export|func|get_(?:global|local)|global|if|import|local|loop|memory|module|mut|nop|offset|param|result|return|select|set_(?:global|local)|start|table|tee_local|then|type|unreachable)\b/],
|
3116 | 'variable': /\$[\w!#$%&'*+\-./:<=>?@\\^_`|~]+/i,
|
3117 | 'number': /[+-]?\b(?:\d(?:_?\d)*(?:\.\d(?:_?\d)*)?(?:[eE][+-]?\d(?:_?\d)*)?|0x[\da-fA-F](?:_?[\da-fA-F])*(?:\.[\da-fA-F](?:_?[\da-fA-D])*)?(?:[pP][+-]?\d(?:_?\d)*)?)\b|\binf\b|\bnan(?::0x[\da-fA-F](?:_?[\da-fA-D])*)?\b/,
|
3118 | 'punctuation': /[()]/
|
3119 | };
|
3120 | /* "prismjs/components/prism-yaml" */
|
3121 |
|
3122 | Prism.languages.yaml = {
|
3123 | 'scalar': {
|
3124 | pattern: /([\-:]\s*(?:![^\s]+)?[ \t]*[|>])[ \t]*(?:((?:\r?\n|\r)[ \t]+)[^\r\n]+(?:\2[^\r\n]+)*)/,
|
3125 | lookbehind: true,
|
3126 | alias: 'string'
|
3127 | },
|
3128 | 'comment': /#.*/,
|
3129 | 'key': {
|
3130 | pattern: /(\s*(?:^|[:\-,[{\r\n?])[ \t]*(?:![^\s]+)?[ \t]*)[^\r\n{[\]},#\s]+?(?=\s*:\s)/,
|
3131 | lookbehind: true,
|
3132 | alias: 'atrule'
|
3133 | },
|
3134 | 'directive': {
|
3135 | pattern: /(^[ \t]*)%.+/m,
|
3136 | lookbehind: true,
|
3137 | alias: 'important'
|
3138 | },
|
3139 | 'datetime': {
|
3140 | pattern: /([:\-,[{]\s*(?:![^\s]+)?[ \t]*)(?:\d{4}-\d\d?-\d\d?(?:[tT]|[ \t]+)\d\d?:\d{2}:\d{2}(?:\.\d*)?[ \t]*(?:Z|[-+]\d\d?(?::\d{2})?)?|\d{4}-\d{2}-\d{2}|\d\d?:\d{2}(?::\d{2}(?:\.\d*)?)?)(?=[ \t]*(?:$|,|]|}))/m,
|
3141 | lookbehind: true,
|
3142 | alias: 'number'
|
3143 | },
|
3144 | 'boolean': {
|
3145 | pattern: /([:\-,[{]\s*(?:![^\s]+)?[ \t]*)(?:true|false)[ \t]*(?=$|,|]|})/im,
|
3146 | lookbehind: true,
|
3147 | alias: 'important'
|
3148 | },
|
3149 | 'null': {
|
3150 | pattern: /([:\-,[{]\s*(?:![^\s]+)?[ \t]*)(?:null|~)[ \t]*(?=$|,|]|})/im,
|
3151 | lookbehind: true,
|
3152 | alias: 'important'
|
3153 | },
|
3154 | 'string': {
|
3155 | pattern: /([:\-,[{]\s*(?:![^\s]+)?[ \t]*)("|')(?:(?!\2)[^\\\r\n]|\\.)*\2(?=[ \t]*(?:$|,|]|}|\s*#))/m,
|
3156 | lookbehind: true,
|
3157 | greedy: true
|
3158 | },
|
3159 | 'number': {
|
3160 | pattern: /([:\-,[{]\s*(?:![^\s]+)?[ \t]*)[+-]?(?:0x[\da-f]+|0o[0-7]+|(?:\d+\.?\d*|\.?\d+)(?:e[+-]?\d+)?|\.inf|\.nan)[ \t]*(?=$|,|]|})/im,
|
3161 | lookbehind: true
|
3162 | },
|
3163 | 'tag': /![^\s]+/,
|
3164 | 'important': /[&*][\w]+/,
|
3165 | 'punctuation': /---|[:[\]{}\-,|>?]|\.\.\./
|
3166 | };
|
3167 | Prism.languages.yml = Prism.languages.yaml;
|
3168 |
|
3169 | export default Prism;
|
3170 |
|
\ | No newline at end of file |