From dc94855e1a15fe0872ad8c6329f3eefe72057ca2 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Sun, 7 Apr 2013 15:07:57 -0700 Subject: [PATCH] Parse emoji start, word, and end into different scopes --- src/packages/gfm/grammars/gfm.cson | 6 +++++- src/packages/gfm/spec/gfm-spec.coffee | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/packages/gfm/grammars/gfm.cson b/src/packages/gfm/grammars/gfm.cson index be815f5ca..ff77790d0 100644 --- a/src/packages/gfm/grammars/gfm.cson +++ b/src/packages/gfm/grammars/gfm.cson @@ -34,8 +34,12 @@ 'name': 'markup.heading.gfm' } { - 'match': '\\:[^\\:\\s]+\\:' + 'match': '(\\:)([^\\:\\s]+)(\\:)' 'name': 'string.emoji.gfm' + 'captures': + '1': 'name': 'string.emoji.start.gfm' + '2': 'name': 'string.emoji.word.gfm' + '3': 'name': 'string.emoji.end.gfm' } { 'match': '^\\s*[\\*]{3,}\\s*$' diff --git a/src/packages/gfm/spec/gfm-spec.coffee b/src/packages/gfm/spec/gfm-spec.coffee index 3ca1b3a79..39f70236a 100644 --- a/src/packages/gfm/spec/gfm-spec.coffee +++ b/src/packages/gfm/spec/gfm-spec.coffee @@ -78,7 +78,9 @@ describe "GitHub Flavored Markdown grammar", -> it "tokenizies an :emoji:", -> {tokens} = grammar.tokenizeLine("this is :no_good:") expect(tokens[0]).toEqual value: "this is ", scopes: ["source.gfm"] - expect(tokens[1]).toEqual value: ":no_good:", scopes: ["source.gfm", "string.emoji.gfm"] + expect(tokens[1]).toEqual value: ":", scopes: ["source.gfm", "string.emoji.gfm", "string.emoji.start.gfm"] + expect(tokens[2]).toEqual value: "no_good", scopes: ["source.gfm", "string.emoji.gfm", "string.emoji.word.gfm"] + expect(tokens[3]).toEqual value: ":", scopes: ["source.gfm", "string.emoji.gfm", "string.emoji.end.gfm"] {tokens} = grammar.tokenizeLine("this is :no good:") expect(tokens[0]).toEqual value: "this is :no good:", scopes: ["source.gfm"]