Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Commit c55d62d

Browse files
author
Wliu
authored
Merge pull request #98 from DavidePastore/add-entity-scope
Improve entity scopes and related spec
2 parents 316113d + 2868437 commit c55d62d

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

grammars/html.cson

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -350,12 +350,16 @@
350350
'entities':
351351
'patterns': [
352352
{
353-
'captures':
353+
'begin': '(&)([a-zA-Z0-9]+|#[0-9]+|#x[0-9a-fA-F]+)'
354+
'beginCaptures':
354355
'1':
355-
'name': 'punctuation.definition.entity.html'
356-
'3':
357-
'name': 'punctuation.definition.entity.html'
358-
'match': '(&)([a-zA-Z0-9]+|#[0-9]+|#x[0-9a-fA-F]+)(;)'
356+
'name': 'punctuation.definition.entity.begin.html'
357+
'2':
358+
'name': 'entity.name.entity.other.html'
359+
'end': ';'
360+
'endCaptures':
361+
'0':
362+
'name': 'punctuation.definition.entity.end.html'
359363
'name': 'constant.character.entity.html'
360364
}
361365
{

spec/html-spec.coffee

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,12 @@ describe 'HTML grammar', ->
100100

101101
grammarTest path.join(__dirname, 'fixtures/syntax_test_html.html')
102102
grammarTest path.join(__dirname, 'fixtures/syntax_test_html_template_fragments.html')
103+
104+
describe "entities", ->
105+
it "tokenizes & and characters after it", ->
106+
{tokens} = grammar.tokenizeLine '& & &a'
107+
108+
expect(tokens[0]).toEqual value: '&', scopes: ['text.html.basic', 'invalid.illegal.bad-ampersand.html']
109+
expect(tokens[3]).toEqual value: 'amp', scopes: ['text.html.basic', 'constant.character.entity.html', 'entity.name.entity.other.html']
110+
expect(tokens[4]).toEqual value: ';', scopes: ['text.html.basic', 'constant.character.entity.html', 'punctuation.definition.entity.end.html']
111+
expect(tokens[7]).toEqual value: 'a', scopes: ['text.html.basic', 'constant.character.entity.html', 'entity.name.entity.other.html']

0 commit comments

Comments
 (0)