Merge pull request #2516 from ajaxorg/fix/highlighter

fix highlighting of tables in Gherkin  mode
This commit is contained in:
Harutyun Amirjanyan 2015-05-31 16:45:58 +04:00
commit 652dd7009c
2 changed files with 53 additions and 49 deletions

View file

@ -56,34 +56,34 @@
],[ ],[
"start", "start",
["text"," "], ["text"," "],
["comment","| "], ["comment","|"],
["string","start "], ["string"," start "],
["comment","| "], ["comment","|"],
["string","eat "], ["string"," eat "],
["comment","| "], ["comment","|"],
["string","left "], ["string"," left "],
["comment","|"] ["comment","|"]
],[ ],[
"start", "start",
["text"," "], ["text"," "],
["comment","| "], ["comment","|"],
["string"," 12 "], ["string"," 12 "],
["comment","| "], ["comment","|"],
["string"," 5 "], ["string"," 5 "],
["comment","| "], ["comment","|"],
["string"," 7 "], ["string"," 7 "],
["comment","|"] ["comment","|"]
],[ ],[
"start", "start",
["text"," "], ["text"," "],
["comment","| "], ["comment","|"],
["string"," 20 "], ["string"," 20 "],
["comment","| "], ["comment","|"],
["string"," 5 "], ["string"," 5 "],
["comment","| "], ["comment","|"],
["string"," 15 "], ["string"," 15 "],
["comment","| "], ["comment","|"],
["string"," "] ["string"," "]
],[ ],[
"start" "start"
],[ ],[

View file

@ -36,18 +36,18 @@ var stringEscape = "\\\\(x[0-9A-Fa-f]{2}|[0-7]{3}|[\\\\abfnrtv'\"]|U[0-9A-Fa-f]
var GherkinHighlightRules = function() { var GherkinHighlightRules = function() {
// need to include constant ints // need to include constant ints
this.$rules = { this.$rules = {
start : [{ start : [{
token: 'constant.numeric', token: 'constant.numeric',
regex: "(?:(?:[1-9]\\d*)|(?:0))" regex: "(?:(?:[1-9]\\d*)|(?:0))"
}, { }, {
token : "comment", token : "comment",
regex : "#.*$" regex : "#.*$"
}, { }, {
token : "keyword", token : "keyword",
regex : "Feature:|Background:|Scenario:|Scenario\ Outline:|Examples:|Given|When|Then|And|But|\\*", regex : "Feature:|Background:|Scenario:|Scenario\ Outline:|Examples:|Given|When|Then|And|But|\\*",
}, { }, {
token : "string", // multi line """ string start token : "string", // multi line """ string start
regex : '"{3}', regex : '"{3}',
next : "qqstring3" next : "qqstring3"
@ -56,22 +56,22 @@ var GherkinHighlightRules = function() {
regex : '"', regex : '"',
next : "qqstring" next : "qqstring"
}, { }, {
token : "comment", token : "comment",
regex : "@[A-Za-z0-9]+", regex : "@[A-Za-z0-9]+",
next : "start" next : "start"
}, { }, {
token : "comment", token : "comment",
regex : "<.+>" regex : "<.+>"
}, { }, {
token : "comment", token : "comment",
regex : "\\| ", regex : "\\|(?=.)",
next : "table-item" next : "table-item"
}, { }, {
token : "comment", token : "comment",
regex : "\\|$", regex : "\\|$",
next : "start" next : "start"
}], }],
"qqstring3" : [ { "qqstring3" : [ {
token : "constant.language.escape", token : "constant.language.escape",
regex : stringEscape regex : stringEscape
}, { }, {
@ -81,7 +81,7 @@ var GherkinHighlightRules = function() {
}, { }, {
defaultToken : "string" defaultToken : "string"
}], }],
"qqstring" : [{ "qqstring" : [{
token : "constant.language.escape", token : "constant.language.escape",
regex : stringEscape regex : stringEscape
}, { }, {
@ -96,15 +96,19 @@ var GherkinHighlightRules = function() {
defaultToken: "string" defaultToken: "string"
}], }],
"table-item" : [{ "table-item" : [{
token : "comment",
regex : /$/,
next : "start"
}, {
token : "comment",
regex : /\|/
}, {
token : "string", token : "string",
regex : "[A-Za-z0-9 ]*", regex : /\\./
next : "start" }, {
}], defaultToken : "string"
}]
}; };
//new TextHighlightRules().getRules();
} }
oop.inherits(GherkinHighlightRules, TextHighlightRules); oop.inherits(GherkinHighlightRules, TextHighlightRules);