Skip to content

Commit e018087

Browse files
authored
Merge pull request #971 from Golmote/prism-graphql
Add support for GraphQL
2 parents a263362 + bfb559b commit e018087

14 files changed

+206
-2
lines changed

components.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,10 @@ var components = {
210210
"require": "clike",
211211
"owner": "arnehormann"
212212
},
213+
"graphql": {
214+
"title": "GraphQL",
215+
"owner": "Golmote"
216+
},
213217
"groovy": {
214218
"title": "Groovy",
215219
"require": "clike",

components/prism-graphql.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Prism.languages.graphql = {
2+
'comment': /#.*/,
3+
'string': {
4+
pattern: /"(?:\\.|[^\\"])*"/,
5+
greedy: true
6+
},
7+
'number': /(?:\B-|\b)\d+(?:\.\d+)?(?:[eE][+-]?\d+)?\b/,
8+
'boolean': /\b(?:true|false)\b/,
9+
'variable': /\$[a-z_]\w*/i,
10+
'directive': {
11+
pattern: /@[a-z_]\w*/i,
12+
alias: 'function'
13+
},
14+
'attr-name': /[a-z_]\w*(?=\s*:)/i,
15+
'keyword': [
16+
{
17+
pattern: /(fragment\s+(?!on)[a-z_]\w*\s+|\.\.\.\s*)on\b/,
18+
lookbehind: true
19+
},
20+
/\b(?:query|fragment|mutation)\b/
21+
],
22+
'operator': /!|=|\.{3}/,
23+
'punctuation': /[!(){}\[\]:=,]/
24+
};

components/prism-graphql.min.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/prism-graphql.html

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<h1>GraphQL</h1>
2+
<p>To use this language, use the class "language-graphql".</p>
3+
4+
<h2>Comments</h2>
5+
<pre><code># This is a comment</code></pre>
6+
7+
<h2>Strings</h2>
8+
<pre><code>""
9+
"foo \"bar\" baz"</code></pre>
10+
11+
<h2>Numbers</h2>
12+
<pre><code>0
13+
42
14+
3.14159
15+
-9e-5
16+
0.9E+7</code></pre>
17+
18+
<h2>Keywords</h2>
19+
<pre><code>query withFragments {
20+
user(id: 4) {
21+
friends(first: 10) {
22+
...friendFields
23+
}
24+
mutualFriends(first: 10) {
25+
...friendFields
26+
}
27+
}
28+
}
29+
30+
fragment friendFields on User {
31+
id
32+
name
33+
profilePic(size: 50)
34+
}</code></pre>

plugins/show-language/prism-show-language.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ if (typeof self === 'undefined' || !self.Prism || !self.document) {
55
}
66

77
// The languages map is built automatically with gulp
8-
var Languages = /*languages_placeholder[*/{"html":"HTML","xml":"XML","svg":"SVG","mathml":"MathML","css":"CSS","clike":"C-like","javascript":"JavaScript","abap":"ABAP","actionscript":"ActionScript","apacheconf":"Apache Configuration","apl":"APL","applescript":"AppleScript","asciidoc":"AsciiDoc","aspnet":"ASP.NET (C#)","autoit":"AutoIt","autohotkey":"AutoHotkey","basic":"BASIC","csharp":"C#","cpp":"C++","coffeescript":"CoffeeScript","css-extras":"CSS Extras","fsharp":"F#","glsl":"GLSL","http":"HTTP","inform7":"Inform 7","json":"JSON","latex":"LaTeX","lolcode":"LOLCODE","matlab":"MATLAB","mel":"MEL","nasm":"NASM","nginx":"nginx","nsis":"NSIS","objectivec":"Objective-C","ocaml":"OCaml","parigp":"PARI/GP","php":"PHP","php-extras":"PHP Extras","powershell":"PowerShell","protobuf":"Protocol Buffers","jsx":"React JSX","rest":"reST (reStructuredText)","sas":"SAS","sass":"Sass (Sass)","scss":"Sass (Scss)","sql":"SQL","typescript":"TypeScript","vhdl":"VHDL","vim":"vim","wiki":"Wiki markup","yaml":"YAML"}/*]*/;
8+
var Languages = /*languages_placeholder[*/{"html":"HTML","xml":"XML","svg":"SVG","mathml":"MathML","css":"CSS","clike":"C-like","javascript":"JavaScript","abap":"ABAP","actionscript":"ActionScript","apacheconf":"Apache Configuration","apl":"APL","applescript":"AppleScript","asciidoc":"AsciiDoc","aspnet":"ASP.NET (C#)","autoit":"AutoIt","autohotkey":"AutoHotkey","basic":"BASIC","csharp":"C#","cpp":"C++","coffeescript":"CoffeeScript","css-extras":"CSS Extras","fsharp":"F#","glsl":"GLSL","graphql":"GraphQL","http":"HTTP","inform7":"Inform 7","json":"JSON","latex":"LaTeX","lolcode":"LOLCODE","matlab":"MATLAB","mel":"MEL","nasm":"NASM","nginx":"nginx","nsis":"NSIS","objectivec":"Objective-C","ocaml":"OCaml","parigp":"PARI/GP","php":"PHP","php-extras":"PHP Extras","powershell":"PowerShell","protobuf":"Protocol Buffers","jsx":"React JSX","rest":"reST (reStructuredText)","sas":"SAS","sass":"Sass (Sass)","scss":"Sass (Scss)","sql":"SQL","typescript":"TypeScript","vhdl":"VHDL","vim":"vim","wiki":"Wiki markup","yaml":"YAML"}/*]*/;
99
Prism.hooks.add('before-highlight', function(env) {
1010
var pre = env.element.parentNode;
1111
if (!pre || !/pre/i.test(pre.nodeName)) {

plugins/show-language/prism-show-language.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
zuck: user(id: 4) {
3+
name
4+
}
5+
}
6+
7+
----------------------------------------------------
8+
9+
[
10+
["punctuation", "{"],
11+
["attr-name", "zuck"],
12+
["punctuation", ":"],
13+
" user",
14+
["punctuation", "("],
15+
["attr-name", "id"],
16+
["punctuation", ":"],
17+
["number", "4"],
18+
["punctuation", ")"],
19+
["punctuation", "{"],
20+
"\r\n\t\tname\r\n\t",
21+
["punctuation", "}"],
22+
["punctuation", "}"]
23+
]
24+
25+
----------------------------------------------------
26+
27+
Checks for aliases, parameter names, etc.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
true
2+
false
3+
4+
----------------------------------------------------
5+
6+
[
7+
["boolean", "true"],
8+
["boolean", "false"]
9+
]
10+
11+
----------------------------------------------------
12+
13+
Checks for booleans.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#
2+
# foobar
3+
4+
----------------------------------------------------
5+
6+
[
7+
["comment", "#"],
8+
["comment", "# foobar"]
9+
]
10+
11+
----------------------------------------------------
12+
13+
Checks for comments.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
@skip
2+
@include
3+
4+
----------------------------------------------------
5+
6+
[
7+
["directive", "@skip"],
8+
["directive", "@include"]
9+
]
10+
11+
----------------------------------------------------
12+
13+
Checks for directives

0 commit comments

Comments
 (0)