1 | Prism.languages.javascript = Prism.languages.extend('clike', {
|
2 | 'keyword': /\b(as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|false|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|true|try|typeof|var|void|while|with|yield)\b/,
|
3 | 'number': /\b-?(0x[\dA-Fa-f]+|0b[01]+|0o[0-7]+|\d*\.?\d+([Ee][+-]?\d+)?|NaN|Infinity)\b/,
|
4 | 'function': /(?!\d)[a-z0-9_$]+(?=\()/i
|
5 | });
|
6 |
|
7 | Prism.languages.insertBefore('javascript', 'keyword', {
|
8 | 'regex': {
|
9 | pattern: /(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\\\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})]))/,
|
10 | lookbehind: true
|
11 | }
|
12 | });
|
13 |
|
14 | Prism.languages.insertBefore('javascript', 'class-name', {
|
15 | 'template-string': {
|
16 | pattern: /`(?:\\`|\\?[^`])*`/,
|
17 | inside: {
|
18 | 'interpolation': {
|
19 | pattern: /\$\{[^}]+\}/,
|
20 | inside: {
|
21 | 'interpolation-punctuation': {
|
22 | pattern: /^\$\{|\}$/,
|
23 | alias: 'punctuation'
|
24 | },
|
25 | rest: Prism.languages.javascript
|
26 | }
|
27 | },
|
28 | 'string': /[\s\S]+/
|
29 | }
|
30 | }
|
31 | });
|
32 |
|
33 | if (Prism.languages.markup) {
|
34 | Prism.languages.insertBefore('markup', 'tag', {
|
35 | 'script': {
|
36 | pattern: /<script[\w\W]*?>[\w\W]*?<\/script>/i,
|
37 | inside: {
|
38 | 'tag': {
|
39 | pattern: /<script[\w\W]*?>|<\/script>/i,
|
40 | inside: Prism.languages.markup.tag.inside
|
41 | },
|
42 | rest: Prism.languages.javascript
|
43 | },
|
44 | alias: 'language-javascript'
|
45 | }
|
46 | });
|
47 | }
|