Support bold and italic wrapped in underscores

This commit is contained in:
Kevin Sawicki
2013-02-09 16:51:41 -08:00
parent e4da35d841
commit 5e81d5ceb8
2 changed files with 26 additions and 0 deletions

View File

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

View File

@@ -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"]