1 | 'use strict';
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 | var Prism = function () {
|
20 | var uniqueId = 0;
|
21 | var _ = {
|
22 | util: {
|
23 | encode: function (tokens) {
|
24 | if (tokens instanceof Token) {
|
25 | return new Token(tokens.type, _.util.encode(tokens.content), tokens.alias);
|
26 | } else if (_.util.type(tokens) === "Array") {
|
27 | return tokens.map(_.util.encode);
|
28 | } else {
|
29 | return tokens.replace(/&/g, "&").replace(/</g, "<").replace(/\u00a0/g, " ");
|
30 | }
|
31 | },
|
32 | type: function (o) {
|
33 | return Object.prototype.toString.call(o).match(/\[object (\w+)\]/)[1];
|
34 | },
|
35 | objId: function (obj) {
|
36 | if (!obj["__id"]) {
|
37 | Object.defineProperty(obj, "__id", {
|
38 | value: ++uniqueId
|
39 | });
|
40 | }
|
41 |
|
42 | return obj["__id"];
|
43 | },
|
44 |
|
45 | clone: function (o, visited) {
|
46 | var type = _.util.type(o);
|
47 |
|
48 | visited = visited || {};
|
49 |
|
50 | switch (type) {
|
51 | case "Object":
|
52 | if (visited[_.util.objId(o)]) {
|
53 | return visited[_.util.objId(o)];
|
54 | }
|
55 |
|
56 | var clone = {};
|
57 | visited[_.util.objId(o)] = clone;
|
58 |
|
59 | for (var key in o) {
|
60 | if (o.hasOwnProperty(key)) {
|
61 | clone[key] = _.util.clone(o[key], visited);
|
62 | }
|
63 | }
|
64 |
|
65 | return clone;
|
66 |
|
67 | case "Array":
|
68 | if (visited[_.util.objId(o)]) {
|
69 | return visited[_.util.objId(o)];
|
70 | }
|
71 |
|
72 | var clone = [];
|
73 | visited[_.util.objId(o)] = clone;
|
74 | o.forEach(function (v, i) {
|
75 | clone[i] = _.util.clone(v, visited);
|
76 | });
|
77 | return clone;
|
78 | }
|
79 |
|
80 | return o;
|
81 | }
|
82 | },
|
83 | languages: {
|
84 | extend: function (id, redef) {
|
85 | var lang = _.util.clone(_.languages[id]);
|
86 |
|
87 | for (var key in redef) {
|
88 | lang[key] = redef[key];
|
89 | }
|
90 |
|
91 | return lang;
|
92 | },
|
93 |
|
94 | |
95 |
|
96 |
|
97 |
|
98 |
|
99 |
|
100 |
|
101 |
|
102 |
|
103 | insertBefore: function (inside, before, insert, root) {
|
104 | root = root || _.languages;
|
105 | var grammar = root[inside];
|
106 |
|
107 | if (arguments.length == 2) {
|
108 | insert = arguments[1];
|
109 |
|
110 | for (var newToken in insert) {
|
111 | if (insert.hasOwnProperty(newToken)) {
|
112 | grammar[newToken] = insert[newToken];
|
113 | }
|
114 | }
|
115 |
|
116 | return grammar;
|
117 | }
|
118 |
|
119 | var ret = {};
|
120 |
|
121 | for (var token in grammar) {
|
122 | if (grammar.hasOwnProperty(token)) {
|
123 | if (token == before) {
|
124 | for (var newToken in insert) {
|
125 | if (insert.hasOwnProperty(newToken)) {
|
126 | ret[newToken] = insert[newToken];
|
127 | }
|
128 | }
|
129 | }
|
130 |
|
131 | ret[token] = grammar[token];
|
132 | }
|
133 | }
|
134 |
|
135 |
|
136 | _.languages.DFS(_.languages, function (key, value) {
|
137 | if (value === root[inside] && key != inside) {
|
138 | this[key] = ret;
|
139 | }
|
140 | });
|
141 |
|
142 | return root[inside] = ret;
|
143 | },
|
144 |
|
145 | DFS: function (o, callback, type, visited) {
|
146 | visited = visited || {};
|
147 |
|
148 | for (var i in o) {
|
149 | if (o.hasOwnProperty(i)) {
|
150 | callback.call(o, i, o[i], type || i);
|
151 |
|
152 | if (_.util.type(o[i]) === "Object" && !visited[_.util.objId(o[i])]) {
|
153 | visited[_.util.objId(o[i])] = true;
|
154 |
|
155 | _.languages.DFS(o[i], callback, null, visited);
|
156 | } else if (_.util.type(o[i]) === "Array" && !visited[_.util.objId(o[i])]) {
|
157 | visited[_.util.objId(o[i])] = true;
|
158 |
|
159 | _.languages.DFS(o[i], callback, i, visited);
|
160 | }
|
161 | }
|
162 | }
|
163 | }
|
164 | },
|
165 | plugins: {},
|
166 | highlight: function (text, grammar, language) {
|
167 | var env = {
|
168 | code: text,
|
169 | grammar: grammar,
|
170 | language: language
|
171 | };
|
172 | env.tokens = _.tokenize(env.code, env.grammar);
|
173 | return Token.stringify(_.util.encode(env.tokens), env.language);
|
174 | },
|
175 | matchGrammar: function (text, strarr, grammar, index, startPos, oneshot, target) {
|
176 | var Token = _.Token;
|
177 |
|
178 | for (var token in grammar) {
|
179 | if (!grammar.hasOwnProperty(token) || !grammar[token]) {
|
180 | continue;
|
181 | }
|
182 |
|
183 | if (token == target) {
|
184 | return;
|
185 | }
|
186 |
|
187 | var patterns = grammar[token];
|
188 | patterns = _.util.type(patterns) === "Array" ? patterns : [patterns];
|
189 |
|
190 | for (var j = 0; j < patterns.length; ++j) {
|
191 | var pattern = patterns[j],
|
192 | inside = pattern.inside,
|
193 | lookbehind = !!pattern.lookbehind,
|
194 | greedy = !!pattern.greedy,
|
195 | lookbehindLength = 0,
|
196 | alias = pattern.alias;
|
197 |
|
198 | if (greedy && !pattern.pattern.global) {
|
199 |
|
200 | var flags = pattern.pattern.toString().match(/[imuy]*$/)[0];
|
201 | pattern.pattern = RegExp(pattern.pattern.source, flags + "g");
|
202 | }
|
203 |
|
204 | pattern = pattern.pattern || pattern;
|
205 |
|
206 | for (var i = index, pos = startPos; i < strarr.length; pos += strarr[i].length, ++i) {
|
207 | var str = strarr[i];
|
208 |
|
209 | if (strarr.length > text.length) {
|
210 |
|
211 | return;
|
212 | }
|
213 |
|
214 | if (str instanceof Token) {
|
215 | continue;
|
216 | }
|
217 |
|
218 | if (greedy && i != strarr.length - 1) {
|
219 | pattern.lastIndex = pos;
|
220 | var match = pattern.exec(text);
|
221 |
|
222 | if (!match) {
|
223 | break;
|
224 | }
|
225 |
|
226 | var from = match.index + (lookbehind ? match[1].length : 0),
|
227 | to = match.index + match[0].length,
|
228 | k = i,
|
229 | p = pos;
|
230 |
|
231 | for (var len = strarr.length; k < len && (p < to || !strarr[k].type && !strarr[k - 1].greedy); ++k) {
|
232 | p += strarr[k].length;
|
233 |
|
234 | if (from >= p) {
|
235 | ++i;
|
236 | pos = p;
|
237 | }
|
238 | }
|
239 |
|
240 |
|
241 | if (strarr[i] instanceof Token) {
|
242 | continue;
|
243 | }
|
244 |
|
245 |
|
246 | delNum = k - i;
|
247 | str = text.slice(pos, p);
|
248 | match.index -= pos;
|
249 | } else {
|
250 | pattern.lastIndex = 0;
|
251 | var match = pattern.exec(str),
|
252 | delNum = 1;
|
253 | }
|
254 |
|
255 | if (!match) {
|
256 | if (oneshot) {
|
257 | break;
|
258 | }
|
259 |
|
260 | continue;
|
261 | }
|
262 |
|
263 | if (lookbehind) {
|
264 | lookbehindLength = match[1] ? match[1].length : 0;
|
265 | }
|
266 |
|
267 | var from = match.index + lookbehindLength,
|
268 | match = match[0].slice(lookbehindLength),
|
269 | to = from + match.length,
|
270 | before = str.slice(0, from),
|
271 | after = str.slice(to);
|
272 | var args = [i, delNum];
|
273 |
|
274 | if (before) {
|
275 | ++i;
|
276 | pos += before.length;
|
277 | args.push(before);
|
278 | }
|
279 |
|
280 | var wrapped = new Token(token, inside ? _.tokenize(match, inside) : match, alias, match, greedy);
|
281 | args.push(wrapped);
|
282 |
|
283 | if (after) {
|
284 | args.push(after);
|
285 | }
|
286 |
|
287 | Array.prototype.splice.apply(strarr, args);
|
288 |
|
289 | if (delNum != 1) {
|
290 | _.matchGrammar(text, strarr, grammar, i, pos, true, token);
|
291 | }
|
292 |
|
293 | if (oneshot) {
|
294 | break;
|
295 | }
|
296 | }
|
297 | }
|
298 | }
|
299 | },
|
300 | hooks: {
|
301 | add: function () {}
|
302 | },
|
303 | tokenize: function (text, grammar, language) {
|
304 | var strarr = [text];
|
305 | var rest = grammar.rest;
|
306 |
|
307 | if (rest) {
|
308 | for (var token in rest) {
|
309 | grammar[token] = rest[token];
|
310 | }
|
311 |
|
312 | delete grammar.rest;
|
313 | }
|
314 |
|
315 | _.matchGrammar(text, strarr, grammar, 0, 0, false);
|
316 |
|
317 | return strarr;
|
318 | }
|
319 | };
|
320 |
|
321 | var Token = _.Token = function (type, content, alias, matchedStr, greedy) {
|
322 | this.type = type;
|
323 | this.content = content;
|
324 | this.alias = alias;
|
325 |
|
326 | this.length = (matchedStr || "").length | 0;
|
327 | this.greedy = !!greedy;
|
328 | };
|
329 |
|
330 | Token.stringify = function (o, language, parent) {
|
331 | if (typeof o == "string") {
|
332 | return o;
|
333 | }
|
334 |
|
335 | if (_.util.type(o) === "Array") {
|
336 | return o.map(function (element) {
|
337 | return Token.stringify(element, language, o);
|
338 | }).join("");
|
339 | }
|
340 |
|
341 | var env = {
|
342 | type: o.type,
|
343 | content: Token.stringify(o.content, language, parent),
|
344 | tag: "span",
|
345 | classes: ["token", o.type],
|
346 | attributes: {},
|
347 | language: language,
|
348 | parent: parent
|
349 | };
|
350 |
|
351 | if (o.alias) {
|
352 | var aliases = _.util.type(o.alias) === "Array" ? o.alias : [o.alias];
|
353 | Array.prototype.push.apply(env.classes, aliases);
|
354 | }
|
355 |
|
356 | var attributes = Object.keys(env.attributes).map(function (name) {
|
357 | return name + '="' + (env.attributes[name] || "").replace(/"/g, """) + '"';
|
358 | }).join(" ");
|
359 | return "<" + env.tag + ' class="' + env.classes.join(" ") + '"' + (attributes ? " " + attributes : "") + ">" + env.content + "</" + env.tag + ">";
|
360 | };
|
361 |
|
362 | return _;
|
363 | }();
|
364 |
|
365 |
|
366 |
|
367 |
|
368 |
|
369 | Prism.languages.markup = {
|
370 | 'comment': /<!--[\s\S]*?-->/,
|
371 | 'prolog': /<\?[\s\S]+?\?>/,
|
372 | 'doctype': /<!DOCTYPE[\s\S]+?>/i,
|
373 | 'cdata': /<!\[CDATA\[[\s\S]*?]]>/i,
|
374 | 'tag': {
|
375 | pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/i,
|
376 | greedy: true,
|
377 | inside: {
|
378 | 'tag': {
|
379 | pattern: /^<\/?[^\s>\/]+/i,
|
380 | inside: {
|
381 | 'punctuation': /^<\/?/,
|
382 | 'namespace': /^[^\s>\/:]+:/
|
383 | }
|
384 | },
|
385 | 'attr-value': {
|
386 | pattern: /=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/i,
|
387 | inside: {
|
388 | 'punctuation': [/^=/, {
|
389 | pattern: /^(\s*)["']|["']$/,
|
390 | lookbehind: true
|
391 | }]
|
392 | }
|
393 | },
|
394 | 'punctuation': /\/?>/,
|
395 | 'attr-name': {
|
396 | pattern: /[^\s>\/]+/,
|
397 | inside: {
|
398 | 'namespace': /^[^\s>\/:]+:/
|
399 | }
|
400 | }
|
401 | }
|
402 | },
|
403 | 'entity': /&#?[\da-z]{1,8};/i
|
404 | };
|
405 | Prism.languages.markup['tag'].inside['attr-value'].inside['entity'] = Prism.languages.markup['entity'];
|
406 |
|
407 | Prism.hooks.add('wrap', function (env) {
|
408 | if (env.type === 'entity') {
|
409 | env.attributes['title'] = env.content.replace(/&/, '&');
|
410 | }
|
411 | });
|
412 | Object.defineProperty(Prism.languages.markup.tag, 'addInlined', {
|
413 | |
414 |
|
415 |
|
416 |
|
417 |
|
418 |
|
419 |
|
420 |
|
421 |
|
422 |
|
423 |
|
424 | value: function addInlined(tagName, lang) {
|
425 | var includedCdataInside = {};
|
426 | includedCdataInside['language-' + lang] = {
|
427 | pattern: /(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,
|
428 | lookbehind: true,
|
429 | inside: Prism.languages[lang]
|
430 | };
|
431 | includedCdataInside['cdata'] = /^<!\[CDATA\[|\]\]>$/i;
|
432 | var inside = {
|
433 | 'included-cdata': {
|
434 | pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
|
435 | inside: includedCdataInside
|
436 | }
|
437 | };
|
438 | inside['language-' + lang] = {
|
439 | pattern: /[\s\S]+/,
|
440 | inside: Prism.languages[lang]
|
441 | };
|
442 | var def = {};
|
443 | def[tagName] = {
|
444 | pattern: RegExp(/(<__[\s\S]*?>)(?:<!\[CDATA\[[\s\S]*?\]\]>\s*|[\s\S])*?(?=<\/__>)/.source.replace(/__/g, tagName), 'i'),
|
445 | lookbehind: true,
|
446 | greedy: true,
|
447 | inside: inside
|
448 | };
|
449 | Prism.languages.insertBefore('markup', 'cdata', def);
|
450 | }
|
451 | });
|
452 | Prism.languages.xml = Prism.languages.extend('markup', {});
|
453 | Prism.languages.html = Prism.languages.markup;
|
454 | Prism.languages.mathml = Prism.languages.markup;
|
455 | Prism.languages.svg = Prism.languages.markup;
|
456 |
|
457 |
|
458 | (function (Prism) {
|
459 |
|
460 |
|
461 |
|
462 |
|
463 | 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';
|
464 | var insideString = {
|
465 | 'environment': {
|
466 | pattern: RegExp("\\$" + envVars),
|
467 | alias: 'constant'
|
468 | },
|
469 | 'variable': [
|
470 | {
|
471 | pattern: /\$?\(\([\s\S]+?\)\)/,
|
472 | greedy: true,
|
473 | inside: {
|
474 |
|
475 | 'variable': [{
|
476 | pattern: /(^\$\(\([\s\S]+)\)\)/,
|
477 | lookbehind: true
|
478 | }, /^\$\(\(/],
|
479 | 'number': /\b0x[\dA-Fa-f]+\b|(?:\b\d+\.?\d*|\B\.\d+)(?:[Ee]-?\d+)?/,
|
480 |
|
481 | 'operator': /--?|-=|\+\+?|\+=|!=?|~|\*\*?|\*=|\/=?|%=?|<<=?|>>=?|<=?|>=?|==?|&&?|&=|\^=?|\|\|?|\|=|\?|:/,
|
482 |
|
483 | 'punctuation': /\(\(?|\)\)?|,|;/
|
484 | }
|
485 | },
|
486 | {
|
487 | pattern: /\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,
|
488 | greedy: true,
|
489 | inside: {
|
490 | 'variable': /^\$\(|^`|\)$|`$/
|
491 | }
|
492 | },
|
493 | {
|
494 | pattern: /\$\{[^}]+\}/,
|
495 | greedy: true,
|
496 | inside: {
|
497 | 'operator': /:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,
|
498 | 'punctuation': /[\[\]]/,
|
499 | 'environment': {
|
500 | pattern: RegExp("(\\{)" + envVars),
|
501 | lookbehind: true,
|
502 | alias: 'constant'
|
503 | }
|
504 | }
|
505 | }, /\$(?:\w+|[#?*!@$])/],
|
506 |
|
507 | '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})/
|
508 | };
|
509 | Prism.languages.bash = {
|
510 | 'shebang': {
|
511 | pattern: /^#!\s*\/.*/,
|
512 | alias: 'important'
|
513 | },
|
514 | 'comment': {
|
515 | pattern: /(^|[^"{\\$])#.*/,
|
516 | lookbehind: true
|
517 | },
|
518 | 'function-name': [
|
519 |
|
520 |
|
521 |
|
522 | {
|
523 |
|
524 | pattern: /(\bfunction\s+)\w+(?=(?:\s*\(?:\s*\))?\s*\{)/,
|
525 | lookbehind: true,
|
526 | alias: 'function'
|
527 | }, {
|
528 |
|
529 | pattern: /\b\w+(?=\s*\(\s*\)\s*\{)/,
|
530 | alias: 'function'
|
531 | }],
|
532 |
|
533 | 'for-or-select': {
|
534 | pattern: /(\b(?:for|select)\s+)\w+(?=\s+in\s)/,
|
535 | alias: 'variable',
|
536 | lookbehind: true
|
537 | },
|
538 |
|
539 |
|
540 | 'assign-left': {
|
541 | pattern: /(^|[\s;|&]|[<>]\()\w+(?=\+?=)/,
|
542 | inside: {
|
543 | 'environment': {
|
544 | pattern: RegExp("(^|[\\s;|&]|[<>]\\()" + envVars),
|
545 | lookbehind: true,
|
546 | alias: 'constant'
|
547 | }
|
548 | },
|
549 | alias: 'variable',
|
550 | lookbehind: true
|
551 | },
|
552 | 'string': [
|
553 | {
|
554 | pattern: /((?:^|[^<])<<-?\s*)(\w+?)\s*(?:\r?\n|\r)(?:[\s\S])*?(?:\r?\n|\r)\2/,
|
555 | lookbehind: true,
|
556 | greedy: true,
|
557 | inside: insideString
|
558 | },
|
559 |
|
560 | {
|
561 | pattern: /((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s*(?:\r?\n|\r)(?:[\s\S])*?(?:\r?\n|\r)\3/,
|
562 | lookbehind: true,
|
563 | greedy: true
|
564 | },
|
565 | {
|
566 | pattern: /(["'])(?:\\[\s\S]|\$\([^)]+\)|`[^`]+`|(?!\1)[^\\])*\1/,
|
567 | greedy: true,
|
568 | inside: insideString
|
569 | }],
|
570 | 'environment': {
|
571 | pattern: RegExp("\\$?" + envVars),
|
572 | alias: 'constant'
|
573 | },
|
574 | 'variable': insideString.variable,
|
575 | 'function': {
|
576 | 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;|&])/,
|
577 | lookbehind: true
|
578 | },
|
579 | 'keyword': {
|
580 | pattern: /(^|[\s;|&]|[<>]\()(?:if|then|else|elif|fi|for|while|in|case|esac|function|select|do|done|until)(?=$|[)\s;|&])/,
|
581 | lookbehind: true
|
582 | },
|
583 |
|
584 | 'builtin': {
|
585 | 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;|&])/,
|
586 | lookbehind: true,
|
587 |
|
588 | alias: 'class-name'
|
589 | },
|
590 | 'boolean': {
|
591 | pattern: /(^|[\s;|&]|[<>]\()(?:true|false)(?=$|[)\s;|&])/,
|
592 | lookbehind: true
|
593 | },
|
594 | 'file-descriptor': {
|
595 | pattern: /\B&\d\b/,
|
596 | alias: 'important'
|
597 | },
|
598 | 'operator': {
|
599 |
|
600 | pattern: /\d?<>|>\||\+=|==?|!=?|=~|<<[<-]?|[&\d]?>>|\d?[<>]&?|&[>&]?|\|[&|]?|<=?|>=?/,
|
601 | inside: {
|
602 | 'file-descriptor': {
|
603 | pattern: /^\d/,
|
604 | alias: 'important'
|
605 | }
|
606 | }
|
607 | },
|
608 | 'punctuation': /\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,
|
609 | 'number': {
|
610 | pattern: /(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,
|
611 | lookbehind: true
|
612 | }
|
613 | };
|
614 |
|
615 |
|
616 | var toBeCopied = ['comment', 'function-name', 'for-or-select', 'assign-left', 'string', 'environment', 'function', 'keyword', 'builtin', 'boolean', 'file-descriptor', 'operator', 'punctuation', 'number'];
|
617 | var inside = insideString.variable[1].inside;
|
618 |
|
619 | for (var i = 0; i < toBeCopied.length; i++) {
|
620 | inside[toBeCopied[i]] = Prism.languages.bash[toBeCopied[i]];
|
621 | }
|
622 |
|
623 | Prism.languages.shell = Prism.languages.bash;
|
624 | })(Prism);
|
625 |
|
626 |
|
627 |
|
628 | Prism.languages.clike = {
|
629 | 'comment': [{
|
630 | pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
|
631 | lookbehind: true
|
632 | }, {
|
633 | pattern: /(^|[^\\:])\/\/.*/,
|
634 | lookbehind: true,
|
635 | greedy: true
|
636 | }],
|
637 | 'string': {
|
638 | pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
|
639 | greedy: true
|
640 | },
|
641 | 'class-name': {
|
642 | pattern: /((?:\b(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[\w.\\]+/i,
|
643 | lookbehind: true,
|
644 | inside: {
|
645 | punctuation: /[.\\]/
|
646 | }
|
647 | },
|
648 | 'keyword': /\b(?:if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,
|
649 | 'boolean': /\b(?:true|false)\b/,
|
650 | 'function': /\w+(?=\()/,
|
651 | 'number': /\b0x[\da-f]+\b|(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?/i,
|
652 | 'operator': /--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*|\/|~|\^|%/,
|
653 | 'punctuation': /[{}[\];(),.:]/
|
654 | };
|
655 |
|
656 |
|
657 | Prism.languages.c = Prism.languages.extend('clike', {
|
658 | 'class-name': {
|
659 | pattern: /(\b(?:enum|struct)\s+)\w+/,
|
660 | lookbehind: true
|
661 | },
|
662 | '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/,
|
663 | 'operator': />>=?|<<=?|->|([-+&|:])\1|[?:~]|[-+*/%&|^!=<>]=?/,
|
664 | 'number': /(?:\b0x(?:[\da-f]+\.?[\da-f]*|\.[\da-f]+)(?:p[+-]?\d+)?|(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?)[ful]*/i
|
665 | });
|
666 | Prism.languages.insertBefore('c', 'string', {
|
667 | 'macro': {
|
668 |
|
669 |
|
670 | pattern: /(^\s*)#\s*[a-z]+(?:[^\r\n\\]|\\(?:\r\n|[\s\S]))*/im,
|
671 | lookbehind: true,
|
672 | alias: 'property',
|
673 | inside: {
|
674 |
|
675 | 'string': {
|
676 | pattern: /(#\s*include\s*)(?:<.+?>|("|')(?:\\?.)+?\2)/,
|
677 | lookbehind: true
|
678 | },
|
679 |
|
680 | 'directive': {
|
681 | pattern: /(#\s*)\b(?:define|defined|elif|else|endif|error|ifdef|ifndef|if|import|include|line|pragma|undef|using)\b/,
|
682 | lookbehind: true,
|
683 | alias: 'keyword'
|
684 | }
|
685 | }
|
686 | },
|
687 |
|
688 | 'constant': /\b(?:__FILE__|__LINE__|__DATE__|__TIME__|__TIMESTAMP__|__func__|EOF|NULL|SEEK_CUR|SEEK_END|SEEK_SET|stdin|stdout|stderr)\b/
|
689 | });
|
690 | delete Prism.languages.c['boolean'];
|
691 |
|
692 |
|
693 | Prism.languages.cpp = Prism.languages.extend('c', {
|
694 | 'class-name': {
|
695 | pattern: /(\b(?:class|enum|struct)\s+)\w+/,
|
696 | lookbehind: true
|
697 | },
|
698 | '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/,
|
699 | 'number': {
|
700 | pattern: /(?:\b0b[01']+|\b0x(?:[\da-f']+\.?[\da-f']*|\.[\da-f']+)(?:p[+-]?[\d']+)?|(?:\b[\d']+\.?[\d']*|\B\.[\d']+)(?:e[+-]?[\d']+)?)[ful]*/i,
|
701 | greedy: true
|
702 | },
|
703 | 'operator': />>=?|<<=?|->|([-+&|:])\1|[?:~]|[-+*/%&|^!=<>]=?|\b(?:and|and_eq|bitand|bitor|not|not_eq|or|or_eq|xor|xor_eq)\b/,
|
704 | 'boolean': /\b(?:true|false)\b/
|
705 | });
|
706 | Prism.languages.insertBefore('cpp', 'string', {
|
707 | 'raw-string': {
|
708 | pattern: /R"([^()\\ ]{0,16})\([\s\S]*?\)\1"/,
|
709 | alias: 'string',
|
710 | greedy: true
|
711 | }
|
712 | });
|
713 |
|
714 |
|
715 | (function (Prism) {
|
716 | var string = /("|')(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/;
|
717 | Prism.languages.css = {
|
718 | 'comment': /\/\*[\s\S]*?\*\//,
|
719 | 'atrule': {
|
720 | pattern: /@[\w-]+[\s\S]*?(?:;|(?=\s*\{))/,
|
721 | inside: {
|
722 | 'rule': /@[\w-]+/
|
723 |
|
724 | }
|
725 | },
|
726 | 'url': {
|
727 | pattern: RegExp('url\\((?:' + string.source + '|[^\n\r()]*)\\)', 'i'),
|
728 | inside: {
|
729 | 'function': /^url/i,
|
730 | 'punctuation': /^\(|\)$/
|
731 | }
|
732 | },
|
733 | 'selector': RegExp('[^{}\\s](?:[^{};"\']|' + string.source + ')*?(?=\\s*\\{)'),
|
734 | 'string': {
|
735 | pattern: string,
|
736 | greedy: true
|
737 | },
|
738 | 'property': /[-_a-z\xA0-\uFFFF][-\w\xA0-\uFFFF]*(?=\s*:)/i,
|
739 | 'important': /!important\b/i,
|
740 | 'function': /[-a-z0-9]+(?=\()/i,
|
741 | 'punctuation': /[(){};:,]/
|
742 | };
|
743 | Prism.languages.css['atrule'].inside.rest = Prism.languages.css;
|
744 | var markup = Prism.languages.markup;
|
745 |
|
746 | if (markup) {
|
747 | markup.tag.addInlined('style', 'css');
|
748 | Prism.languages.insertBefore('inside', 'attr-value', {
|
749 | 'style-attr': {
|
750 | pattern: /\s*style=("|')(?:\\[\s\S]|(?!\1)[^\\])*\1/i,
|
751 | inside: {
|
752 | 'attr-name': {
|
753 | pattern: /^\s*style/i,
|
754 | inside: markup.tag.inside
|
755 | },
|
756 | 'punctuation': /^\s*=\s*['"]|['"]\s*$/,
|
757 | 'attr-value': {
|
758 | pattern: /.+/i,
|
759 | inside: Prism.languages.css
|
760 | }
|
761 | },
|
762 | alias: 'language-css'
|
763 | }
|
764 | }, markup.tag);
|
765 | }
|
766 | })(Prism);
|
767 |
|
768 |
|
769 |
|
770 | Prism.languages.css.selector = {
|
771 | pattern: Prism.languages.css.selector,
|
772 | inside: {
|
773 | 'pseudo-element': /:(?:after|before|first-letter|first-line|selection)|::[-\w]+/,
|
774 | 'pseudo-class': /:[-\w]+/,
|
775 | 'class': /\.[-:.\w]+/,
|
776 | 'id': /#[-:.\w]+/,
|
777 | 'attribute': {
|
778 | pattern: /\[(?:[^[\]"']|("|')(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1)*\]/,
|
779 | greedy: true,
|
780 | inside: {
|
781 | 'punctuation': /^\[|\]$/,
|
782 | 'case-sensitivity': {
|
783 | pattern: /(\s)[si]$/i,
|
784 | lookbehind: true,
|
785 | alias: 'keyword'
|
786 | },
|
787 | 'namespace': {
|
788 | pattern: /^(\s*)[-*\w\xA0-\uFFFF]*\|(?!=)/,
|
789 | lookbehind: true,
|
790 | inside: {
|
791 | 'punctuation': /\|$/
|
792 | }
|
793 | },
|
794 | 'attribute': {
|
795 | pattern: /^(\s*)[-\w\xA0-\uFFFF]+/,
|
796 | lookbehind: true
|
797 | },
|
798 | 'value': [/("|')(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/, {
|
799 | pattern: /(=\s*)[-\w\xA0-\uFFFF]+(?=\s*$)/,
|
800 | lookbehind: true
|
801 | }],
|
802 | 'operator': /[|~*^$]?=/
|
803 | }
|
804 | },
|
805 | 'n-th': [{
|
806 | pattern: /(\(\s*)[+-]?\d*[\dn](?:\s*[+-]\s*\d+)?(?=\s*\))/,
|
807 | lookbehind: true,
|
808 | inside: {
|
809 | 'number': /[\dn]+/,
|
810 | 'operator': /[+-]/
|
811 | }
|
812 | }, {
|
813 | pattern: /(\(\s*)(?:even|odd)(?=\s*\))/i,
|
814 | lookbehind: true
|
815 | }],
|
816 | 'punctuation': /[()]/
|
817 | }
|
818 | };
|
819 | Prism.languages.insertBefore('css', 'property', {
|
820 | 'variable': {
|
821 | pattern: /(^|[^-\w\xA0-\uFFFF])--[-_a-z\xA0-\uFFFF][-\w\xA0-\uFFFF]*/i,
|
822 | lookbehind: true
|
823 | }
|
824 | });
|
825 | Prism.languages.insertBefore('css', 'function', {
|
826 | 'operator': {
|
827 | pattern: /(\s)[+\-*\/](?=\s)/,
|
828 | lookbehind: true
|
829 | },
|
830 | 'hexcode': /#[\da-f]{3,8}/i,
|
831 | 'entity': /\\[\da-f]{1,8}/i,
|
832 | 'unit': {
|
833 | pattern: /(\d)(?:%|[a-z]+)/,
|
834 | lookbehind: true
|
835 | },
|
836 | 'number': /-?[\d.]+/
|
837 | });
|
838 |
|
839 |
|
840 | Prism.languages.javascript = Prism.languages.extend('clike', {
|
841 | 'class-name': [Prism.languages.clike['class-name'], {
|
842 | pattern: /(^|[^$\w\xA0-\uFFFF])[_$A-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\.(?:prototype|constructor))/,
|
843 | lookbehind: true
|
844 | }],
|
845 | 'keyword': [{
|
846 | pattern: /((?:^|})\s*)(?:catch|finally)\b/,
|
847 | lookbehind: true
|
848 | }, {
|
849 | 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/,
|
850 | lookbehind: true
|
851 | }],
|
852 | '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)?)+)?/,
|
853 |
|
854 | 'function': /#?[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,
|
855 | 'operator': /-[-=]?|\+[+=]?|!=?=?|<<?=?|>>?>?=?|=(?:==?|>)?|&[&=]?|\|[|=]?|\*\*?=?|\/=?|~|\^=?|%=?|\?|\.{3}/
|
856 | });
|
857 | Prism.languages.javascript['class-name'][0].pattern = /(\b(?:class|interface|extends|implements|instanceof|new)\s+)[\w.\\]+/;
|
858 | Prism.languages.insertBefore('javascript', 'keyword', {
|
859 | 'regex': {
|
860 | pattern: /((?:^|[^$\w\xA0-\uFFFF."'\])\s])\s*)\/(\[(?:[^\]\\\r\n]|\\.)*]|\\.|[^/\\\[\r\n])+\/[gimyus]{0,6}(?=\s*($|[\r\n,.;})\]]))/,
|
861 | lookbehind: true,
|
862 | greedy: true
|
863 | },
|
864 |
|
865 | 'function-variable': {
|
866 | pattern: /#?[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)\s*=>))/,
|
867 | alias: 'function'
|
868 | },
|
869 | 'parameter': [{
|
870 | pattern: /(function(?:\s+[_$A-Za-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)?\s*\(\s*)(?!\s)(?:[^()]|\([^()]*\))+?(?=\s*\))/,
|
871 | lookbehind: true,
|
872 | inside: Prism.languages.javascript
|
873 | }, {
|
874 | pattern: /[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*=>)/i,
|
875 | inside: Prism.languages.javascript
|
876 | }, {
|
877 | pattern: /(\(\s*)(?!\s)(?:[^()]|\([^()]*\))+?(?=\s*\)\s*=>)/,
|
878 | lookbehind: true,
|
879 | inside: Prism.languages.javascript
|
880 | }, {
|
881 | 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*\{)/,
|
882 | lookbehind: true,
|
883 | inside: Prism.languages.javascript
|
884 | }],
|
885 | 'constant': /\b[A-Z](?:[A-Z_]|\dx?)*\b/
|
886 | });
|
887 | Prism.languages.insertBefore('javascript', 'string', {
|
888 | 'template-string': {
|
889 | pattern: /`(?:\\[\s\S]|\${(?:[^{}]|{(?:[^{}]|{[^}]*})*})+}|(?!\${)[^\\`])*`/,
|
890 | greedy: true,
|
891 | inside: {
|
892 | 'template-punctuation': {
|
893 | pattern: /^`|`$/,
|
894 | alias: 'string'
|
895 | },
|
896 | 'interpolation': {
|
897 | pattern: /((?:^|[^\\])(?:\\{2})*)\${(?:[^{}]|{(?:[^{}]|{[^}]*})*})+}/,
|
898 | lookbehind: true,
|
899 | inside: {
|
900 | 'interpolation-punctuation': {
|
901 | pattern: /^\${|}$/,
|
902 | alias: 'punctuation'
|
903 | },
|
904 | rest: Prism.languages.javascript
|
905 | }
|
906 | },
|
907 | 'string': /[\s\S]+/
|
908 | }
|
909 | }
|
910 | });
|
911 |
|
912 | if (Prism.languages.markup) {
|
913 | Prism.languages.markup.tag.addInlined('script', 'javascript');
|
914 | }
|
915 |
|
916 | Prism.languages.js = Prism.languages.javascript;
|
917 |
|
918 |
|
919 | (function (Prism) {
|
920 | var javascript = Prism.util.clone(Prism.languages.javascript);
|
921 | Prism.languages.jsx = Prism.languages.extend('markup', javascript);
|
922 | Prism.languages.jsx.tag.pattern = /<\/?(?:[\w.:-]+\s*(?:\s+(?:[\w.:-]+(?:=(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s{'">=]+|\{(?:\{(?:\{[^}]*\}|[^{}])*\}|[^{}])+\}))?|\{\.{3}[a-z_$][\w$]*(?:\.[a-z_$][\w$]*)*\}))*\s*\/?)?>/i;
|
923 | Prism.languages.jsx.tag.inside['tag'].pattern = /^<\/?[^\s>\/]*/i;
|
924 | Prism.languages.jsx.tag.inside['attr-value'].pattern = /=(?!\{)(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s'">]+)/i;
|
925 | Prism.languages.jsx.tag.inside['tag'].inside['class-name'] = /^[A-Z]\w*(?:\.[A-Z]\w*)*$/;
|
926 | Prism.languages.insertBefore('inside', 'attr-name', {
|
927 | 'spread': {
|
928 | pattern: /\{\.{3}[a-z_$][\w$]*(?:\.[a-z_$][\w$]*)*\}/,
|
929 | inside: {
|
930 | 'punctuation': /\.{3}|[{}.]/,
|
931 | 'attr-value': /\w+/
|
932 | }
|
933 | }
|
934 | }, Prism.languages.jsx.tag);
|
935 | Prism.languages.insertBefore('inside', 'attr-value', {
|
936 | 'script': {
|
937 |
|
938 | pattern: /=(\{(?:\{(?:\{[^}]*\}|[^}])*\}|[^}])+\})/i,
|
939 | inside: {
|
940 | 'script-punctuation': {
|
941 | pattern: /^=(?={)/,
|
942 | alias: 'punctuation'
|
943 | },
|
944 | rest: Prism.languages.jsx
|
945 | },
|
946 | 'alias': 'language-javascript'
|
947 | }
|
948 | }, Prism.languages.jsx.tag);
|
949 |
|
950 | var stringifyToken = function (token) {
|
951 | if (!token) {
|
952 | return '';
|
953 | }
|
954 |
|
955 | if (typeof token === 'string') {
|
956 | return token;
|
957 | }
|
958 |
|
959 | if (typeof token.content === 'string') {
|
960 | return token.content;
|
961 | }
|
962 |
|
963 | return token.content.map(stringifyToken).join('');
|
964 | };
|
965 |
|
966 | var walkTokens = function (tokens) {
|
967 | var openedTags = [];
|
968 |
|
969 | for (var i = 0; i < tokens.length; i++) {
|
970 | var token = tokens[i];
|
971 | var notTagNorBrace = false;
|
972 |
|
973 | if (typeof token !== 'string') {
|
974 | if (token.type === 'tag' && token.content[0] && token.content[0].type === 'tag') {
|
975 |
|
976 | if (token.content[0].content[0].content === '</') {
|
977 |
|
978 | if (openedTags.length > 0 && openedTags[openedTags.length - 1].tagName === stringifyToken(token.content[0].content[1])) {
|
979 |
|
980 | openedTags.pop();
|
981 | }
|
982 | } else {
|
983 | if (token.content[token.content.length - 1].content === '/>') ; else {
|
984 |
|
985 | openedTags.push({
|
986 | tagName: stringifyToken(token.content[0].content[1]),
|
987 | openedBraces: 0
|
988 | });
|
989 | }
|
990 | }
|
991 | } else if (openedTags.length > 0 && token.type === 'punctuation' && token.content === '{') {
|
992 |
|
993 | openedTags[openedTags.length - 1].openedBraces++;
|
994 | } else if (openedTags.length > 0 && openedTags[openedTags.length - 1].openedBraces > 0 && token.type === 'punctuation' && token.content === '}') {
|
995 |
|
996 | openedTags[openedTags.length - 1].openedBraces--;
|
997 | } else {
|
998 | notTagNorBrace = true;
|
999 | }
|
1000 | }
|
1001 |
|
1002 | if (notTagNorBrace || typeof token === 'string') {
|
1003 | if (openedTags.length > 0 && openedTags[openedTags.length - 1].openedBraces === 0) {
|
1004 |
|
1005 |
|
1006 | var plainText = stringifyToken(token);
|
1007 |
|
1008 | if (i < tokens.length - 1 && (typeof tokens[i + 1] === 'string' || tokens[i + 1].type === 'plain-text')) {
|
1009 | plainText += stringifyToken(tokens[i + 1]);
|
1010 | tokens.splice(i + 1, 1);
|
1011 | }
|
1012 |
|
1013 | if (i > 0 && (typeof tokens[i - 1] === 'string' || tokens[i - 1].type === 'plain-text')) {
|
1014 | plainText = stringifyToken(tokens[i - 1]) + plainText;
|
1015 | tokens.splice(i - 1, 1);
|
1016 | i--;
|
1017 | }
|
1018 |
|
1019 | tokens[i] = new Prism.Token('plain-text', plainText, null, plainText);
|
1020 | }
|
1021 | }
|
1022 |
|
1023 | if (token.content && typeof token.content !== 'string') {
|
1024 | walkTokens(token.content);
|
1025 | }
|
1026 | }
|
1027 | };
|
1028 |
|
1029 | Prism.hooks.add('after-tokenize', function (env) {
|
1030 | if (env.language !== 'jsx' && env.language !== 'tsx') {
|
1031 | return;
|
1032 | }
|
1033 |
|
1034 | walkTokens(env.tokens);
|
1035 | });
|
1036 | })(Prism);
|
1037 |
|
1038 |
|
1039 |
|
1040 | (function (Prism) {
|
1041 | var javaDocLike = Prism.languages.javadoclike = {
|
1042 | 'parameter': {
|
1043 | pattern: /(^\s*(?:\/{3}|\*|\/\*\*)\s*@(?:param|arg|arguments)\s+)\w+/m,
|
1044 | lookbehind: true
|
1045 | },
|
1046 | 'keyword': {
|
1047 |
|
1048 |
|
1049 | pattern: /(^\s*(?:\/{3}|\*|\/\*\*)\s*|\{)@[a-z][a-zA-Z-]+\b/m,
|
1050 | lookbehind: true
|
1051 | },
|
1052 | 'punctuation': /[{}]/
|
1053 | };
|
1054 | |
1055 |
|
1056 |
|
1057 |
|
1058 |
|
1059 |
|
1060 |
|
1061 | function docCommentSupport(lang, callback) {
|
1062 | var tokenName = 'doc-comment';
|
1063 | var grammar = Prism.languages[lang];
|
1064 |
|
1065 | if (!grammar) {
|
1066 | return;
|
1067 | }
|
1068 |
|
1069 | var token = grammar[tokenName];
|
1070 |
|
1071 | if (!token) {
|
1072 |
|
1073 | var definition = {};
|
1074 | definition[tokenName] = {
|
1075 | pattern: /(^|[^\\])\/\*\*[^/][\s\S]*?(?:\*\/|$)/,
|
1076 | alias: 'comment'
|
1077 | };
|
1078 | grammar = Prism.languages.insertBefore(lang, 'comment', definition);
|
1079 | token = grammar[tokenName];
|
1080 | }
|
1081 |
|
1082 | if (token instanceof RegExp) {
|
1083 |
|
1084 | token = grammar[tokenName] = {
|
1085 | pattern: token
|
1086 | };
|
1087 | }
|
1088 |
|
1089 | if (Array.isArray(token)) {
|
1090 | for (var i = 0, l = token.length; i < l; i++) {
|
1091 | if (token[i] instanceof RegExp) {
|
1092 | token[i] = {
|
1093 | pattern: token[i]
|
1094 | };
|
1095 | }
|
1096 |
|
1097 | callback(token[i]);
|
1098 | }
|
1099 | } else {
|
1100 | callback(token);
|
1101 | }
|
1102 | }
|
1103 | |
1104 |
|
1105 |
|
1106 |
|
1107 |
|
1108 |
|
1109 |
|
1110 |
|
1111 | function addSupport(languages, docLanguage) {
|
1112 | if (typeof languages === 'string') {
|
1113 | languages = [languages];
|
1114 | }
|
1115 |
|
1116 | languages.forEach(function (lang) {
|
1117 | docCommentSupport(lang, function (pattern) {
|
1118 | if (!pattern.inside) {
|
1119 | pattern.inside = {};
|
1120 | }
|
1121 |
|
1122 | pattern.inside.rest = docLanguage;
|
1123 | });
|
1124 | });
|
1125 | }
|
1126 |
|
1127 | Object.defineProperty(javaDocLike, 'addSupport', {
|
1128 | value: addSupport
|
1129 | });
|
1130 | javaDocLike.addSupport(['java', 'javascript', 'php'], javaDocLike);
|
1131 | })(Prism);
|
1132 |
|
1133 |
|
1134 |
|
1135 | (function (Prism) {
|
1136 | 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/;
|
1137 |
|
1138 | var className = /\b[A-Z](?:\w*[a-z]\w*)?\b/;
|
1139 | Prism.languages.java = Prism.languages.extend('clike', {
|
1140 | 'class-name': [className,
|
1141 |
|
1142 | /\b[A-Z]\w*(?=\s+\w+\s*[;,=())])/],
|
1143 | 'keyword': keywords,
|
1144 | 'function': [Prism.languages.clike.function, {
|
1145 | pattern: /(\:\:)[a-z_]\w*/,
|
1146 | lookbehind: true
|
1147 | }],
|
1148 | '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,
|
1149 | 'operator': {
|
1150 | pattern: /(^|[^.])(?:<<=?|>>>?=?|->|([-+&|])\2|[?:~]|[-+*/%&|^!=<>]=?)/m,
|
1151 | lookbehind: true
|
1152 | }
|
1153 | });
|
1154 | Prism.languages.insertBefore('java', 'class-name', {
|
1155 | 'annotation': {
|
1156 | alias: 'punctuation',
|
1157 | pattern: /(^|[^.])@\w+/,
|
1158 | lookbehind: true
|
1159 | },
|
1160 | 'namespace': {
|
1161 | pattern: /(\b(?:exports|import(?:\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\s+)[a-z]\w*(\.[a-z]\w*)+/,
|
1162 | lookbehind: true,
|
1163 | inside: {
|
1164 | 'punctuation': /\./
|
1165 | }
|
1166 | },
|
1167 | 'generics': {
|
1168 | pattern: /<(?:[\w\s,.&?]|<(?:[\w\s,.&?]|<(?:[\w\s,.&?]|<[\w\s,.&?]*>)*>)*>)*>/,
|
1169 | inside: {
|
1170 | 'class-name': className,
|
1171 | 'keyword': keywords,
|
1172 | 'punctuation': /[<>(),.:]/,
|
1173 | 'operator': /[?&|]/
|
1174 | }
|
1175 | }
|
1176 | });
|
1177 | })(Prism);
|
1178 |
|
1179 |
|
1180 |
|
1181 | (function (Prism) {
|
1182 | |
1183 |
|
1184 |
|
1185 |
|
1186 |
|
1187 |
|
1188 |
|
1189 | function getPlaceholder(language, index) {
|
1190 | return '___' + language.toUpperCase() + index + '___';
|
1191 | }
|
1192 |
|
1193 | Object.defineProperties(Prism.languages['markup-templating'] = {}, {
|
1194 | buildPlaceholders: {
|
1195 | |
1196 |
|
1197 |
|
1198 |
|
1199 |
|
1200 |
|
1201 |
|
1202 |
|
1203 |
|
1204 |
|
1205 |
|
1206 | value: function (env, language, placeholderPattern, replaceFilter) {
|
1207 | if (env.language !== language) {
|
1208 | return;
|
1209 | }
|
1210 |
|
1211 | var tokenStack = env.tokenStack = [];
|
1212 | env.code = env.code.replace(placeholderPattern, function (match) {
|
1213 | if (typeof replaceFilter === 'function' && !replaceFilter(match)) {
|
1214 | return match;
|
1215 | }
|
1216 |
|
1217 | var i = tokenStack.length;
|
1218 | var placeholder;
|
1219 |
|
1220 | while (env.code.indexOf(placeholder = getPlaceholder(language, i)) !== -1) {
|
1221 | ++i;
|
1222 | }
|
1223 |
|
1224 |
|
1225 | tokenStack[i] = match;
|
1226 | return placeholder;
|
1227 | });
|
1228 |
|
1229 | env.grammar = Prism.languages.markup;
|
1230 | }
|
1231 | },
|
1232 | tokenizePlaceholders: {
|
1233 | |
1234 |
|
1235 |
|
1236 |
|
1237 |
|
1238 |
|
1239 | value: function (env, language) {
|
1240 | if (env.language !== language || !env.tokenStack) {
|
1241 | return;
|
1242 | }
|
1243 |
|
1244 |
|
1245 | env.grammar = Prism.languages[language];
|
1246 | var j = 0;
|
1247 | var keys = Object.keys(env.tokenStack);
|
1248 |
|
1249 | function walkTokens(tokens) {
|
1250 | for (var i = 0; i < tokens.length; i++) {
|
1251 |
|
1252 | if (j >= keys.length) {
|
1253 | break;
|
1254 | }
|
1255 |
|
1256 | var token = tokens[i];
|
1257 |
|
1258 | if (typeof token === 'string' || token.content && typeof token.content === 'string') {
|
1259 | var k = keys[j];
|
1260 | var t = env.tokenStack[k];
|
1261 | var s = typeof token === 'string' ? token : token.content;
|
1262 | var placeholder = getPlaceholder(language, k);
|
1263 | var index = s.indexOf(placeholder);
|
1264 |
|
1265 | if (index > -1) {
|
1266 | ++j;
|
1267 | var before = s.substring(0, index);
|
1268 | var middle = new Prism.Token(language, Prism.tokenize(t, env.grammar), 'language-' + language, t);
|
1269 | var after = s.substring(index + placeholder.length);
|
1270 | var replacement = [];
|
1271 |
|
1272 | if (before) {
|
1273 | replacement.push.apply(replacement, walkTokens([before]));
|
1274 | }
|
1275 |
|
1276 | replacement.push(middle);
|
1277 |
|
1278 | if (after) {
|
1279 | replacement.push.apply(replacement, walkTokens([after]));
|
1280 | }
|
1281 |
|
1282 | if (typeof token === 'string') {
|
1283 | tokens.splice.apply(tokens, [i, 1].concat(replacement));
|
1284 | } else {
|
1285 | token.content = replacement;
|
1286 | }
|
1287 | }
|
1288 | } else if (token.content
|
1289 |
|
1290 | ) {
|
1291 | walkTokens(token.content);
|
1292 | }
|
1293 | }
|
1294 |
|
1295 | return tokens;
|
1296 | }
|
1297 |
|
1298 | walkTokens(env.tokens);
|
1299 | }
|
1300 | }
|
1301 | });
|
1302 | })(Prism);
|
1303 |
|
1304 |
|
1305 |
|
1306 |
|
1307 |
|
1308 |
|
1309 |
|
1310 |
|
1311 |
|
1312 |
|
1313 |
|
1314 |
|
1315 |
|
1316 |
|
1317 |
|
1318 |
|
1319 | (function (Prism) {
|
1320 | Prism.languages.php = Prism.languages.extend('clike', {
|
1321 | '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,
|
1322 | 'boolean': {
|
1323 | pattern: /\b(?:false|true)\b/i,
|
1324 | alias: 'constant'
|
1325 | },
|
1326 | 'constant': [/\b[A-Z_][A-Z0-9_]*\b/, /\b(?:null)\b/i],
|
1327 | 'comment': {
|
1328 | pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|\/\/.*)/,
|
1329 | lookbehind: true
|
1330 | }
|
1331 | });
|
1332 | Prism.languages.insertBefore('php', 'string', {
|
1333 | 'shell-comment': {
|
1334 | pattern: /(^|[^\\])#.*/,
|
1335 | lookbehind: true,
|
1336 | alias: 'comment'
|
1337 | }
|
1338 | });
|
1339 | Prism.languages.insertBefore('php', 'comment', {
|
1340 | 'delimiter': {
|
1341 | pattern: /\?>$|^<\?(?:php(?=\s)|=)?/i,
|
1342 | alias: 'important'
|
1343 | }
|
1344 | });
|
1345 | Prism.languages.insertBefore('php', 'keyword', {
|
1346 | 'variable': /\$+(?:\w+\b|(?={))/i,
|
1347 | 'package': {
|
1348 | pattern: /(\\|namespace\s+|use\s+)[\w\\]+/,
|
1349 | lookbehind: true,
|
1350 | inside: {
|
1351 | punctuation: /\\/
|
1352 | }
|
1353 | }
|
1354 | });
|
1355 |
|
1356 | Prism.languages.insertBefore('php', 'operator', {
|
1357 | 'property': {
|
1358 | pattern: /(->)[\w]+/,
|
1359 | lookbehind: true
|
1360 | }
|
1361 | });
|
1362 | var string_interpolation = {
|
1363 | pattern: /{\$(?:{(?:{[^{}]+}|[^{}]+)}|[^{}])+}|(^|[^\\{])\$+(?:\w+(?:\[.+?]|->\w+)*)/,
|
1364 | lookbehind: true,
|
1365 | inside: {
|
1366 | rest: Prism.languages.php
|
1367 | }
|
1368 | };
|
1369 | Prism.languages.insertBefore('php', 'string', {
|
1370 | 'nowdoc-string': {
|
1371 | pattern: /<<<'([^']+)'(?:\r\n?|\n)(?:.*(?:\r\n?|\n))*?\1;/,
|
1372 | greedy: true,
|
1373 | alias: 'string',
|
1374 | inside: {
|
1375 | 'delimiter': {
|
1376 | pattern: /^<<<'[^']+'|[a-z_]\w*;$/i,
|
1377 | alias: 'symbol',
|
1378 | inside: {
|
1379 | 'punctuation': /^<<<'?|[';]$/
|
1380 | }
|
1381 | }
|
1382 | }
|
1383 | },
|
1384 | 'heredoc-string': {
|
1385 | pattern: /<<<(?:"([^"]+)"(?:\r\n?|\n)(?:.*(?:\r\n?|\n))*?\1;|([a-z_]\w*)(?:\r\n?|\n)(?:.*(?:\r\n?|\n))*?\2;)/i,
|
1386 | greedy: true,
|
1387 | alias: 'string',
|
1388 | inside: {
|
1389 | 'delimiter': {
|
1390 | pattern: /^<<<(?:"[^"]+"|[a-z_]\w*)|[a-z_]\w*;$/i,
|
1391 | alias: 'symbol',
|
1392 | inside: {
|
1393 | 'punctuation': /^<<<"?|[";]$/
|
1394 | }
|
1395 | },
|
1396 | 'interpolation': string_interpolation
|
1397 |
|
1398 | }
|
1399 | },
|
1400 | 'single-quoted-string': {
|
1401 | pattern: /'(?:\\[\s\S]|[^\\'])*'/,
|
1402 | greedy: true,
|
1403 | alias: 'string'
|
1404 | },
|
1405 | 'double-quoted-string': {
|
1406 | pattern: /"(?:\\[\s\S]|[^\\"])*"/,
|
1407 | greedy: true,
|
1408 | alias: 'string',
|
1409 | inside: {
|
1410 | 'interpolation': string_interpolation
|
1411 |
|
1412 | }
|
1413 | }
|
1414 | });
|
1415 |
|
1416 | delete Prism.languages.php['string'];
|
1417 | Prism.hooks.add('before-tokenize', function (env) {
|
1418 | if (!/<\?/.test(env.code)) {
|
1419 | return;
|
1420 | }
|
1421 |
|
1422 | var phpPattern = /<\?(?:[^"'/#]|\/(?![*/])|("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|(?:\/\/|#)(?:[^?\n\r]|\?(?!>))*|\/\*[\s\S]*?(?:\*\/|$))*?(?:\?>|$)/ig;
|
1423 | Prism.languages['markup-templating'].buildPlaceholders(env, 'php', phpPattern);
|
1424 | });
|
1425 | Prism.hooks.add('after-tokenize', function (env) {
|
1426 | Prism.languages['markup-templating'].tokenizePlaceholders(env, 'php');
|
1427 | });
|
1428 | })(Prism);
|
1429 |
|
1430 |
|
1431 |
|
1432 | (function (Prism) {
|
1433 | var javascript = Prism.languages.javascript;
|
1434 | var type = /{(?:[^{}]|{(?:[^{}]|{[^{}]*})*})+}/.source;
|
1435 | var parameterPrefix = '(@(?:param|arg|argument|property)\\s+(?:' + type + '\\s+)?)';
|
1436 | Prism.languages.jsdoc = Prism.languages.extend('javadoclike', {
|
1437 | 'parameter': {
|
1438 |
|
1439 | pattern: RegExp(parameterPrefix + /[$\w\xA0-\uFFFF.]+(?=\s|$)/.source),
|
1440 | lookbehind: true,
|
1441 | inside: {
|
1442 | 'punctuation': /\./
|
1443 | }
|
1444 | }
|
1445 | });
|
1446 | Prism.languages.insertBefore('jsdoc', 'keyword', {
|
1447 | 'optional-parameter': {
|
1448 |
|
1449 | pattern: RegExp(parameterPrefix + /\[[$\w\xA0-\uFFFF.]+(?:=[^[\]]+)?\](?=\s|$)/.source),
|
1450 | lookbehind: true,
|
1451 | inside: {
|
1452 | 'parameter': {
|
1453 | pattern: /(^\[)[$\w\xA0-\uFFFF\.]+/,
|
1454 | lookbehind: true,
|
1455 | inside: {
|
1456 | 'punctuation': /\./
|
1457 | }
|
1458 | },
|
1459 | 'code': {
|
1460 | pattern: /(=)[\s\S]*(?=\]$)/,
|
1461 | lookbehind: true,
|
1462 | inside: javascript,
|
1463 | alias: 'language-javascript'
|
1464 | },
|
1465 | 'punctuation': /[=[\]]/
|
1466 | }
|
1467 | },
|
1468 | 'class-name': [{
|
1469 | pattern: RegExp('(@[a-z]+\\s+)' + type),
|
1470 | lookbehind: true,
|
1471 | inside: {
|
1472 | 'punctuation': /[.,:?=<>|{}()[\]]/
|
1473 | }
|
1474 | }, {
|
1475 | pattern: /(@(?:augments|extends|class|interface|memberof!?|this)\s+)[A-Z]\w*(?:\.[A-Z]\w*)*/,
|
1476 | lookbehind: true,
|
1477 | inside: {
|
1478 | 'punctuation': /\./
|
1479 | }
|
1480 | }],
|
1481 | 'example': {
|
1482 | pattern: /(@example\s+)[^@]+?(?=\s*(?:\*\s*)?(?:@\w|\*\/))/,
|
1483 | lookbehind: true,
|
1484 | inside: {
|
1485 | 'code': {
|
1486 | pattern: /^(\s*(?:\*\s*)?).+$/m,
|
1487 | lookbehind: true,
|
1488 | inside: javascript,
|
1489 | alias: 'language-javascript'
|
1490 | }
|
1491 | }
|
1492 | }
|
1493 | });
|
1494 | Prism.languages.javadoclike.addSupport('javascript', Prism.languages.jsdoc);
|
1495 | })(Prism);
|
1496 |
|
1497 |
|
1498 |
|
1499 | Prism.languages.actionscript = Prism.languages.extend('javascript', {
|
1500 | '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/,
|
1501 | 'operator': /\+\+|--|(?:[+\-*\/%^]|&&?|\|\|?|<<?|>>?>?|[!=]=?)=?|[~?@]/
|
1502 | });
|
1503 | Prism.languages.actionscript['class-name'].alias = 'function';
|
1504 |
|
1505 | if (Prism.languages.markup) {
|
1506 | Prism.languages.insertBefore('actionscript', 'string', {
|
1507 | 'xml': {
|
1508 | pattern: /(^|[^.])<\/?\w+(?:\s+[^\s>\/=]+=("|')(?:\\[\s\S]|(?!\2)[^\\])*\2)*\s*\/?>/,
|
1509 | lookbehind: true,
|
1510 | inside: {
|
1511 | rest: Prism.languages.markup
|
1512 | }
|
1513 | }
|
1514 | });
|
1515 | }
|
1516 |
|
1517 |
|
1518 |
|
1519 | (function (Prism) {
|
1520 |
|
1521 | var comment = /#(?!\{).+/,
|
1522 | interpolation = {
|
1523 | pattern: /#\{[^}]+\}/,
|
1524 | alias: 'variable'
|
1525 | };
|
1526 | Prism.languages.coffeescript = Prism.languages.extend('javascript', {
|
1527 | 'comment': comment,
|
1528 | 'string': [
|
1529 | {
|
1530 | pattern: /'(?:\\[\s\S]|[^\\'])*'/,
|
1531 | greedy: true
|
1532 | }, {
|
1533 |
|
1534 | pattern: /"(?:\\[\s\S]|[^\\"])*"/,
|
1535 | greedy: true,
|
1536 | inside: {
|
1537 | 'interpolation': interpolation
|
1538 | }
|
1539 | }],
|
1540 | '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/,
|
1541 | 'class-member': {
|
1542 | pattern: /@(?!\d)\w+/,
|
1543 | alias: 'variable'
|
1544 | }
|
1545 | });
|
1546 | Prism.languages.insertBefore('coffeescript', 'comment', {
|
1547 | 'multiline-comment': {
|
1548 | pattern: /###[\s\S]+?###/,
|
1549 | alias: 'comment'
|
1550 | },
|
1551 |
|
1552 | 'block-regex': {
|
1553 | pattern: /\/{3}[\s\S]*?\/{3}/,
|
1554 | alias: 'regex',
|
1555 | inside: {
|
1556 | 'comment': comment,
|
1557 | 'interpolation': interpolation
|
1558 | }
|
1559 | }
|
1560 | });
|
1561 | Prism.languages.insertBefore('coffeescript', 'string', {
|
1562 | 'inline-javascript': {
|
1563 | pattern: /`(?:\\[\s\S]|[^\\`])*`/,
|
1564 | inside: {
|
1565 | 'delimiter': {
|
1566 | pattern: /^`|`$/,
|
1567 | alias: 'punctuation'
|
1568 | },
|
1569 | rest: Prism.languages.javascript
|
1570 | }
|
1571 | },
|
1572 |
|
1573 | 'multiline-string': [{
|
1574 | pattern: /'''[\s\S]*?'''/,
|
1575 | greedy: true,
|
1576 | alias: 'string'
|
1577 | }, {
|
1578 | pattern: /"""[\s\S]*?"""/,
|
1579 | greedy: true,
|
1580 | alias: 'string',
|
1581 | inside: {
|
1582 | interpolation: interpolation
|
1583 | }
|
1584 | }]
|
1585 | });
|
1586 | Prism.languages.insertBefore('coffeescript', 'keyword', {
|
1587 |
|
1588 | 'property': /(?!\d)\w+(?=\s*:(?!:))/
|
1589 | });
|
1590 | delete Prism.languages.coffeescript['template-string'];
|
1591 | Prism.languages.coffee = Prism.languages.coffeescript;
|
1592 | })(Prism);
|
1593 |
|
1594 |
|
1595 |
|
1596 | (function (Prism) {
|
1597 | Prism.languages.insertBefore('javascript', 'function-variable', {
|
1598 | 'method-variable': {
|
1599 | pattern: RegExp('(\\.\\s*)' + Prism.languages.javascript['function-variable'].pattern.source),
|
1600 | lookbehind: true,
|
1601 | alias: ['function-variable', 'method', 'function', 'property-access']
|
1602 | }
|
1603 | });
|
1604 | Prism.languages.insertBefore('javascript', 'function', {
|
1605 | 'method': {
|
1606 | pattern: RegExp('(\\.\\s*)' + Prism.languages.javascript['function'].source),
|
1607 | lookbehind: true,
|
1608 | alias: ['function', 'property-access']
|
1609 | }
|
1610 | });
|
1611 | Prism.languages.insertBefore('javascript', 'constant', {
|
1612 | 'known-class-name': [{
|
1613 |
|
1614 |
|
1615 | 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/,
|
1616 | alias: 'class-name'
|
1617 | }, {
|
1618 |
|
1619 | pattern: /\b(?:[A-Z]\w*)Error\b/,
|
1620 | alias: 'class-name'
|
1621 | }]
|
1622 | });
|
1623 | Prism.languages.javascript['keyword'].unshift({
|
1624 | pattern: /\b(?:as|default|export|from|import)\b/,
|
1625 | alias: 'module'
|
1626 | }, {
|
1627 | pattern: /\bnull\b/,
|
1628 | alias: ['null', 'nil']
|
1629 | }, {
|
1630 | pattern: /\bundefined\b/,
|
1631 | alias: 'nil'
|
1632 | });
|
1633 | Prism.languages.insertBefore('javascript', 'operator', {
|
1634 | 'spread': {
|
1635 | pattern: /\.{3}/,
|
1636 | alias: 'operator'
|
1637 | },
|
1638 | 'arrow': {
|
1639 | pattern: /=>/,
|
1640 | alias: 'operator'
|
1641 | }
|
1642 | });
|
1643 | Prism.languages.insertBefore('javascript', 'punctuation', {
|
1644 | 'property-access': {
|
1645 | pattern: /(\.\s*)#?[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*/,
|
1646 | lookbehind: true
|
1647 | },
|
1648 | 'maybe-class-name': {
|
1649 | pattern: /(^|[^$\w\xA0-\uFFFF])[A-Z][$\w\xA0-\uFFFF]+/,
|
1650 | lookbehind: true
|
1651 | },
|
1652 | 'dom': {
|
1653 |
|
1654 | pattern: /\b(?:document|location|navigator|performance|(?:local|session)Storage|window)\b/,
|
1655 | alias: 'variable'
|
1656 | },
|
1657 | 'console': {
|
1658 | pattern: /\bconsole(?=\s*\.)/,
|
1659 | alias: 'class-name'
|
1660 | }
|
1661 | });
|
1662 |
|
1663 | var maybeClassNameTokens = ['function', 'function-variable', 'method', 'method-variable', 'property-access'];
|
1664 |
|
1665 | for (var i = 0; i < maybeClassNameTokens.length; i++) {
|
1666 | var token = maybeClassNameTokens[i];
|
1667 | var value = Prism.languages.javascript[token];
|
1668 |
|
1669 | if (Prism.util.type(value) === 'RegExp') {
|
1670 | value = Prism.languages.javascript[token] = {
|
1671 | pattern: value
|
1672 | };
|
1673 | }
|
1674 |
|
1675 |
|
1676 | var inside = value.inside || {};
|
1677 | value.inside = inside;
|
1678 | inside['maybe-class-name'] = /^[A-Z][\s\S]*/;
|
1679 | }
|
1680 | })(Prism);
|
1681 |
|
1682 |
|
1683 |
|
1684 | (function (Prism) {
|
1685 | Prism.languages.flow = Prism.languages.extend('javascript', {});
|
1686 | Prism.languages.insertBefore('flow', 'keyword', {
|
1687 | 'type': [{
|
1688 | pattern: /\b(?:[Nn]umber|[Ss]tring|[Bb]oolean|Function|any|mixed|null|void)\b/,
|
1689 | alias: 'tag'
|
1690 | }]
|
1691 | });
|
1692 | 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;
|
1693 | delete Prism.languages.flow['parameter'];
|
1694 | Prism.languages.insertBefore('flow', 'operator', {
|
1695 | 'flow-punctuation': {
|
1696 | pattern: /\{\||\|\}/,
|
1697 | alias: 'punctuation'
|
1698 | }
|
1699 | });
|
1700 |
|
1701 | if (!Array.isArray(Prism.languages.flow.keyword)) {
|
1702 | Prism.languages.flow.keyword = [Prism.languages.flow.keyword];
|
1703 | }
|
1704 |
|
1705 | Prism.languages.flow.keyword.unshift({
|
1706 | pattern: /(^|[^$]\b)(?:type|opaque|declare|Class)\b(?!\$)/,
|
1707 | lookbehind: true
|
1708 | }, {
|
1709 | pattern: /(^|[^$]\B)\$(?:await|Diff|Exact|Keys|ObjMap|PropertyType|Shape|Record|Supertype|Subtype|Enum)\b(?!\$)/,
|
1710 | lookbehind: true
|
1711 | });
|
1712 | })(Prism);
|
1713 |
|
1714 |
|
1715 |
|
1716 | Prism.languages.n4js = Prism.languages.extend('javascript', {
|
1717 |
|
1718 | '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/
|
1719 | });
|
1720 | Prism.languages.insertBefore('n4js', 'constant', {
|
1721 |
|
1722 | 'annotation': {
|
1723 | pattern: /@+\w+/,
|
1724 | alias: 'operator'
|
1725 | }
|
1726 | });
|
1727 | Prism.languages.n4jsd = Prism.languages.n4js;
|
1728 |
|
1729 |
|
1730 | Prism.languages.typescript = Prism.languages.extend('javascript', {
|
1731 |
|
1732 | '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/,
|
1733 | 'builtin': /\b(?:string|Function|any|number|boolean|Array|symbol|console|Promise|unknown|never)\b/
|
1734 | });
|
1735 | Prism.languages.ts = Prism.languages.typescript;
|
1736 |
|
1737 |
|
1738 | (function (Prism) {
|
1739 | var templateString = Prism.languages.javascript['template-string'];
|
1740 |
|
1741 | var templateLiteralPattern = templateString.pattern.source;
|
1742 | var interpolationObject = templateString.inside['interpolation'];
|
1743 | var interpolationPunctuationObject = interpolationObject.inside['interpolation-punctuation'];
|
1744 | var interpolationPattern = interpolationObject.pattern.source;
|
1745 | |
1746 |
|
1747 |
|
1748 |
|
1749 |
|
1750 |
|
1751 |
|
1752 |
|
1753 |
|
1754 |
|
1755 |
|
1756 |
|
1757 | function createTemplate(language, tag) {
|
1758 | if (!Prism.languages[language]) {
|
1759 | return undefined;
|
1760 | }
|
1761 |
|
1762 | return {
|
1763 | pattern: RegExp('((?:' + tag + ')\\s*)' + templateLiteralPattern),
|
1764 | lookbehind: true,
|
1765 | greedy: true,
|
1766 | inside: {
|
1767 | 'template-punctuation': {
|
1768 | pattern: /^`|`$/,
|
1769 | alias: 'string'
|
1770 | },
|
1771 | 'embedded-code': {
|
1772 | pattern: /[\s\S]+/,
|
1773 | alias: language
|
1774 | }
|
1775 | }
|
1776 | };
|
1777 | }
|
1778 |
|
1779 | Prism.languages.javascript['template-string'] = [
|
1780 |
|
1781 |
|
1782 |
|
1783 | createTemplate('css', /\b(?:styled(?:\([^)]*\))?(?:\s*\.\s*\w+(?:\([^)]*\))*)*|css(?:\s*\.\s*(?:global|resolve))?|createGlobalStyle|keyframes)/.source),
|
1784 |
|
1785 | createTemplate('html', /\bhtml|\.\s*(?:inner|outer)HTML\s*\+?=/.source), // svg`<path fill="#fff" d="M55.37 ..."/>`
|
1786 | createTemplate('svg', /\bsvg/.source), // md`# h1`, markdown`## h2`
|
1787 | createTemplate('markdown', /\b(?:md|markdown)/.source),
|
1788 | createTemplate('graphql', /\b(?:gql|graphql(?:\s*\.\s*experimental)?)/.source),
|
1789 | templateString].filter(Boolean);
|
1790 | |
1791 |
|
1792 |
|
1793 |
|
1794 |
|
1795 |
|
1796 |
|
1797 |
|
1798 | function getPlaceholder(counter, language) {
|
1799 | return '___' + language.toUpperCase() + '_' + counter + '___';
|
1800 | }
|
1801 | |
1802 |
|
1803 |
|
1804 |
|
1805 |
|
1806 |
|
1807 |
|
1808 |
|
1809 |
|
1810 |
|
1811 | function tokenizeWithHooks(code, grammar, language) {
|
1812 | var env = {
|
1813 | code: code,
|
1814 | grammar: grammar,
|
1815 | language: language
|
1816 | };
|
1817 | Prism.hooks.run('before-tokenize', env);
|
1818 | env.tokens = Prism.tokenize(env.code, env.grammar);
|
1819 | Prism.hooks.run('after-tokenize', env);
|
1820 | return env.tokens;
|
1821 | }
|
1822 | |
1823 |
|
1824 |
|
1825 |
|
1826 |
|
1827 |
|
1828 |
|
1829 |
|
1830 | function tokenizeInterpolationExpression(expression) {
|
1831 | var tempGrammar = {};
|
1832 | tempGrammar['interpolation-punctuation'] = interpolationPunctuationObject;
|
1833 |
|
1834 |
|
1835 | var tokens = Prism.tokenize(expression, tempGrammar);
|
1836 |
|
1837 | if (tokens.length === 3) {
|
1838 | |
1839 |
|
1840 |
|
1841 |
|
1842 |
|
1843 |
|
1844 |
|
1845 |
|
1846 | var args = [1, 1];
|
1847 | args.push.apply(args, tokenizeWithHooks(tokens[1], Prism.languages.javascript, 'javascript'));
|
1848 | tokens.splice.apply(tokens, args);
|
1849 | }
|
1850 |
|
1851 | return new Prism.Token('interpolation', tokens, interpolationObject.alias, expression);
|
1852 | }
|
1853 | |
1854 |
|
1855 |
|
1856 |
|
1857 |
|
1858 |
|
1859 |
|
1860 |
|
1861 |
|
1862 |
|
1863 |
|
1864 |
|
1865 |
|
1866 |
|
1867 |
|
1868 |
|
1869 |
|
1870 |
|
1871 |
|
1872 | function tokenizeEmbedded(code, grammar, language) {
|
1873 |
|
1874 |
|
1875 |
|
1876 |
|
1877 | var _tokens = Prism.tokenize(code, {
|
1878 | 'interpolation': {
|
1879 | pattern: RegExp(interpolationPattern),
|
1880 | lookbehind: true
|
1881 | }
|
1882 | });
|
1883 |
|
1884 |
|
1885 | var placeholderCounter = 0;
|
1886 |
|
1887 |
|
1888 | var placeholderMap = {};
|
1889 |
|
1890 | var embeddedCode = _tokens.map(function (token) {
|
1891 | if (typeof token === 'string') {
|
1892 | return token;
|
1893 | } else {
|
1894 | var interpolationExpression = token.content;
|
1895 | var placeholder;
|
1896 |
|
1897 | while (code.indexOf(placeholder = getPlaceholder(placeholderCounter++, language)) !== -1) {}
|
1898 |
|
1899 | placeholderMap[placeholder] = interpolationExpression;
|
1900 | return placeholder;
|
1901 | }
|
1902 | }).join('');
|
1903 |
|
1904 |
|
1905 | var embeddedTokens = tokenizeWithHooks(embeddedCode, grammar, language);
|
1906 |
|
1907 | var placeholders = Object.keys(placeholderMap);
|
1908 | placeholderCounter = 0;
|
1909 | |
1910 |
|
1911 |
|
1912 |
|
1913 |
|
1914 |
|
1915 | function walkTokens(tokens) {
|
1916 | for (var i = 0; i < tokens.length; i++) {
|
1917 | if (placeholderCounter >= placeholders.length) {
|
1918 | return;
|
1919 | }
|
1920 |
|
1921 | var token = tokens[i];
|
1922 |
|
1923 | if (typeof token === 'string' || typeof token.content === 'string') {
|
1924 | var placeholder = placeholders[placeholderCounter];
|
1925 | var s = typeof token === 'string' ? token :
|
1926 |
|
1927 | token.content;
|
1928 | var index = s.indexOf(placeholder);
|
1929 |
|
1930 | if (index !== -1) {
|
1931 | ++placeholderCounter;
|
1932 | var before = s.substring(0, index);
|
1933 | var middle = tokenizeInterpolationExpression(placeholderMap[placeholder]);
|
1934 | var after = s.substring(index + placeholder.length);
|
1935 | var replacement = [];
|
1936 |
|
1937 | if (before) {
|
1938 | replacement.push(before);
|
1939 | }
|
1940 |
|
1941 | replacement.push(middle);
|
1942 |
|
1943 | if (after) {
|
1944 | var afterTokens = [after];
|
1945 | walkTokens(afterTokens);
|
1946 | replacement.push.apply(replacement, afterTokens);
|
1947 | }
|
1948 |
|
1949 | if (typeof token === 'string') {
|
1950 | tokens.splice.apply(tokens, [i, 1].concat(replacement));
|
1951 | i += replacement.length - 1;
|
1952 | } else {
|
1953 | token.content = replacement;
|
1954 | }
|
1955 | }
|
1956 | } else {
|
1957 | var content = token.content;
|
1958 |
|
1959 | if (Array.isArray(content)) {
|
1960 | walkTokens(content);
|
1961 | } else {
|
1962 | walkTokens([content]);
|
1963 | }
|
1964 | }
|
1965 | }
|
1966 | }
|
1967 |
|
1968 | walkTokens(embeddedTokens);
|
1969 | return new Prism.Token(language, embeddedTokens, 'language-' + language, code);
|
1970 | }
|
1971 | |
1972 |
|
1973 |
|
1974 |
|
1975 |
|
1976 |
|
1977 |
|
1978 | var supportedLanguages = {
|
1979 | 'javascript': true,
|
1980 | 'js': true,
|
1981 | 'typescript': true,
|
1982 | 'ts': true,
|
1983 | 'jsx': true,
|
1984 | 'tsx': true
|
1985 | };
|
1986 | Prism.hooks.add('after-tokenize', function (env) {
|
1987 | if (!(env.language in supportedLanguages)) {
|
1988 | return;
|
1989 | }
|
1990 | |
1991 |
|
1992 |
|
1993 |
|
1994 |
|
1995 |
|
1996 |
|
1997 |
|
1998 | function findTemplateStrings(tokens) {
|
1999 | for (var i = 0, l = tokens.length; i < l; i++) {
|
2000 | var token = tokens[i];
|
2001 |
|
2002 | if (typeof token === 'string') {
|
2003 | continue;
|
2004 | }
|
2005 |
|
2006 | var content = token.content;
|
2007 |
|
2008 | if (!Array.isArray(content)) {
|
2009 | if (typeof content !== 'string') {
|
2010 | findTemplateStrings([content]);
|
2011 | }
|
2012 |
|
2013 | continue;
|
2014 | }
|
2015 |
|
2016 | if (token.type === 'template-string') {
|
2017 | |
2018 |
|
2019 |
|
2020 |
|
2021 |
|
2022 |
|
2023 |
|
2024 |
|
2025 |
|
2026 |
|
2027 |
|
2028 |
|
2029 |
|
2030 |
|
2031 | var embedded = content[1];
|
2032 |
|
2033 | if (content.length === 3 && typeof embedded !== 'string' && embedded.type === 'embedded-code') {
|
2034 |
|
2035 | var code = stringContent(embedded);
|
2036 | var alias = embedded.alias;
|
2037 | var language = Array.isArray(alias) ? alias[0] : alias;
|
2038 | var grammar = Prism.languages[language];
|
2039 |
|
2040 | if (!grammar) {
|
2041 |
|
2042 | continue;
|
2043 | }
|
2044 |
|
2045 | content[1] = tokenizeEmbedded(code, grammar, language);
|
2046 | }
|
2047 | } else {
|
2048 | findTemplateStrings(content);
|
2049 | }
|
2050 | }
|
2051 | }
|
2052 |
|
2053 | findTemplateStrings(env.tokens);
|
2054 | });
|
2055 | |
2056 |
|
2057 |
|
2058 |
|
2059 |
|
2060 |
|
2061 |
|
2062 | function stringContent(value) {
|
2063 | if (typeof value === 'string') {
|
2064 | return value;
|
2065 | } else if (Array.isArray(value)) {
|
2066 | return value.map(stringContent).join('');
|
2067 | } else {
|
2068 | return stringContent(value.content);
|
2069 | }
|
2070 | }
|
2071 | })(Prism);
|
2072 |
|
2073 |
|
2074 |
|
2075 | Prism.languages.graphql = {
|
2076 | 'comment': /#.*/,
|
2077 | 'string': {
|
2078 | pattern: /"(?:\\.|[^\\"\r\n])*"/,
|
2079 | greedy: true
|
2080 | },
|
2081 | 'number': /(?:\B-|\b)\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,
|
2082 | 'boolean': /\b(?:true|false)\b/,
|
2083 | 'variable': /\$[a-z_]\w*/i,
|
2084 | 'directive': {
|
2085 | pattern: /@[a-z_]\w*/i,
|
2086 | alias: 'function'
|
2087 | },
|
2088 | 'attr-name': {
|
2089 | pattern: /[a-z_]\w*(?=\s*(?:\((?:[^()"]|"(?:\\.|[^\\"\r\n])*")*\))?:)/i,
|
2090 | greedy: true
|
2091 | },
|
2092 | 'class-name': {
|
2093 | pattern: /(\b(?:enum|implements|interface|on|scalar|type|union)\s+)[a-zA-Z_]\w*/,
|
2094 | lookbehind: true
|
2095 | },
|
2096 | 'fragment': {
|
2097 | pattern: /(\bfragment\s+|\.{3}\s*(?!on\b))[a-zA-Z_]\w*/,
|
2098 | lookbehind: true,
|
2099 | alias: 'function'
|
2100 | },
|
2101 | 'keyword': /\b(?:enum|fragment|implements|input|interface|mutation|on|query|scalar|schema|type|union)\b/,
|
2102 | 'operator': /[!=|]|\.{3}/,
|
2103 | 'punctuation': /[!(){}\[\]:=,]/,
|
2104 | 'constant': /\b(?!ID\b)[A-Z][A-Z_\d]*\b/
|
2105 | };
|
2106 |
|
2107 |
|
2108 | (function (Prism) {
|
2109 |
|
2110 | var inner = /(?:\\.|[^\\\n\r]|(?:\r?\n|\r)(?!\r?\n|\r))/.source;
|
2111 | |
2112 |
|
2113 |
|
2114 |
|
2115 |
|
2116 |
|
2117 |
|
2118 |
|
2119 |
|
2120 |
|
2121 |
|
2122 |
|
2123 | function createInline(pattern, starAlternative) {
|
2124 | pattern = pattern.replace(/<inner>/g, inner);
|
2125 |
|
2126 | if (starAlternative) {
|
2127 | pattern = pattern + '|' + pattern.replace(/_/g, '\\*');
|
2128 | }
|
2129 |
|
2130 | return RegExp(/((?:^|[^\\])(?:\\{2})*)/.source + '(?:' + pattern + ')');
|
2131 | }
|
2132 |
|
2133 | var tableCell = /(?:\\.|``.+?``|`[^`\r\n]+`|[^\\|\r\n`])+/.source;
|
2134 | var tableRow = /\|?__(?:\|__)+\|?(?:(?:\r?\n|\r)|$)/.source.replace(/__/g, tableCell);
|
2135 | var tableLine = /\|?[ \t]*:?-{3,}:?[ \t]*(?:\|[ \t]*:?-{3,}:?[ \t]*)+\|?(?:\r?\n|\r)/.source;
|
2136 | Prism.languages.markdown = Prism.languages.extend('markup', {});
|
2137 | Prism.languages.insertBefore('markdown', 'prolog', {
|
2138 | 'blockquote': {
|
2139 |
|
2140 | pattern: /^>(?:[\t ]*>)*/m,
|
2141 | alias: 'punctuation'
|
2142 | },
|
2143 | 'table': {
|
2144 | pattern: RegExp('^' + tableRow + tableLine + '(?:' + tableRow + ')*', 'm'),
|
2145 | inside: {
|
2146 | 'table-data-rows': {
|
2147 | pattern: RegExp('^(' + tableRow + tableLine + ')(?:' + tableRow + ')*$'),
|
2148 | lookbehind: true,
|
2149 | inside: {
|
2150 | 'table-data': {
|
2151 | pattern: RegExp(tableCell),
|
2152 | inside: Prism.languages.markdown
|
2153 | },
|
2154 | 'punctuation': /\|/
|
2155 | }
|
2156 | },
|
2157 | 'table-line': {
|
2158 | pattern: RegExp('^(' + tableRow + ')' + tableLine + '$'),
|
2159 | lookbehind: true,
|
2160 | inside: {
|
2161 | 'punctuation': /\||:?-{3,}:?/
|
2162 | }
|
2163 | },
|
2164 | 'table-header-row': {
|
2165 | pattern: RegExp('^' + tableRow + '$'),
|
2166 | inside: {
|
2167 | 'table-header': {
|
2168 | pattern: RegExp(tableCell),
|
2169 | alias: 'important',
|
2170 | inside: Prism.languages.markdown
|
2171 | },
|
2172 | 'punctuation': /\|/
|
2173 | }
|
2174 | }
|
2175 | }
|
2176 | },
|
2177 | 'code': [{
|
2178 |
|
2179 | pattern: /(^[ \t]*(?:\r?\n|\r))(?: {4}|\t).+(?:(?:\r?\n|\r)(?: {4}|\t).+)*/m,
|
2180 | lookbehind: true,
|
2181 | alias: 'keyword'
|
2182 | }, {
|
2183 |
|
2184 |
|
2185 | pattern: /``.+?``|`[^`\r\n]+`/,
|
2186 | alias: 'keyword'
|
2187 | }, {
|
2188 |
|
2189 |
|
2190 |
|
2191 | pattern: /^```[\s\S]*?^```$/m,
|
2192 | greedy: true,
|
2193 | inside: {
|
2194 | 'code-block': {
|
2195 | pattern: /^(```.*(?:\r?\n|\r))[\s\S]+?(?=(?:\r?\n|\r)^```$)/m,
|
2196 | lookbehind: true
|
2197 | },
|
2198 | 'code-language': {
|
2199 | pattern: /^(```).+/,
|
2200 | lookbehind: true
|
2201 | },
|
2202 | 'punctuation': /```/
|
2203 | }
|
2204 | }],
|
2205 | 'title': [{
|
2206 |
|
2207 |
|
2208 |
|
2209 |
|
2210 | pattern: /\S.*(?:\r?\n|\r)(?:==+|--+)(?=[ \t]*$)/m,
|
2211 | alias: 'important',
|
2212 | inside: {
|
2213 | punctuation: /==+$|--+$/
|
2214 | }
|
2215 | }, {
|
2216 |
|
2217 |
|
2218 | pattern: /(^\s*)#+.+/m,
|
2219 | lookbehind: true,
|
2220 | alias: 'important',
|
2221 | inside: {
|
2222 | punctuation: /^#+|#+$/
|
2223 | }
|
2224 | }],
|
2225 | 'hr': {
|
2226 |
|
2227 |
|
2228 |
|
2229 |
|
2230 | pattern: /(^\s*)([*-])(?:[\t ]*\2){2,}(?=\s*$)/m,
|
2231 | lookbehind: true,
|
2232 | alias: 'punctuation'
|
2233 | },
|
2234 | 'list': {
|
2235 |
|
2236 |
|
2237 |
|
2238 |
|
2239 | pattern: /(^\s*)(?:[*+-]|\d+\.)(?=[\t ].)/m,
|
2240 | lookbehind: true,
|
2241 | alias: 'punctuation'
|
2242 | },
|
2243 | 'url-reference': {
|
2244 |
|
2245 |
|
2246 |
|
2247 |
|
2248 | pattern: /!?\[[^\]]+\]:[\t ]+(?:\S+|<(?:\\.|[^>\\])+>)(?:[\t ]+(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\((?:\\.|[^)\\])*\)))?/,
|
2249 | inside: {
|
2250 | 'variable': {
|
2251 | pattern: /^(!?\[)[^\]]+/,
|
2252 | lookbehind: true
|
2253 | },
|
2254 | 'string': /(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\((?:\\.|[^)\\])*\))$/,
|
2255 | 'punctuation': /^[\[\]!:]|[<>]/
|
2256 | },
|
2257 | alias: 'url'
|
2258 | },
|
2259 | 'bold': {
|
2260 |
|
2261 |
|
2262 |
|
2263 | pattern: createInline(/__(?:(?!_)<inner>|_(?:(?!_)<inner>)+_)+__/.source, true),
|
2264 | lookbehind: true,
|
2265 | greedy: true,
|
2266 | inside: {
|
2267 | 'content': {
|
2268 | pattern: /(^..)[\s\S]+(?=..$)/,
|
2269 | lookbehind: true,
|
2270 | inside: {}
|
2271 |
|
2272 | },
|
2273 | 'punctuation': /\*\*|__/
|
2274 | }
|
2275 | },
|
2276 | 'italic': {
|
2277 |
|
2278 |
|
2279 |
|
2280 | pattern: createInline(/_(?:(?!_)<inner>|__(?:(?!_)<inner>)+__)+_/.source, true),
|
2281 | lookbehind: true,
|
2282 | greedy: true,
|
2283 | inside: {
|
2284 | 'content': {
|
2285 | pattern: /(^.)[\s\S]+(?=.$)/,
|
2286 | lookbehind: true,
|
2287 | inside: {}
|
2288 |
|
2289 | },
|
2290 | 'punctuation': /[*_]/
|
2291 | }
|
2292 | },
|
2293 | 'strike': {
|
2294 |
|
2295 |
|
2296 | pattern: createInline(/(~~?)(?:(?!~)<inner>)+?\2/.source, false),
|
2297 | lookbehind: true,
|
2298 | greedy: true,
|
2299 | inside: {
|
2300 | 'content': {
|
2301 | pattern: /(^~~?)[\s\S]+(?=\1$)/,
|
2302 | lookbehind: true,
|
2303 | inside: {}
|
2304 |
|
2305 | },
|
2306 | 'punctuation': /~~?/
|
2307 | }
|
2308 | },
|
2309 | 'url': {
|
2310 |
|
2311 |
|
2312 |
|
2313 | pattern: createInline(/!?\[(?:(?!\])<inner>)+\](?:\([^\s)]+(?:[\t ]+"(?:\\.|[^"\\])*")?\)| ?\[(?:(?!\])<inner>)+\])/.source, false),
|
2314 | lookbehind: true,
|
2315 | greedy: true,
|
2316 | inside: {
|
2317 | 'variable': {
|
2318 | pattern: /(\[)[^\]]+(?=\]$)/,
|
2319 | lookbehind: true
|
2320 | },
|
2321 | 'content': {
|
2322 | pattern: /(^!?\[)[^\]]+(?=\])/,
|
2323 | lookbehind: true,
|
2324 | inside: {}
|
2325 |
|
2326 | },
|
2327 | 'string': {
|
2328 | pattern: /"(?:\\.|[^"\\])*"(?=\)$)/
|
2329 | }
|
2330 | }
|
2331 | }
|
2332 | });
|
2333 | ['url', 'bold', 'italic', 'strike'].forEach(function (token) {
|
2334 | ['url', 'bold', 'italic', 'strike'].forEach(function (inside) {
|
2335 | if (token !== inside) {
|
2336 | Prism.languages.markdown[token].inside.content.inside[inside] = Prism.languages.markdown[inside];
|
2337 | }
|
2338 | });
|
2339 | });
|
2340 | Prism.hooks.add('after-tokenize', function (env) {
|
2341 | if (env.language !== 'markdown' && env.language !== 'md') {
|
2342 | return;
|
2343 | }
|
2344 |
|
2345 | function walkTokens(tokens) {
|
2346 | if (!tokens || typeof tokens === 'string') {
|
2347 | return;
|
2348 | }
|
2349 |
|
2350 | for (var i = 0, l = tokens.length; i < l; i++) {
|
2351 | var token = tokens[i];
|
2352 |
|
2353 | if (token.type !== 'code') {
|
2354 | walkTokens(token.content);
|
2355 | continue;
|
2356 | }
|
2357 | |
2358 |
|
2359 |
|
2360 |
|
2361 |
|
2362 |
|
2363 |
|
2364 |
|
2365 |
|
2366 |
|
2367 |
|
2368 |
|
2369 |
|
2370 |
|
2371 |
|
2372 | var codeLang = token.content[1];
|
2373 | var codeBlock = token.content[3];
|
2374 |
|
2375 | if (codeLang && codeBlock && codeLang.type === 'code-language' && codeBlock.type === 'code-block' && typeof codeLang.content === 'string') {
|
2376 |
|
2377 | var alias = 'language-' + codeLang.content.trim().split(/\s+/)[0].toLowerCase();
|
2378 |
|
2379 | if (!codeBlock.alias) {
|
2380 | codeBlock.alias = [alias];
|
2381 | } else if (typeof codeBlock.alias === 'string') {
|
2382 | codeBlock.alias = [codeBlock.alias, alias];
|
2383 | } else {
|
2384 | codeBlock.alias.push(alias);
|
2385 | }
|
2386 | }
|
2387 | }
|
2388 | }
|
2389 |
|
2390 | walkTokens(env.tokens);
|
2391 | });
|
2392 | Prism.hooks.add('wrap', function (env) {
|
2393 | if (env.type !== 'code-block') {
|
2394 | return;
|
2395 | }
|
2396 |
|
2397 | var codeLang = '';
|
2398 |
|
2399 | for (var i = 0, l = env.classes.length; i < l; i++) {
|
2400 | var cls = env.classes[i];
|
2401 | var match = /language-(.+)/.exec(cls);
|
2402 |
|
2403 | if (match) {
|
2404 | codeLang = match[1];
|
2405 | break;
|
2406 | }
|
2407 | }
|
2408 |
|
2409 | var grammar = Prism.languages[codeLang];
|
2410 |
|
2411 | if (!grammar) {
|
2412 | if (codeLang && codeLang !== 'none' && Prism.plugins.autoloader) {
|
2413 | var id = 'md-' + new Date().valueOf() + '-' + Math.floor(Math.random() * 1e16);
|
2414 | env.attributes['id'] = id;
|
2415 | Prism.plugins.autoloader.loadLanguages(codeLang, function () {
|
2416 | var ele = document.getElementById(id);
|
2417 |
|
2418 | if (ele) {
|
2419 | ele.innerHTML = Prism.highlight(ele.textContent, Prism.languages[codeLang], codeLang);
|
2420 | }
|
2421 | });
|
2422 | }
|
2423 | } else {
|
2424 |
|
2425 | var code = env.content.replace(/</g, '<').replace(/&/g, '&');
|
2426 | env.content = Prism.highlight(code, grammar, codeLang);
|
2427 | }
|
2428 | });
|
2429 | Prism.languages.md = Prism.languages.markdown;
|
2430 | })(Prism);
|
2431 |
|
2432 |
|
2433 |
|
2434 | (function (Prism) {
|
2435 | Prism.languages.diff = {
|
2436 | 'coord': [
|
2437 | /^(?:\*{3}|-{3}|\+{3}).*$/m,
|
2438 | /^@@.*@@$/m,
|
2439 | /^\d+.*$/m]
|
2440 |
|
2441 | };
|
2442 | |
2443 |
|
2444 |
|
2445 |
|
2446 |
|
2447 |
|
2448 | var PREFIXES = {
|
2449 | 'deleted-sign': '-',
|
2450 | 'deleted-arrow': '<',
|
2451 | 'inserted-sign': '+',
|
2452 | 'inserted-arrow': '>',
|
2453 | 'unchanged': ' ',
|
2454 | 'diff': '!'
|
2455 | };
|
2456 |
|
2457 | Object.keys(PREFIXES).forEach(function (name) {
|
2458 | var prefix = PREFIXES[name];
|
2459 | var alias = [];
|
2460 |
|
2461 | if (!/^\w+$/.test(name)) {
|
2462 |
|
2463 | alias.push(/\w+/.exec(name)[0]);
|
2464 | }
|
2465 |
|
2466 | if (name === "diff") {
|
2467 | alias.push("bold");
|
2468 | }
|
2469 |
|
2470 | Prism.languages.diff[name] = {
|
2471 |
|
2472 | pattern: RegExp('^(?:[' + prefix + '].*(?:\r\n?|\n|(?![\\s\\S])))+', 'm'),
|
2473 | alias: alias
|
2474 | };
|
2475 | });
|
2476 |
|
2477 | Object.defineProperty(Prism.languages.diff, 'PREFIXES', {
|
2478 | value: PREFIXES
|
2479 | });
|
2480 | })(Prism);
|
2481 |
|
2482 |
|
2483 |
|
2484 | Prism.languages.git = {
|
2485 | |
2486 |
|
2487 |
|
2488 |
|
2489 |
|
2490 |
|
2491 |
|
2492 |
|
2493 |
|
2494 | 'comment': /^#.*/m,
|
2495 |
|
2496 | |
2497 |
|
2498 |
|
2499 | 'deleted': /^[-–].*/m,
|
2500 | 'inserted': /^\+.*/m,
|
2501 |
|
2502 | |
2503 |
|
2504 |
|
2505 | 'string': /("|')(?:\\.|(?!\1)[^\\\r\n])*\1/m,
|
2506 |
|
2507 | |
2508 |
|
2509 |
|
2510 |
|
2511 |
|
2512 | 'command': {
|
2513 | pattern: /^.*\$ git .*$/m,
|
2514 | inside: {
|
2515 | |
2516 |
|
2517 |
|
2518 |
|
2519 |
|
2520 |
|
2521 | 'parameter': /\s--?\w+/m
|
2522 | }
|
2523 | },
|
2524 |
|
2525 | |
2526 |
|
2527 |
|
2528 |
|
2529 |
|
2530 |
|
2531 |
|
2532 |
|
2533 |
|
2534 |
|
2535 |
|
2536 |
|
2537 |
|
2538 | 'coord': /^@@.*@@$/m,
|
2539 |
|
2540 | |
2541 |
|
2542 |
|
2543 |
|
2544 |
|
2545 |
|
2546 |
|
2547 |
|
2548 |
|
2549 |
|
2550 | 'commit_sha1': /^commit \w{40}$/m
|
2551 | };
|
2552 |
|
2553 |
|
2554 | Prism.languages.go = Prism.languages.extend('clike', {
|
2555 | '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/,
|
2556 | '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/,
|
2557 | 'boolean': /\b(?:_|iota|nil|true|false)\b/,
|
2558 | 'operator': /[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,
|
2559 | 'number': /(?:\b0x[a-f\d]+|(?:\b\d+\.?\d*|\B\.\d+)(?:e[-+]?\d+)?)i?/i,
|
2560 | 'string': {
|
2561 | pattern: /(["'`])(\\[\s\S]|(?!\1)[^\\])*\1/,
|
2562 | greedy: true
|
2563 | }
|
2564 | });
|
2565 | delete Prism.languages.go['class-name'];
|
2566 |
|
2567 |
|
2568 | (function (Prism) {
|
2569 | Prism.languages.handlebars = {
|
2570 | 'comment': /\{\{![\s\S]*?\}\}/,
|
2571 | 'delimiter': {
|
2572 | pattern: /^\{\{\{?|\}\}\}?$/i,
|
2573 | alias: 'punctuation'
|
2574 | },
|
2575 | 'string': /(["'])(?:\\.|(?!\1)[^\\\r\n])*\1/,
|
2576 | 'number': /\b0x[\dA-Fa-f]+\b|(?:\b\d+\.?\d*|\B\.\d+)(?:[Ee][+-]?\d+)?/,
|
2577 | 'boolean': /\b(?:true|false)\b/,
|
2578 | 'block': {
|
2579 | pattern: /^(\s*~?\s*)[#\/]\S+?(?=\s*~?\s*$|\s)/i,
|
2580 | lookbehind: true,
|
2581 | alias: 'keyword'
|
2582 | },
|
2583 | 'brackets': {
|
2584 | pattern: /\[[^\]]+\]/,
|
2585 | inside: {
|
2586 | punctuation: /\[|\]/,
|
2587 | variable: /[\s\S]+/
|
2588 | }
|
2589 | },
|
2590 | 'punctuation': /[!"#%&'()*+,.\/;<=>@\[\\\]^`{|}~]/,
|
2591 | 'variable': /[^!"#%&'()*+,.\/;<=>@\[\\\]^`{|}~\s]+/
|
2592 | };
|
2593 | Prism.hooks.add('before-tokenize', function (env) {
|
2594 | var handlebarsPattern = /\{\{\{[\s\S]+?\}\}\}|\{\{[\s\S]+?\}\}/g;
|
2595 | Prism.languages['markup-templating'].buildPlaceholders(env, 'handlebars', handlebarsPattern);
|
2596 | });
|
2597 | Prism.hooks.add('after-tokenize', function (env) {
|
2598 | Prism.languages['markup-templating'].tokenizePlaceholders(env, 'handlebars');
|
2599 | });
|
2600 | })(Prism);
|
2601 |
|
2602 |
|
2603 |
|
2604 | Prism.languages.json = {
|
2605 | 'property': {
|
2606 | pattern: /"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,
|
2607 | greedy: true
|
2608 | },
|
2609 | 'string': {
|
2610 | pattern: /"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,
|
2611 | greedy: true
|
2612 | },
|
2613 | 'comment': /\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,
|
2614 | 'number': /-?\d+\.?\d*(e[+-]?\d+)?/i,
|
2615 | 'punctuation': /[{}[\],]/,
|
2616 | 'operator': /:/,
|
2617 | 'boolean': /\b(?:true|false)\b/,
|
2618 | 'null': {
|
2619 | pattern: /\bnull\b/,
|
2620 | alias: 'keyword'
|
2621 | }
|
2622 | };
|
2623 |
|
2624 |
|
2625 |
|
2626 |
|
2627 |
|
2628 |
|
2629 |
|
2630 |
|
2631 |
|
2632 |
|
2633 | Prism.languages.less = Prism.languages.extend('css', {
|
2634 | 'comment': [/\/\*[\s\S]*?\*\//, {
|
2635 | pattern: /(^|[^\\])\/\/.*/,
|
2636 | lookbehind: true
|
2637 | }],
|
2638 | 'atrule': {
|
2639 | pattern: /@[\w-]+?(?:\([^{}]+\)|[^(){};])*?(?=\s*\{)/i,
|
2640 | inside: {
|
2641 | 'punctuation': /[:()]/
|
2642 | }
|
2643 | },
|
2644 |
|
2645 | 'selector': {
|
2646 | pattern: /(?:@\{[\w-]+\}|[^{};\s@])(?:@\{[\w-]+\}|\([^{}]*\)|[^{};@])*?(?=\s*\{)/,
|
2647 | inside: {
|
2648 |
|
2649 | 'variable': /@+[\w-]+/
|
2650 | }
|
2651 | },
|
2652 | 'property': /(?:@\{[\w-]+\}|[\w-])+(?:\+_?)?(?=\s*:)/i,
|
2653 | 'operator': /[+\-*\/]/
|
2654 | });
|
2655 | Prism.languages.insertBefore('less', 'property', {
|
2656 | 'variable': [
|
2657 | {
|
2658 | pattern: /@[\w-]+\s*:/,
|
2659 | inside: {
|
2660 | "punctuation": /:/
|
2661 | }
|
2662 | },
|
2663 | /@@?[\w-]+/],
|
2664 | 'mixin-usage': {
|
2665 | pattern: /([{;]\s*)[.#](?!\d)[\w-]+.*?(?=[(;])/,
|
2666 | lookbehind: true,
|
2667 | alias: 'function'
|
2668 | }
|
2669 | });
|
2670 |
|
2671 |
|
2672 | Prism.languages.makefile = {
|
2673 | 'comment': {
|
2674 | pattern: /(^|[^\\])#(?:\\(?:\r\n|[\s\S])|[^\\\r\n])*/,
|
2675 | lookbehind: true
|
2676 | },
|
2677 | 'string': {
|
2678 | pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
|
2679 | greedy: true
|
2680 | },
|
2681 |
|
2682 | 'builtin': /\.[A-Z][^:#=\s]+(?=\s*:(?!=))/,
|
2683 |
|
2684 | 'symbol': {
|
2685 | pattern: /^[^:=\r\n]+(?=\s*:(?!=))/m,
|
2686 | inside: {
|
2687 | 'variable': /\$+(?:[^(){}:#=\s]+|(?=[({]))/
|
2688 | }
|
2689 | },
|
2690 | 'variable': /\$+(?:[^(){}:#=\s]+|\([@*%<^+?][DF]\)|(?=[({]))/,
|
2691 | 'keyword': [
|
2692 | /-include\b|\b(?:define|else|endef|endif|export|ifn?def|ifn?eq|include|override|private|sinclude|undefine|unexport|vpath)\b/,
|
2693 | {
|
2694 | 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])/,
|
2695 | lookbehind: true
|
2696 | }],
|
2697 | 'operator': /(?:::|[?:+!])?=|[|@]/,
|
2698 | 'punctuation': /[:;(){}]/
|
2699 | };
|
2700 |
|
2701 |
|
2702 | Prism.languages.objectivec = Prism.languages.extend('c', {
|
2703 | '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/,
|
2704 | 'string': /("|')(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1|@"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"/,
|
2705 | 'operator': /-[->]?|\+\+?|!=?|<<?=?|>>?=?|==?|&&?|\|\|?|[~^%?*\/@]/
|
2706 | });
|
2707 | delete Prism.languages.objectivec['class-name'];
|
2708 |
|
2709 |
|
2710 | Prism.languages.ocaml = {
|
2711 | 'comment': /\(\*[\s\S]*?\*\)/,
|
2712 | 'string': [{
|
2713 | pattern: /"(?:\\.|[^\\\r\n"])*"/,
|
2714 | greedy: true
|
2715 | }, {
|
2716 | pattern: /(['`])(?:\\(?:\d+|x[\da-f]+|.)|(?!\1)[^\\\r\n])\1/i,
|
2717 | greedy: true
|
2718 | }],
|
2719 | 'number': /\b(?:0x[\da-f][\da-f_]+|(?:0[bo])?\d[\d_]*\.?[\d_]*(?:e[+-]?[\d_]+)?)/i,
|
2720 | 'type': {
|
2721 | pattern: /\B['`]\w*/,
|
2722 | alias: 'variable'
|
2723 | },
|
2724 | 'directive': {
|
2725 | pattern: /\B#\w+/,
|
2726 | alias: 'function'
|
2727 | },
|
2728 | '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/,
|
2729 | 'boolean': /\b(?:false|true)\b/,
|
2730 |
|
2731 | 'operator': /:=|[=<>@^|&+\-*\/$%!?~][!$%&*+\-.\/:<=>?@^|~]*|\b(?:and|asr|land|lor|lxor|lsl|lsr|mod|nor|or)\b/,
|
2732 | 'punctuation': /[(){}\[\]|_.,:;]/
|
2733 | };
|
2734 |
|
2735 |
|
2736 | Prism.languages.python = {
|
2737 | 'comment': {
|
2738 | pattern: /(^|[^\\])#.*/,
|
2739 | lookbehind: true
|
2740 | },
|
2741 | 'string-interpolation': {
|
2742 | pattern: /(?:f|rf|fr)(?:("""|''')[\s\S]+?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2)/i,
|
2743 | greedy: true,
|
2744 | inside: {
|
2745 | 'interpolation': {
|
2746 |
|
2747 | pattern: /((?:^|[^{])(?:{{)*){(?!{)(?:[^{}]|{(?!{)(?:[^{}]|{(?!{)(?:[^{}])+})+})+}/,
|
2748 | lookbehind: true,
|
2749 | inside: {
|
2750 | 'format-spec': {
|
2751 | pattern: /(:)[^:(){}]+(?=}$)/,
|
2752 | lookbehind: true
|
2753 | },
|
2754 | 'conversion-option': {
|
2755 | pattern: /![sra](?=[:}]$)/,
|
2756 | alias: 'punctuation'
|
2757 | },
|
2758 | rest: null
|
2759 | }
|
2760 | },
|
2761 | 'string': /[\s\S]+/
|
2762 | }
|
2763 | },
|
2764 | 'triple-quoted-string': {
|
2765 | pattern: /(?:[rub]|rb|br)?("""|''')[\s\S]+?\1/i,
|
2766 | greedy: true,
|
2767 | alias: 'string'
|
2768 | },
|
2769 | 'string': {
|
2770 | pattern: /(?:[rub]|rb|br)?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/i,
|
2771 | greedy: true
|
2772 | },
|
2773 | 'function': {
|
2774 | pattern: /((?:^|\s)def[ \t]+)[a-zA-Z_]\w*(?=\s*\()/g,
|
2775 | lookbehind: true
|
2776 | },
|
2777 | 'class-name': {
|
2778 | pattern: /(\bclass\s+)\w+/i,
|
2779 | lookbehind: true
|
2780 | },
|
2781 | 'decorator': {
|
2782 | pattern: /(^\s*)@\w+(?:\.\w+)*/i,
|
2783 | lookbehind: true,
|
2784 | alias: ['annotation', 'punctuation'],
|
2785 | inside: {
|
2786 | 'punctuation': /\./
|
2787 | }
|
2788 | },
|
2789 | '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/,
|
2790 | '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/,
|
2791 | 'boolean': /\b(?:True|False|None)\b/,
|
2792 | 'number': /(?:\b(?=\d)|\B(?=\.))(?:0[bo])?(?:(?:\d|0x[\da-f])[\da-f]*\.?\d*|\.\d+)(?:e[+-]?\d+)?j?\b/i,
|
2793 | 'operator': /[-+%=]=?|!=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/,
|
2794 | 'punctuation': /[{}[\];(),.:]/
|
2795 | };
|
2796 | Prism.languages.python['string-interpolation'].inside['interpolation'].inside.rest = Prism.languages.python;
|
2797 | Prism.languages.py = Prism.languages.python;
|
2798 |
|
2799 |
|
2800 | Prism.languages.reason = Prism.languages.extend('clike', {
|
2801 | 'comment': {
|
2802 | pattern: /(^|[^\\])\/\*[\s\S]*?\*\//,
|
2803 | lookbehind: true
|
2804 | },
|
2805 | 'string': {
|
2806 | pattern: /"(?:\\(?:\r\n|[\s\S])|[^\\\r\n"])*"/,
|
2807 | greedy: true
|
2808 | },
|
2809 |
|
2810 | 'class-name': /\b[A-Z]\w*/,
|
2811 | '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/,
|
2812 | 'operator': /\.{3}|:[:=]|\|>|->|=(?:==?|>)?|<=?|>=?|[|^?'#!~`]|[+\-*\/]\.?|\b(?:mod|land|lor|lxor|lsl|lsr|asr)\b/
|
2813 | });
|
2814 | Prism.languages.insertBefore('reason', 'class-name', {
|
2815 | 'character': {
|
2816 | pattern: /'(?:\\x[\da-f]{2}|\\o[0-3][0-7][0-7]|\\\d{3}|\\.|[^'\\\r\n])'/,
|
2817 | alias: 'string'
|
2818 | },
|
2819 | 'constructor': {
|
2820 |
|
2821 | pattern: /\b[A-Z]\w*\b(?!\s*\.)/,
|
2822 | alias: 'variable'
|
2823 | },
|
2824 | 'label': {
|
2825 | pattern: /\b[a-z]\w*(?=::)/,
|
2826 | alias: 'symbol'
|
2827 | }
|
2828 | });
|
2829 |
|
2830 | delete Prism.languages.reason.function;
|
2831 |
|
2832 |
|
2833 | (function (Prism) {
|
2834 | Prism.languages.sass = Prism.languages.extend('css', {
|
2835 |
|
2836 | 'comment': {
|
2837 | pattern: /^([ \t]*)\/[\/*].*(?:(?:\r?\n|\r)\1[ \t]+.+)*/m,
|
2838 | lookbehind: true
|
2839 | }
|
2840 | });
|
2841 | Prism.languages.insertBefore('sass', 'atrule', {
|
2842 |
|
2843 | 'atrule-line': {
|
2844 |
|
2845 | pattern: /^(?:[ \t]*)[@+=].+/m,
|
2846 | inside: {
|
2847 | 'atrule': /(?:@[\w-]+|[+=])/m
|
2848 | }
|
2849 | }
|
2850 | });
|
2851 | delete Prism.languages.sass.atrule;
|
2852 | var variable = /\$[-\w]+|#\{\$[-\w]+\}/;
|
2853 | var operator = [/[+*\/%]|[=!]=|<=?|>=?|\b(?:and|or|not)\b/, {
|
2854 | pattern: /(\s+)-(?=\s)/,
|
2855 | lookbehind: true
|
2856 | }];
|
2857 | Prism.languages.insertBefore('sass', 'property', {
|
2858 |
|
2859 | 'variable-line': {
|
2860 | pattern: /^[ \t]*\$.+/m,
|
2861 | inside: {
|
2862 | 'punctuation': /:/,
|
2863 | 'variable': variable,
|
2864 | 'operator': operator
|
2865 | }
|
2866 | },
|
2867 |
|
2868 | 'property-line': {
|
2869 | pattern: /^[ \t]*(?:[^:\s]+ *:.*|:[^:\s]+.*)/m,
|
2870 | inside: {
|
2871 | 'property': [/[^:\s]+(?=\s*:)/, {
|
2872 | pattern: /(:)[^:\s]+/,
|
2873 | lookbehind: true
|
2874 | }],
|
2875 | 'punctuation': /:/,
|
2876 | 'variable': variable,
|
2877 | 'operator': operator,
|
2878 | 'important': Prism.languages.sass.important
|
2879 | }
|
2880 | }
|
2881 | });
|
2882 | delete Prism.languages.sass.property;
|
2883 | delete Prism.languages.sass.important;
|
2884 |
|
2885 |
|
2886 | Prism.languages.insertBefore('sass', 'punctuation', {
|
2887 | 'selector': {
|
2888 | pattern: /([ \t]*)\S(?:,?[^,\r\n]+)*(?:,(?:\r?\n|\r)\1[ \t]+\S(?:,?[^,\r\n]+)*)*/,
|
2889 | lookbehind: true
|
2890 | }
|
2891 | });
|
2892 | })(Prism);
|
2893 |
|
2894 |
|
2895 |
|
2896 | Prism.languages.scss = Prism.languages.extend('css', {
|
2897 | 'comment': {
|
2898 | pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|\/\/.*)/,
|
2899 | lookbehind: true
|
2900 | },
|
2901 | 'atrule': {
|
2902 | pattern: /@[\w-]+(?:\([^()]+\)|[^(])*?(?=\s+[{;])/,
|
2903 | inside: {
|
2904 | 'rule': /@[\w-]+/
|
2905 |
|
2906 | }
|
2907 | },
|
2908 |
|
2909 | 'url': /(?:[-a-z]+-)?url(?=\()/i,
|
2910 |
|
2911 |
|
2912 |
|
2913 |
|
2914 |
|
2915 |
|
2916 |
|
2917 | 'selector': {
|
2918 |
|
2919 | pattern: /(?=\S)[^@;{}()]?(?:[^@;{}()]|#\{\$[-\w]+\})+(?=\s*\{(?:\}|\s|[^}]+[:{][^}]+))/m,
|
2920 | inside: {
|
2921 | 'parent': {
|
2922 | pattern: /&/,
|
2923 | alias: 'important'
|
2924 | },
|
2925 | 'placeholder': /%[-\w]+/,
|
2926 | 'variable': /\$[-\w]+|#\{\$[-\w]+\}/
|
2927 | }
|
2928 | },
|
2929 | 'property': {
|
2930 | pattern: /(?:[\w-]|\$[-\w]+|#\{\$[-\w]+\})+(?=\s*:)/,
|
2931 | inside: {
|
2932 | 'variable': /\$[-\w]+|#\{\$[-\w]+\}/
|
2933 | }
|
2934 | }
|
2935 | });
|
2936 | Prism.languages.insertBefore('scss', 'atrule', {
|
2937 | 'keyword': [/@(?:if|else(?: if)?|for|each|while|import|extend|debug|warn|mixin|include|function|return|content)/i, {
|
2938 | pattern: /( +)(?:from|through)(?= )/,
|
2939 | lookbehind: true
|
2940 | }]
|
2941 | });
|
2942 | Prism.languages.insertBefore('scss', 'important', {
|
2943 |
|
2944 | 'variable': /\$[-\w]+|#\{\$[-\w]+\}/
|
2945 | });
|
2946 | Prism.languages.insertBefore('scss', 'function', {
|
2947 | 'placeholder': {
|
2948 | pattern: /%[-\w]+/,
|
2949 | alias: 'selector'
|
2950 | },
|
2951 | 'statement': {
|
2952 | pattern: /\B!(?:default|optional)\b/i,
|
2953 | alias: 'keyword'
|
2954 | },
|
2955 | 'boolean': /\b(?:true|false)\b/,
|
2956 | 'null': {
|
2957 | pattern: /\bnull\b/,
|
2958 | alias: 'keyword'
|
2959 | },
|
2960 | 'operator': {
|
2961 | pattern: /(\s)(?:[-+*\/%]|[=!]=|<=?|>=?|and|or|not)(?=\s)/,
|
2962 | lookbehind: true
|
2963 | }
|
2964 | });
|
2965 | Prism.languages.scss['atrule'].inside.rest = Prism.languages.scss;
|
2966 |
|
2967 |
|
2968 | Prism.languages.sql = {
|
2969 | 'comment': {
|
2970 | pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|(?:--|\/\/|#).*)/,
|
2971 | lookbehind: true
|
2972 | },
|
2973 | 'variable': [{
|
2974 | pattern: /@(["'`])(?:\\[\s\S]|(?!\1)[^\\])+\1/,
|
2975 | greedy: true
|
2976 | }, /@[\w.$]+/],
|
2977 | 'string': {
|
2978 | pattern: /(^|[^@\\])("|')(?:\\[\s\S]|(?!\2)[^\\]|\2\2)*\2/,
|
2979 | greedy: true,
|
2980 | lookbehind: true
|
2981 | },
|
2982 | 'function': /\b(?:AVG|COUNT|FIRST|FORMAT|LAST|LCASE|LEN|MAX|MID|MIN|MOD|NOW|ROUND|SUM|UCASE)(?=\s*\()/i,
|
2983 |
|
2984 | '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,
|
2985 | 'boolean': /\b(?:TRUE|FALSE|NULL)\b/i,
|
2986 | 'number': /\b0x[\da-f]+\b|\b\d+\.?\d*|\B\.\d+\b/i,
|
2987 | 'operator': /[-+*\/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?|\b(?:AND|BETWEEN|IN|LIKE|NOT|OR|IS|DIV|REGEXP|RLIKE|SOUNDS LIKE|XOR)\b/i,
|
2988 | 'punctuation': /[;[\]()`,.]/
|
2989 | };
|
2990 |
|
2991 |
|
2992 | (function (Prism) {
|
2993 | var inside = {
|
2994 | 'url': /url\((["']?).*?\1\)/i,
|
2995 | 'string': {
|
2996 | pattern: /("|')(?:(?!\1)[^\\\r\n]|\\(?:\r\n|[\s\S]))*\1/,
|
2997 | greedy: true
|
2998 | },
|
2999 | 'interpolation': null,
|
3000 |
|
3001 | 'func': null,
|
3002 |
|
3003 | 'important': /\B!(?:important|optional)\b/i,
|
3004 | 'keyword': {
|
3005 | pattern: /(^|\s+)(?:(?:if|else|for|return|unless)(?=\s+|$)|@[\w-]+)/,
|
3006 | lookbehind: true
|
3007 | },
|
3008 | 'hexcode': /#[\da-f]{3,6}/i,
|
3009 | 'number': /\b\d+(?:\.\d+)?%?/,
|
3010 | 'boolean': /\b(?:true|false)\b/,
|
3011 | 'operator': [
|
3012 |
|
3013 | /~|[+!\/%<>?=]=?|[-:]=|\*[*=]?|\.+|&&|\|\||\B-\B|\b(?:and|in|is(?: a| defined| not|nt)?|not|or)\b/],
|
3014 | 'punctuation': /[{}()\[\];:,]/
|
3015 | };
|
3016 | inside['interpolation'] = {
|
3017 | pattern: /\{[^\r\n}:]+\}/,
|
3018 | alias: 'variable',
|
3019 | inside: {
|
3020 | 'delimiter': {
|
3021 | pattern: /^{|}$/,
|
3022 | alias: 'punctuation'
|
3023 | },
|
3024 | rest: inside
|
3025 | }
|
3026 | };
|
3027 | inside['func'] = {
|
3028 | pattern: /[\w-]+\([^)]*\).*/,
|
3029 | inside: {
|
3030 | 'function': /^[^(]+/,
|
3031 | rest: inside
|
3032 | }
|
3033 | };
|
3034 | Prism.languages.stylus = {
|
3035 | 'comment': {
|
3036 | pattern: /(^|[^\\])(\/\*[\s\S]*?\*\/|\/\/.*)/,
|
3037 | lookbehind: true
|
3038 | },
|
3039 | 'atrule-declaration': {
|
3040 | pattern: /(^\s*)@.+/m,
|
3041 | lookbehind: true,
|
3042 | inside: {
|
3043 | 'atrule': /^@[\w-]+/,
|
3044 | rest: inside
|
3045 | }
|
3046 | },
|
3047 | 'variable-declaration': {
|
3048 | pattern: /(^[ \t]*)[\w$-]+\s*.?=[ \t]*(?:(?:\{[^}]*\}|.+)|$)/m,
|
3049 | lookbehind: true,
|
3050 | inside: {
|
3051 | 'variable': /^\S+/,
|
3052 | rest: inside
|
3053 | }
|
3054 | },
|
3055 | 'statement': {
|
3056 | pattern: /(^[ \t]*)(?:if|else|for|return|unless)[ \t]+.+/m,
|
3057 | lookbehind: true,
|
3058 | inside: {
|
3059 | keyword: /^\S+/,
|
3060 | rest: inside
|
3061 | }
|
3062 | },
|
3063 | // A property/value pair cannot end with a comma or a brace
|
3064 | // It cannot have indented content unless it ended with a semicolon
|
3065 | 'property-declaration': {
|
3066 | pattern: /((?:^|\{)([ \t]*))(?:[\w-]|\{[^}\r\n]+\})+(?:\s*:\s*|[ \t]+)[^{\r\n]*(?:;|[^{\r\n,](?=$)(?!(\r?\n|\r)(?:\{|\2[ \t]+)))/m,
|
3067 | lookbehind: true,
|
3068 | inside: {
|
3069 | 'property': {
|
3070 | pattern: /^[^\s:]+/,
|
3071 | inside: {
|
3072 | 'interpolation': inside.interpolation
|
3073 | }
|
3074 | },
|
3075 | rest: inside
|
3076 | }
|
3077 | },
|
3078 | // A selector can contain parentheses only as part of a pseudo-element
|
3079 | // It can span multiple lines.
|
3080 | // It must end with a comma or an accolade or have indented content.
|
3081 | 'selector': {
|
3082 | 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,
|
3083 | lookbehind: true,
|
3084 | inside: {
|
3085 | 'interpolation': inside.interpolation,
|
3086 | 'punctuation': /[{},]/
|
3087 | }
|
3088 | },
|
3089 | 'func': inside.func,
|
3090 | 'string': inside.string,
|
3091 | 'interpolation': inside.interpolation,
|
3092 | 'punctuation': /[{}()\[\];:.]/
|
3093 | };
|
3094 | })(Prism);
|
3095 | /* "prismjs/components/prism-wasm" */
|
3096 |
|
3097 |
|
3098 | Prism.languages.wasm = {
|
3099 | 'comment': [/\(;[\s\S]*?;\)/, {
|
3100 | pattern: /;;.*/,
|
3101 | greedy: true
|
3102 | }],
|
3103 | 'string': {
|
3104 | pattern: /"(?:\\[\s\S]|[^"\\])*"/,
|
3105 | greedy: true
|
3106 | },
|
3107 | 'keyword': [{
|
3108 | pattern: /\b(?:align|offset)=/,
|
3109 | inside: {
|
3110 | 'operator': /=/
|
3111 | }
|
3112 | }, {
|
3113 | 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/,
|
3114 | inside: {
|
3115 | 'punctuation': /\./
|
3116 | }
|
3117 | }, /\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/],
|
3118 | 'variable': /\$[\w!#$%&'*+\-./:<=>?@\\^_`|~]+/i,
|
3119 | '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/,
|
3120 | 'punctuation': /[()]/
|
3121 | };
|
3122 | /* "prismjs/components/prism-yaml" */
|
3123 |
|
3124 | Prism.languages.yaml = {
|
3125 | 'scalar': {
|
3126 | pattern: /([\-:]\s*(?:![^\s]+)?[ \t]*[|>])[ \t]*(?:((?:\r?\n|\r)[ \t]+)[^\r\n]+(?:\2[^\r\n]+)*)/,
|
3127 | lookbehind: true,
|
3128 | alias: 'string'
|
3129 | },
|
3130 | 'comment': /#.*/,
|
3131 | 'key': {
|
3132 | pattern: /(\s*(?:^|[:\-,[{\r\n?])[ \t]*(?:![^\s]+)?[ \t]*)[^\r\n{[\]},#\s]+?(?=\s*:\s)/,
|
3133 | lookbehind: true,
|
3134 | alias: 'atrule'
|
3135 | },
|
3136 | 'directive': {
|
3137 | pattern: /(^[ \t]*)%.+/m,
|
3138 | lookbehind: true,
|
3139 | alias: 'important'
|
3140 | },
|
3141 | 'datetime': {
|
3142 | 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,
|
3143 | lookbehind: true,
|
3144 | alias: 'number'
|
3145 | },
|
3146 | 'boolean': {
|
3147 | pattern: /([:\-,[{]\s*(?:![^\s]+)?[ \t]*)(?:true|false)[ \t]*(?=$|,|]|})/im,
|
3148 | lookbehind: true,
|
3149 | alias: 'important'
|
3150 | },
|
3151 | 'null': {
|
3152 | pattern: /([:\-,[{]\s*(?:![^\s]+)?[ \t]*)(?:null|~)[ \t]*(?=$|,|]|})/im,
|
3153 | lookbehind: true,
|
3154 | alias: 'important'
|
3155 | },
|
3156 | 'string': {
|
3157 | pattern: /([:\-,[{]\s*(?:![^\s]+)?[ \t]*)("|')(?:(?!\2)[^\\\r\n]|\\.)*\2(?=[ \t]*(?:$|,|]|}|\s*#))/m,
|
3158 | lookbehind: true,
|
3159 | greedy: true
|
3160 | },
|
3161 | 'number': {
|
3162 | pattern: /([:\-,[{]\s*(?:![^\s]+)?[ \t]*)[+-]?(?:0x[\da-f]+|0o[0-7]+|(?:\d+\.?\d*|\.?\d+)(?:e[+-]?\d+)?|\.inf|\.nan)[ \t]*(?=$|,|]|})/im,
|
3163 | lookbehind: true
|
3164 | },
|
3165 | 'tag': /![^\s]+/,
|
3166 | 'important': /[&*][\w]+/,
|
3167 | 'punctuation': /---|[:[\]{}\-,|>?]|\.\.\./
|
3168 | };
|
3169 | Prism.languages.yml = Prism.languages.yaml;
|
3170 |
|
3171 | module.exports = Prism;
|
3172 |
|
\ | No newline at end of file |