-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgraphql.js
63 lines (60 loc) · 1.38 KB
/
graphql.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
/**
* Highlight.js GraphQL syntax highlighting definition
*
* @see https://github.com/isagalaev/highlight.js
*
* @package: highlightjs-graphql
* @author: David Peek <[email protected]>
*/
function hljsDefineGraphQL(hljs) {
return {
aliases: ["gql"],
keywords: {
keyword:
"query mutation subscription|10 input schema implements type interface union scalar fragment|10 enum on ...",
literal: "ID ID! String Float Int Boolean",
variable: "true false null"
},
contains: [
hljs.HASH_COMMENT_MODE,
hljs.QUOTE_STRING_MODE,
hljs.NUMBER_MODE,
{
className: "literal",
begin: "[^\\w][A-Z][a-z]",
end: "\\W",
excludeEnd: true
},
{
className: "literal",
begin: ":\\s\\[",
end: "[\\]!]{1,3}",
excludeBegin: true,
excludeEnd: true
},
{
className: "type",
begin: "[^\\w](?!ID)[A-Z][A-Z]",
end: "\\W",
excludeEnd: true
},
{
className: "name",
begin: "\\$",
end: "\\W",
excludeEnd: true
},
{
className: "meta",
begin: "@",
end: "\\W",
excludeEnd: true
}
],
illegal: /([;<']|BEGIN)/
};
}
module.exports = function(hljs) {
hljs.registerLanguage("graphql", hljsDefineGraphQL);
};
module.exports.definer = hljsDefineGraphQL;