From 5e81d5ceb8f17a7394ca26744dec17040d4563a8 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Sat, 9 Feb 2013 16:51:41 -0800 Subject: [PATCH] Support bold and italic wrapped in underscores --- src/packages/gfm.tmbundle/Syntaxes/gfm.cson | 8 ++++++++ src/packages/gfm.tmbundle/spec/gfm-spec.coffee | 18 ++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/packages/gfm.tmbundle/Syntaxes/gfm.cson b/src/packages/gfm.tmbundle/Syntaxes/gfm.cson index 0f6f614b6..30a11c07b 100644 --- a/src/packages/gfm.tmbundle/Syntaxes/gfm.cson +++ b/src/packages/gfm.tmbundle/Syntaxes/gfm.cson @@ -12,10 +12,18 @@ 'match': '\\*\\*[^\\*]+\\*\\*' 'name': 'markup.bold.gfm' } + { + 'match': '__[^_]+__' + 'name': 'markup.bold.gfm' + } { 'match': '\\*[^\\*]+\\*' 'name': 'markup.italic.gfm' } + { + 'match': '_[^_]+_' + 'name': 'markup.italic.gfm' + } { 'match': '^#{1,6}\\s+.+$' 'name': 'markup.heading.gfm' diff --git a/src/packages/gfm.tmbundle/spec/gfm-spec.coffee b/src/packages/gfm.tmbundle/spec/gfm-spec.coffee index 6b3ed853e..70e24d913 100644 --- a/src/packages/gfm.tmbundle/spec/gfm-spec.coffee +++ b/src/packages/gfm.tmbundle/spec/gfm-spec.coffee @@ -22,6 +22,15 @@ describe "GitHub Flavored Markdown grammar", -> expect(tokens[1]).toEqual value: "**bold**", scopes: ["source.gfm", "markup.bold.gfm"] expect(tokens[2]).toEqual value: " text", scopes: ["source.gfm"] + it "tokenizes __bold__ text", -> + {tokens} = grammar.tokenizeLine("____") + expect(tokens[0]).toEqual value: "____", scopes: ["source.gfm"] + + {tokens} = grammar.tokenizeLine("this is __bold__ text") + expect(tokens[0]).toEqual value: "this is ", scopes: ["source.gfm"] + expect(tokens[1]).toEqual value: "__bold__", scopes: ["source.gfm", "markup.bold.gfm"] + expect(tokens[2]).toEqual value: " text", scopes: ["source.gfm"] + it "tokenizes *italic* text", -> {tokens} = grammar.tokenizeLine("**") expect(tokens[0]).toEqual value: "**", scopes: ["source.gfm"] @@ -31,6 +40,15 @@ describe "GitHub Flavored Markdown grammar", -> expect(tokens[1]).toEqual value: "*italic*", scopes: ["source.gfm", "markup.italic.gfm"] expect(tokens[2]).toEqual value: " text", scopes: ["source.gfm"] + it "tokenizes _italic_ text", -> + {tokens} = grammar.tokenizeLine("__") + expect(tokens[0]).toEqual value: "__", scopes: ["source.gfm"] + + {tokens} = grammar.tokenizeLine("this is _italic_ text") + expect(tokens[0]).toEqual value: "this is ", scopes: ["source.gfm"] + expect(tokens[1]).toEqual value: "_italic_", scopes: ["source.gfm", "markup.italic.gfm"] + expect(tokens[2]).toEqual value: " text", scopes: ["source.gfm"] + it "tokenizes a ## Heading", -> {tokens} = grammar.tokenizeLine("# Heading 1") expect(tokens[0]).toEqual value: "# Heading 1", scopes: ["source.gfm", "markup.heading.gfm"]