Skip to content

Commit 14d5b90

Browse files
velocity
1 parent 57320c0 commit 14d5b90

File tree

1 file changed

+49
-50
lines changed

1 file changed

+49
-50
lines changed

src/languages/velocity.js

Lines changed: 49 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
import { insertBefore } from '../util/language-util.js';
21
import markup from './markup.js';
32

43
/** @type {import('../types.d.ts').LanguageProto<'velocity'>} */
54
export default {
65
id: 'velocity',
76
base: markup,
8-
grammar ({ base }) {
7+
grammar () {
98
const vel = {
109
'variable': {
1110
pattern:
@@ -34,59 +33,59 @@ export default {
3433
'punctuation': vel['punctuation'],
3534
};
3635

37-
insertBefore(base, 'comment', {
38-
'unparsed': {
39-
pattern: /(^|[^\\])#\[\[[\s\S]*?\]\]#/,
40-
lookbehind: true,
41-
greedy: true,
42-
inside: {
43-
'punctuation': /^#\[\[|\]\]#$/,
36+
return {
37+
$merge: {
38+
'tag': {
39+
inside: {
40+
'attr-value': {
41+
inside: {
42+
$rest: 'velocity',
43+
},
44+
},
45+
},
4446
},
4547
},
46-
'velocity-comment': [
47-
{
48-
pattern: /(^|[^\\])#\*[\s\S]*?\*#/,
49-
lookbehind: true,
50-
greedy: true,
51-
alias: 'comment',
52-
},
53-
{
54-
pattern: /(^|[^\\])##.*/,
55-
lookbehind: true,
56-
greedy: true,
57-
alias: 'comment',
58-
},
59-
],
60-
'directive': {
61-
pattern:
62-
/(^|[^\\](?:\\\\)*)#@?(?:[a-z][\w-]*|\{[a-z][\w-]*\})(?:\s*\((?:[^()]|\([^()]*\))*\))?/i,
63-
lookbehind: true,
64-
inside: /** @type {Grammar} */ ({
65-
'keyword': {
66-
pattern: /^#@?(?:[a-z][\w-]*|\{[a-z][\w-]*\})|\bin\b/,
48+
$insertBefore: {
49+
'comment': {
50+
'unparsed': {
51+
pattern: /(^|[^\\])#\[\[[\s\S]*?\]\]#/,
52+
lookbehind: true,
53+
greedy: true,
54+
inside: {
55+
'punctuation': /^#\[\[|\]\]#$/,
56+
},
57+
},
58+
'velocity-comment': [
59+
{
60+
pattern: /(^|[^\\])#\*[\s\S]*?\*#/,
61+
lookbehind: true,
62+
greedy: true,
63+
alias: 'comment',
64+
},
65+
{
66+
pattern: /(^|[^\\])##.*/,
67+
lookbehind: true,
68+
greedy: true,
69+
alias: 'comment',
70+
},
71+
],
72+
'directive': {
73+
pattern:
74+
/(^|[^\\](?:\\\\)*)#@?(?:[a-z][\w-]*|\{[a-z][\w-]*\})(?:\s*\((?:[^()]|\([^()]*\))*\))?/i,
75+
lookbehind: true,
6776
inside: {
68-
'punctuation': /[{}]/,
77+
'keyword': {
78+
pattern: /^#@?(?:[a-z][\w-]*|\{[a-z][\w-]*\})|\bin\b/,
79+
inside: {
80+
'punctuation': /[{}]/,
81+
},
82+
},
83+
$rest: vel,
6984
},
7085
},
71-
$rest: /** @type {Grammar['$rest']} */ (vel),
72-
}),
86+
'variable': vel['variable'],
87+
},
7388
},
74-
'variable': vel['variable'],
75-
});
76-
77-
/** @type {Grammar} */ (
78-
/** @type {GrammarToken} */ (
79-
/** @type {Grammar} */ (/** @type {GrammarToken} */ (base['tag']).inside)[
80-
'attr-value'
81-
]
82-
).inside
83-
).$rest = 'velocity';
84-
85-
return {};
89+
};
8690
},
8791
};
88-
89-
/**
90-
* @typedef {import('../types.d.ts').Grammar} Grammar
91-
* @typedef {import('../types.d.ts').GrammarToken} GrammarToken
92-
*/

0 commit comments

Comments
 (0)