UNPKG

1.7 kBJavaScriptView Raw
1(function (Prism) {
2 Prism.languages.velocity = Prism.languages.extend('markup', {});
3
4 var velocity = {
5 'variable': {
6 pattern: /(^|[^\\](?:\\\\)*)\$!?(?:[a-z][\w-]*(?:\([^)]*\))?(?:\.[a-z][\w-]*(?:\([^)]*\))?|\[[^\]]+])*|{[^}]+})/i,
7 lookbehind: true,
8 inside: {} // See below
9 },
10 'string': {
11 pattern: /"[^"]*"|'[^']*'/,
12 greedy: true
13 },
14 'number': /\b\d+\b/,
15 'boolean': /\b(?:true|false)\b/,
16 'operator': /[=!<>]=?|[+*/%-]|&&|\|\||\.\.|\b(?:eq|g[et]|l[et]|n(?:e|ot))\b/,
17 'punctuation': /[(){}[\]:,.]/
18 };
19
20 velocity.variable.inside = {
21 'string': velocity['string'],
22 'function': {
23 pattern: /([^\w-])[a-z][\w-]*(?=\()/,
24 lookbehind: true
25 },
26 'number': velocity['number'],
27 'boolean': velocity['boolean'],
28 'punctuation': velocity['punctuation']
29 };
30
31 Prism.languages.insertBefore('velocity', 'comment', {
32 'unparsed': {
33 pattern: /(^|[^\\])#\[\[[\s\S]*?]]#/,
34 lookbehind: true,
35 greedy: true,
36 inside: {
37 'punctuation': /^#\[\[|]]#$/
38 }
39 },
40 'velocity-comment': [
41 {
42 pattern: /(^|[^\\])#\*[\s\S]*?\*#/,
43 lookbehind: true,
44 greedy: true,
45 alias: 'comment'
46 },
47 {
48 pattern: /(^|[^\\])##.*/,
49 lookbehind: true,
50 greedy: true,
51 alias: 'comment'
52 }
53 ],
54 'directive': {
55 pattern: /(^|[^\\](?:\\\\)*)#@?(?:[a-z][\w-]*|{[a-z][\w-]*})(?:\s*\((?:[^()]|\([^()]*\))*\))?/i,
56 lookbehind: true,
57 inside: {
58 'keyword': {
59 pattern: /^#@?(?:[a-z][\w-]*|{[a-z][\w-]*})|\bin\b/,
60 inside: {
61 'punctuation': /[{}]/
62 }
63 },
64 rest: velocity
65 }
66 },
67 'variable': velocity['variable']
68 });
69
70 Prism.languages.velocity['tag'].inside['attr-value'].inside.rest = Prism.languages.velocity;
71
72}(Prism));