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

Commit 33b937e

Browse files
committed
normalizing attribute for syntax highlight
related #44
1 parent 57ef98c commit 33b937e

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

grammars/angularjs.cson

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
{ 'include': 'source.js' }
103103
]
104104
'angular-directive-attribute':
105-
'begin': '\\b((?i:ng-(' +
105+
'begin': '\\b((?i:(data-|x-)?ng(-|_|:)(' +
106106
'animate-children|app|' +
107107
'bind|bind-html|bind-template|blur|' +
108108
'change|checked|class|class-even|class-odd|click|cloak|controller|copy|csp|cut|' +

spec/grammar-spec.coffee

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,35 @@ describe 'directive grammar', ->
8282
expect(lines[0][1]).toEqual value: 'NG-INCLUDE', scopes: ['text.html.angular', 'meta.tag.block.any.html', 'entity.name.tag.block.any.html.angular']
8383
expect(lines[0][5]).toEqual value: 'NG-INCLUDE', scopes: ['text.html.angular', 'meta.tag.block.any.html', 'entity.name.tag.block.any.html.angular']
8484

85+
describe 'normalization angular tag and attribute', ->
86+
it 'tokenizes data- prefixed angular attributes', ->
87+
lines = grammar.tokenizeLines '''
88+
<body data-ng-controller="TestCtrl">
89+
'''
90+
91+
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']
92+
93+
it 'tokenizes x- prefixed angular attributes', ->
94+
lines = grammar.tokenizeLines '''
95+
<body x-ng-controller="TestCtrl">
96+
'''
97+
98+
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']
99+
100+
it 'tokenizes _ suffixed angular attributes', ->
101+
lines = grammar.tokenizeLines '''
102+
<body ng_controller="TestCtrl">
103+
'''
104+
105+
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']
106+
107+
it 'tokenizes : suffixed angular attributes', ->
108+
lines = grammar.tokenizeLines '''
109+
<body ng:controller="TestCtrl">
110+
'''
111+
112+
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']
113+
85114
describe 'angular expression', ->
86115
it 'tokenizes angular expressions in HTML tags', ->
87116
lines = grammar.tokenizeLines '''

0 commit comments

Comments
 (0)