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

Commit 9d40ea9

Browse files
committed
normalizing tagName for syntax highlight
related #44
1 parent 33b937e commit 9d40ea9

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

grammars/angularjs.cson

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
]
1111
'patterns': [
1212
{
13-
'begin': '(</?)((?i:ng-(form|include|pluralize|transclude|view|messages|message))\\b)'
13+
'begin': '(</?)((?i:(data-|x-)?ng(-|_|:)(form|include|pluralize|transclude|view|messages|message))\\b)'
1414
'beginCaptures':
1515
'1':
1616
'name': 'punctuation.definition.tag.begin.html'

spec/grammar-spec.coffee

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,38 @@ describe 'directive grammar', ->
111111

112112
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']
113113

114+
it 'tokenizes data- prefixed angular element', ->
115+
lines = grammar.tokenizeLines '''
116+
<data-ng-include src=""></data-ng-include>
117+
'''
118+
119+
expect(lines[0][1]).toEqual value: 'data-ng-include', scopes: ['text.html.angular', 'meta.tag.block.any.html', 'entity.name.tag.block.any.html.angular']
120+
expect(lines[0][5]).toEqual value: 'data-ng-include', scopes: ['text.html.angular', 'meta.tag.block.any.html', 'entity.name.tag.block.any.html.angular']
121+
122+
it 'tokenizes x- prefixed angular element', ->
123+
lines = grammar.tokenizeLines '''
124+
<x-ng-include src=""></x-ng-include>
125+
'''
126+
127+
expect(lines[0][1]).toEqual value: 'x-ng-include', scopes: ['text.html.angular', 'meta.tag.block.any.html', 'entity.name.tag.block.any.html.angular']
128+
expect(lines[0][5]).toEqual value: 'x-ng-include', scopes: ['text.html.angular', 'meta.tag.block.any.html', 'entity.name.tag.block.any.html.angular']
129+
130+
it 'tokenizes _ suffixed angular element', ->
131+
lines = grammar.tokenizeLines '''
132+
<ng_include src=""></ng_include>
133+
'''
134+
135+
expect(lines[0][1]).toEqual value: 'ng_include', scopes: ['text.html.angular', 'meta.tag.block.any.html', 'entity.name.tag.block.any.html.angular']
136+
expect(lines[0][5]).toEqual value: 'ng_include', scopes: ['text.html.angular', 'meta.tag.block.any.html', 'entity.name.tag.block.any.html.angular']
137+
138+
it 'tokenizes : suffixed angular element', ->
139+
lines = grammar.tokenizeLines '''
140+
<ng:include src=""></ng:include>
141+
'''
142+
143+
expect(lines[0][1]).toEqual value: 'ng:include', scopes: ['text.html.angular', 'meta.tag.block.any.html', 'entity.name.tag.block.any.html.angular']
144+
expect(lines[0][5]).toEqual value: 'ng:include', scopes: ['text.html.angular', 'meta.tag.block.any.html', 'entity.name.tag.block.any.html.angular']
145+
114146
describe 'angular expression', ->
115147
it 'tokenizes angular expressions in HTML tags', ->
116148
lines = grammar.tokenizeLines '''

0 commit comments

Comments
 (0)