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