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