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

Commit

Permalink
Merge pull request #98 from DavidePastore/add-entity-scope
Browse files Browse the repository at this point in the history
Improve entity scopes and related spec
  • Loading branch information
Wliu authored Aug 15, 2016
2 parents 316113d + 2868437 commit c55d62d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
14 changes: 9 additions & 5 deletions grammars/html.cson
Original file line number Diff line number Diff line change
Expand Up @@ -350,12 +350,16 @@
'entities':
'patterns': [
{
'captures':
'begin': '(&)([a-zA-Z0-9]+|#[0-9]+|#x[0-9a-fA-F]+)'
'beginCaptures':
'1':
'name': 'punctuation.definition.entity.html'
'3':
'name': 'punctuation.definition.entity.html'
'match': '(&)([a-zA-Z0-9]+|#[0-9]+|#x[0-9a-fA-F]+)(;)'
'name': 'punctuation.definition.entity.begin.html'
'2':
'name': 'entity.name.entity.other.html'
'end': ';'
'endCaptures':
'0':
'name': 'punctuation.definition.entity.end.html'
'name': 'constant.character.entity.html'
}
{
Expand Down
9 changes: 9 additions & 0 deletions spec/html-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,12 @@ describe 'HTML grammar', ->

grammarTest path.join(__dirname, 'fixtures/syntax_test_html.html')
grammarTest path.join(__dirname, 'fixtures/syntax_test_html_template_fragments.html')

describe "entities", ->
it "tokenizes & and characters after it", ->
{tokens} = grammar.tokenizeLine '& & &a'

expect(tokens[0]).toEqual value: '&', scopes: ['text.html.basic', 'invalid.illegal.bad-ampersand.html']
expect(tokens[3]).toEqual value: 'amp', scopes: ['text.html.basic', 'constant.character.entity.html', 'entity.name.entity.other.html']
expect(tokens[4]).toEqual value: ';', scopes: ['text.html.basic', 'constant.character.entity.html', 'punctuation.definition.entity.end.html']
expect(tokens[7]).toEqual value: 'a', scopes: ['text.html.basic', 'constant.character.entity.html', 'entity.name.entity.other.html']

0 comments on commit c55d62d

Please sign in to comment.