Mercurial
comparison third_party/highlight/languages/graphql.js @ 173:827c6ac504cd hg-web
Merged in default here.
| author | MrJuneJune <me@mrjunejune.com> |
|---|---|
| date | Mon, 19 Jan 2026 18:59:10 -0800 |
| parents | 2db6253f355d |
| children |
comparison
equal
deleted
inserted
replaced
| 151:c033667da5f9 | 173:827c6ac504cd |
|---|---|
| 1 /*! `graphql` grammar compiled for Highlight.js 11.11.1 */ | |
| 2 (function(){ | |
| 3 var hljsGrammar = (function () { | |
| 4 'use strict'; | |
| 5 | |
| 6 /* | |
| 7 Language: GraphQL | |
| 8 Author: John Foster (GH jf990), and others | |
| 9 Description: GraphQL is a query language for APIs | |
| 10 Category: web, common | |
| 11 */ | |
| 12 | |
| 13 /** @type LanguageFn */ | |
| 14 function graphql(hljs) { | |
| 15 const regex = hljs.regex; | |
| 16 const GQL_NAME = /[_A-Za-z][_0-9A-Za-z]*/; | |
| 17 return { | |
| 18 name: "GraphQL", | |
| 19 aliases: [ "gql" ], | |
| 20 case_insensitive: true, | |
| 21 disableAutodetect: false, | |
| 22 keywords: { | |
| 23 keyword: [ | |
| 24 "query", | |
| 25 "mutation", | |
| 26 "subscription", | |
| 27 "type", | |
| 28 "input", | |
| 29 "schema", | |
| 30 "directive", | |
| 31 "interface", | |
| 32 "union", | |
| 33 "scalar", | |
| 34 "fragment", | |
| 35 "enum", | |
| 36 "on" | |
| 37 ], | |
| 38 literal: [ | |
| 39 "true", | |
| 40 "false", | |
| 41 "null" | |
| 42 ] | |
| 43 }, | |
| 44 contains: [ | |
| 45 hljs.HASH_COMMENT_MODE, | |
| 46 hljs.QUOTE_STRING_MODE, | |
| 47 hljs.NUMBER_MODE, | |
| 48 { | |
| 49 scope: "punctuation", | |
| 50 match: /[.]{3}/, | |
| 51 relevance: 0 | |
| 52 }, | |
| 53 { | |
| 54 scope: "punctuation", | |
| 55 begin: /[\!\(\)\:\=\[\]\{\|\}]{1}/, | |
| 56 relevance: 0 | |
| 57 }, | |
| 58 { | |
| 59 scope: "variable", | |
| 60 begin: /\$/, | |
| 61 end: /\W/, | |
| 62 excludeEnd: true, | |
| 63 relevance: 0 | |
| 64 }, | |
| 65 { | |
| 66 scope: "meta", | |
| 67 match: /@\w+/, | |
| 68 excludeEnd: true | |
| 69 }, | |
| 70 { | |
| 71 scope: "symbol", | |
| 72 begin: regex.concat(GQL_NAME, regex.lookahead(/\s*:/)), | |
| 73 relevance: 0 | |
| 74 } | |
| 75 ], | |
| 76 illegal: [ | |
| 77 /[;<']/, | |
| 78 /BEGIN/ | |
| 79 ] | |
| 80 }; | |
| 81 } | |
| 82 | |
| 83 return graphql; | |
| 84 | |
| 85 })(); | |
| 86 | |
| 87 hljs.registerLanguage('graphql', hljsGrammar); | |
| 88 })(); |