Skip to content

Commit

Permalink
feat(syntax-highlight): Add the let command, resolves #55 (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
Erik Lieben authored Dec 29, 2017
1 parent b143ce8 commit 5bcdfce
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 1 deletion.
26 changes: 25 additions & 1 deletion syntaxes/html.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
{
"include": "#router-view.html.au"
},
{
"include": "#let.html.au"
},
{
"include": "#meta.tag.block.any.html"
},
Expand Down Expand Up @@ -122,6 +125,27 @@
"include": "#tag-stuff"
}]
},
"let.html.au": {
"begin": "(<\/?)((?i:let)\\b)",
"beginCaptures": {
"1": {
"name": "punctuation.definition.tag.begin.html"
},
"2": {
"name": "let.element.html.au"
}
},
"end": "(>)",
"endCaptures": {
"1": {
"name": "punctuation.definition.tag.end.html"
}
},
"name": "meta.tag.inline.any.html",
"patterns": [{
"include": "#tag-stuff"
}]
},
"meta.tag.other.html": {
"begin": "(<\/?)([a-zA-Z0-9:\\-]+)",
"beginCaptures": {
Expand Down Expand Up @@ -516,4 +540,4 @@
}
},
"scopeName": "au.html"
}
}
34 changes: 34 additions & 0 deletions test/syntax.html/let.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { assert } from 'chai';
import { getTokenOnCharRange, hasScope, tokenizeLine } from './test.utils';

describe('The Aurelia HTML syntax let element', () => {

it('must tokenize let start element with scope "let.element.html.au"', () => {

// arrange
let scope = 'let.element.html.au';

// act
let lineToken = tokenizeLine('<let>');

// assert
let token = getTokenOnCharRange(lineToken, 1, 4);
assert.isOk(hasScope(token.scopes, scope));

});

it('must tokenize let end element with scope "let.element.html.au"', () => {

// arrange
let scope = 'let.element.html.au';

// act
let lineToken = tokenizeLine('</let>');

// assert
let token = getTokenOnCharRange(lineToken, 2, 5);
assert.isOk(hasScope(token.scopes, scope));

});

});

0 comments on commit 5bcdfce

Please sign in to comment.