UNPKG

1.95 kBJavaScriptView Raw
1(function (Prism) {
2
3 var parser = Prism.languages.parser = Prism.languages.extend('markup', {
4 'keyword': {
5 pattern: /(^|[^^])(?:\^(?:case|eval|for|if|switch|throw)\b|@(?:BASE|CLASS|GET(?:_DEFAULT)?|OPTIONS|SET_DEFAULT|USE)\b)/,
6 lookbehind: true
7 },
8 'variable': {
9 pattern: /(^|[^^])\B\$(?:\w+|(?=[.{]))(?:(?:\.|::?)\w+)*(?:\.|::?)?/,
10 lookbehind: true,
11 inside: {
12 'punctuation': /\.|:+/
13 }
14 },
15 'function': {
16 pattern: /(^|[^^])\B[@^]\w+(?:(?:\.|::?)\w+)*(?:\.|::?)?/,
17 lookbehind: true,
18 inside: {
19 'keyword': {
20 pattern: /(^@)(?:GET_|SET_)/,
21 lookbehind: true
22 },
23 'punctuation': /\.|:+/
24 }
25 },
26 'escape': {
27 pattern: /\^(?:[$^;@()\[\]{}"':]|#[a-f\d]*)/i,
28 alias: 'builtin'
29 },
30 'punctuation': /[\[\](){};]/
31 });
32
33 parser = Prism.languages.insertBefore('parser', 'keyword', {
34 'parser-comment': {
35 pattern: /(\s)#.*/,
36 lookbehind: true,
37 alias: 'comment'
38 },
39 'expression': {
40 // Allow for 3 levels of depth
41 pattern: /(^|[^^])\((?:[^()]|\((?:[^()]|\((?:[^()])*\))*\))*\)/,
42 greedy: true,
43 lookbehind: true,
44 inside: {
45 'string': {
46 pattern: /(^|[^^])(["'])(?:(?!\2)[^^]|\^[\s\S])*\2/,
47 lookbehind: true
48 },
49 'keyword': parser.keyword,
50 'variable': parser.variable,
51 'function': parser.function,
52 'boolean': /\b(?:false|true)\b/,
53 'number': /\b(?:0x[a-f\d]+|\d+(?:\.\d*)?(?:e[+-]?\d+)?)\b/i,
54 'escape': parser.escape,
55 'operator': /[~+*\/\\%]|!(?:\|\|?|=)?|&&?|\|\|?|==|<[<=]?|>[>=]?|-[fd]?|\b(?:def|eq|ge|gt|in|is|le|lt|ne)\b/,
56 'punctuation': parser.punctuation
57 }
58 }
59 });
60
61 Prism.languages.insertBefore('inside', 'punctuation', {
62 'expression': parser.expression,
63 'keyword': parser.keyword,
64 'variable': parser.variable,
65 'function': parser.function,
66 'escape': parser.escape,
67 'parser-punctuation': {
68 pattern: parser.punctuation,
69 alias: 'punctuation'
70 }
71 }, parser['tag'].inside['attr-value']);
72
73}(Prism));