Mercurial
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/third_party/highlight/languages/graphql.js Mon Jan 19 18:59:10 2026 -0800 @@ -0,0 +1,88 @@ +/*! `graphql` grammar compiled for Highlight.js 11.11.1 */ + (function(){ + var hljsGrammar = (function () { + 'use strict'; + + /* + Language: GraphQL + Author: John Foster (GH jf990), and others + Description: GraphQL is a query language for APIs + Category: web, common + */ + + /** @type LanguageFn */ + function graphql(hljs) { + const regex = hljs.regex; + const GQL_NAME = /[_A-Za-z][_0-9A-Za-z]*/; + return { + name: "GraphQL", + aliases: [ "gql" ], + case_insensitive: true, + disableAutodetect: false, + keywords: { + keyword: [ + "query", + "mutation", + "subscription", + "type", + "input", + "schema", + "directive", + "interface", + "union", + "scalar", + "fragment", + "enum", + "on" + ], + literal: [ + "true", + "false", + "null" + ] + }, + contains: [ + hljs.HASH_COMMENT_MODE, + hljs.QUOTE_STRING_MODE, + hljs.NUMBER_MODE, + { + scope: "punctuation", + match: /[.]{3}/, + relevance: 0 + }, + { + scope: "punctuation", + begin: /[\!\(\)\:\=\[\]\{\|\}]{1}/, + relevance: 0 + }, + { + scope: "variable", + begin: /\$/, + end: /\W/, + excludeEnd: true, + relevance: 0 + }, + { + scope: "meta", + match: /@\w+/, + excludeEnd: true + }, + { + scope: "symbol", + begin: regex.concat(GQL_NAME, regex.lookahead(/\s*:/)), + relevance: 0 + } + ], + illegal: [ + /[;<']/, + /BEGIN/ + ] + }; + } + + return graphql; + +})(); + + hljs.registerLanguage('graphql', hljsGrammar); + })(); \ No newline at end of file