Skip to content

Commit 8735a7a

Browse files
author
Erik Lieben
committed
fix(highlight): containerless, compile-spy, and view-spy regex add foward lookahead for ' ' or '>', resolves #35
1 parent 16ca230 commit 8735a7a

4 files changed

Lines changed: 54 additions & 5 deletions

File tree

syntaxes/html.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -373,23 +373,23 @@
373373
}
374374
},
375375
"tag-aurelia-containerless-attribute" : {
376-
"match": "(containerless)( |>)",
376+
"match": "(containerless)(?= |>)",
377377
"captures": {
378378
"1": {
379379
"name": "containerless.attribute.html.au"
380380
}
381381
}
382382
},
383383
"tag-aurelia-compile-spy-attribute" : {
384-
"match": "(compile-spy)( |>)",
384+
"match": "(compile-spy)(?= |>)",
385385
"captures": {
386386
"1": {
387387
"name": "compile-spy.attribute.html.au"
388388
}
389389
}
390390
},
391391
"tag-aurelia-view-spy-attribute" : {
392-
"match": "(view-spy)( |>)",
392+
"match": "(view-spy)(?= |>)",
393393
"captures": {
394394
"1": {
395395
"name": "view-spy.attribute.html.au"

test/syntax.html/compile-spy.test.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { assert } from 'chai';
2-
import { getTokenOnCharRange, hasScope, tokenizeLine } from './test.utils';
2+
import { getTokenOnCharRange, hasScope, tokenizeLine, writeOut } from './test.utils';
33

44
describe('The Aurelia HTML syntax compile-spy attribute', () => {
55

@@ -47,7 +47,7 @@ describe('The Aurelia HTML syntax compile-spy attribute', () => {
4747

4848
});
4949

50-
it('must not tokenize foo-containerles="" attribute', () => {
50+
it('must not tokenize foo-compile-spy="" attribute', () => {
5151

5252
// arrange
5353
let scope = 'compile-spy.attribute.html.au';
@@ -91,4 +91,20 @@ describe('The Aurelia HTML syntax compile-spy attribute', () => {
9191
assert.isNotOk(hasScope(token.scopes, scope));
9292

9393
});
94+
95+
it('must tokenize compile-spy attribute', () => {
96+
97+
// arrange
98+
let scope = 'compile-spy.attribute.html.au';
99+
100+
// act
101+
let template = '<template compile-spy></template>';
102+
let lineToken = tokenizeLine(template);
103+
104+
// assert
105+
let token = getTokenOnCharRange(lineToken, 10, 21);
106+
assert.isDefined(token);
107+
assert.isOk(hasScope(token.scopes, scope));
108+
109+
});
94110
});

test/syntax.html/containerless.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,21 @@ describe('The Aurelia HTML syntax containerles attribute', () => {
9191
assert.isNotOk(hasScope(token.scopes, scope));
9292

9393
});
94+
95+
it('must tokenize containerless attribute', () => {
96+
97+
// arrange
98+
let scope = 'containerless.attribute.html.au';
99+
100+
// act
101+
let template = '<template containerless></template>';
102+
let lineToken = tokenizeLine(template);
103+
104+
// assert
105+
let token = getTokenOnCharRange(lineToken, 10, 23);
106+
assert.isDefined(token);
107+
assert.isOk(hasScope(token.scopes, scope));
108+
109+
});
110+
94111
});

test/syntax.html/view-spy.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,20 @@ describe('The Aurelia HTML syntax view-spy attribute', () => {
9191
assert.isNotOk(hasScope(token.scopes, scope));
9292

9393
});
94+
95+
it('must tokenize compile-spy attribute', () => {
96+
97+
// arrange
98+
let scope = 'view-spy.attribute.html.au';
99+
100+
// act
101+
let template = '<template view-spy></template>';
102+
let lineToken = tokenizeLine(template);
103+
104+
// assert
105+
let token = getTokenOnCharRange(lineToken, 10, 18);
106+
assert.isDefined(token);
107+
assert.isOk(hasScope(token.scopes, scope));
108+
109+
});
94110
});

0 commit comments

Comments
 (0)