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

Improve entity scopes and related spec #98

Merged
merged 2 commits into from
Aug 15, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does the 3rd & get tokenized as? I'm guessing illegal?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@50Wliu I think it is a not yet completed entity. If you have more suggestions just tell me because I don't have experience with this package.


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