Skip to content
This repository has been archived by the owner on Sep 8, 2020. It is now read-only.

Commit

Permalink
normalizing attribute for syntax highlight
Browse files Browse the repository at this point in the history
related #44
  • Loading branch information
outsideris committed Oct 9, 2015
1 parent 57ef98c commit 33b937e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion grammars/angularjs.cson
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
{ 'include': 'source.js' }
]
'angular-directive-attribute':
'begin': '\\b((?i:ng-(' +
'begin': '\\b((?i:(data-|x-)?ng(-|_|:)(' +
'animate-children|app|' +
'bind|bind-html|bind-template|blur|' +
'change|checked|class|class-even|class-odd|click|cloak|controller|copy|csp|cut|' +
Expand Down
29 changes: 29 additions & 0 deletions spec/grammar-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,35 @@ describe 'directive grammar', ->
expect(lines[0][1]).toEqual value: 'NG-INCLUDE', scopes: ['text.html.angular', 'meta.tag.block.any.html', 'entity.name.tag.block.any.html.angular']
expect(lines[0][5]).toEqual value: 'NG-INCLUDE', scopes: ['text.html.angular', 'meta.tag.block.any.html', 'entity.name.tag.block.any.html.angular']

describe 'normalization angular tag and attribute', ->
it 'tokenizes data- prefixed angular attributes', ->
lines = grammar.tokenizeLines '''
<body data-ng-controller="TestCtrl">
'''

expect(lines[0][3]).toEqual value: 'data-ng-controller', scopes: ['text.html.angular', 'meta.tag.inline.any.html', 'meta.attribute.html.angular', 'entity.other.attribute-name.html.angular']

it 'tokenizes x- prefixed angular attributes', ->
lines = grammar.tokenizeLines '''
<body x-ng-controller="TestCtrl">
'''

expect(lines[0][3]).toEqual value: 'x-ng-controller', scopes: ['text.html.angular', 'meta.tag.inline.any.html', 'meta.attribute.html.angular', 'entity.other.attribute-name.html.angular']

it 'tokenizes _ suffixed angular attributes', ->
lines = grammar.tokenizeLines '''
<body ng_controller="TestCtrl">
'''

expect(lines[0][3]).toEqual value: 'ng_controller', scopes: ['text.html.angular', 'meta.tag.inline.any.html', 'meta.attribute.html.angular', 'entity.other.attribute-name.html.angular']

it 'tokenizes : suffixed angular attributes', ->
lines = grammar.tokenizeLines '''
<body ng:controller="TestCtrl">
'''

expect(lines[0][3]).toEqual value: 'ng:controller', scopes: ['text.html.angular', 'meta.tag.inline.any.html', 'meta.attribute.html.angular', 'entity.other.attribute-name.html.angular']

describe 'angular expression', ->
it 'tokenizes angular expressions in HTML tags', ->
lines = grammar.tokenizeLines '''
Expand Down

0 comments on commit 33b937e

Please sign in to comment.