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