From e7087af22088569e99c0dd064fd887ba6846d0ec Mon Sep 17 00:00:00 2001 From: Jon Wolfe Date: Sat, 15 Oct 2016 14:13:20 -0400 Subject: [PATCH 1/3] Fix HTML Entities regex was too greedy and broke other grammars --- grammars/html.cson | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grammars/html.cson b/grammars/html.cson index 59bb33d..5117d54 100644 --- a/grammars/html.cson +++ b/grammars/html.cson @@ -363,7 +363,7 @@ 'entities': 'patterns': [ { - 'begin': '(&)([a-zA-Z0-9]+|#[0-9]+|#x[0-9a-fA-F]+)' + 'begin': '(&)([a-zA-Z0-9]+|#[0-9]+|#x[0-9a-fA-F]+)(?=;)' 'beginCaptures': '1': 'name': 'punctuation.definition.entity.begin.html' From 91a3eeb484331613f8e24b788c43a4d99c98d982 Mon Sep 17 00:00:00 2001 From: Jon Wolfe Date: Sun, 16 Oct 2016 00:25:19 -0400 Subject: [PATCH 2/3] swap to match from begin/end --- grammars/html.cson | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/grammars/html.cson b/grammars/html.cson index 5117d54..1a21e67 100644 --- a/grammars/html.cson +++ b/grammars/html.cson @@ -363,15 +363,13 @@ 'entities': 'patterns': [ { - 'begin': '(&)([a-zA-Z0-9]+|#[0-9]+|#x[0-9a-fA-F]+)(?=;)' - 'beginCaptures': + 'match': '(&)([a-zA-Z0-9]+|#[0-9]+|#x[0-9a-fA-F]+)(;)' + 'captures': '1': 'name': 'punctuation.definition.entity.begin.html' '2': 'name': 'entity.name.entity.other.html' - 'end': ';' - 'endCaptures': - '0': + '3': 'name': 'punctuation.definition.entity.end.html' 'name': 'constant.character.entity.html' } From cdd621f8bc9ead71ab235cf9a89eb19239094c4b Mon Sep 17 00:00:00 2001 From: Jon Wolfe Date: Sun, 16 Oct 2016 00:58:01 -0400 Subject: [PATCH 3/3] update spec --- spec/html-spec.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/html-spec.coffee b/spec/html-spec.coffee index b3476a3..ef91223 100644 --- a/spec/html-spec.coffee +++ b/spec/html-spec.coffee @@ -108,7 +108,7 @@ describe 'HTML grammar', -> 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'] + expect(tokens[7]).toEqual value: 'a', scopes: ['text.html.basic'] describe "firstLineMatch", -> it "recognises HTML5 doctypes", ->