-
Notifications
You must be signed in to change notification settings - Fork 3.7k
/
Copy pathgherkin.js
76 lines (74 loc) · 1.84 KB
/
gherkin.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
Language: Gherkin
Author: Sam Pikesley (@pikesley) <[email protected]>
Description: Gherkin is the format for cucumber specifications. It is a domain specific language which helps you to describe business behavior without the need to go into detail of implementation.
Website: https://cucumber.io/docs/gherkin/
*/
const VARIABLE = {
scope: 'variable',
begin: /<[^>\s]+>/
};
export default function(hljs) {
return {
name: 'Gherkin',
aliases: [ 'feature' ],
// No global keywords since they're all situational
contains: [
{
// Eat whitespace at the start of the line
begin: /^[ \t]+/,
relevance: 0,
},
{
// "Business Need" and "Ability" are not part of the spec above, but are included in the English "translation"
// https://cucumber.io/docs/gherkin/languages/#gherkin-dialect-en-content
begin: [
/(Feature|Business Need|Ability|Rule|Examples?|Scenario(?:s| Outline| Template)?|Background)/,
/:/
],
beginScope: {
1: 'keyword',
2: 'punctuation',
},
end: /$/,
relevance: 10,
contains: [ VARIABLE ]
},
{
begin: /(?:Given|When|Then|And|But)\b/,
beginScope: 'keyword',
end: /$/,
contains: [ VARIABLE ]
},
{
begin: /\*(?=[ \t])/,
relevance: 0,
beginScope: 'keyword',
end: /$/,
contains: [ VARIABLE ]
},
{
scope: 'meta',
begin: /@[^@\s]+/
},
hljs.HASH_COMMENT_MODE,
{
scope: 'string',
variants: [
{
begin: /"""/,
end: /"""/
},
{
begin: /```/,
end: /```/
}
]
},
{
begin: /\|.*\|$/,
scope: 'string'
},
]
};
}