Mercurial
comparison third_party/highlight/languages/thrift.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 /*! `thrift` grammar compiled for Highlight.js 11.11.1 */ | |
| 2 (function(){ | |
| 3 var hljsGrammar = (function () { | |
| 4 'use strict'; | |
| 5 | |
| 6 /* | |
| 7 Language: Thrift | |
| 8 Author: Oleg Efimov <[email protected]> | |
| 9 Description: Thrift message definition format | |
| 10 Website: https://thrift.apache.org | |
| 11 Category: protocols | |
| 12 */ | |
| 13 | |
| 14 function thrift(hljs) { | |
| 15 const TYPES = [ | |
| 16 "bool", | |
| 17 "byte", | |
| 18 "i16", | |
| 19 "i32", | |
| 20 "i64", | |
| 21 "double", | |
| 22 "string", | |
| 23 "binary" | |
| 24 ]; | |
| 25 const KEYWORDS = [ | |
| 26 "namespace", | |
| 27 "const", | |
| 28 "typedef", | |
| 29 "struct", | |
| 30 "enum", | |
| 31 "service", | |
| 32 "exception", | |
| 33 "void", | |
| 34 "oneway", | |
| 35 "set", | |
| 36 "list", | |
| 37 "map", | |
| 38 "required", | |
| 39 "optional" | |
| 40 ]; | |
| 41 return { | |
| 42 name: 'Thrift', | |
| 43 keywords: { | |
| 44 keyword: KEYWORDS, | |
| 45 type: TYPES, | |
| 46 literal: 'true false' | |
| 47 }, | |
| 48 contains: [ | |
| 49 hljs.QUOTE_STRING_MODE, | |
| 50 hljs.NUMBER_MODE, | |
| 51 hljs.C_LINE_COMMENT_MODE, | |
| 52 hljs.C_BLOCK_COMMENT_MODE, | |
| 53 { | |
| 54 className: 'class', | |
| 55 beginKeywords: 'struct enum service exception', | |
| 56 end: /\{/, | |
| 57 illegal: /\n/, | |
| 58 contains: [ | |
| 59 hljs.inherit(hljs.TITLE_MODE, { | |
| 60 // hack: eating everything after the first title | |
| 61 starts: { | |
| 62 endsWithParent: true, | |
| 63 excludeEnd: true | |
| 64 } }) | |
| 65 ] | |
| 66 }, | |
| 67 { | |
| 68 begin: '\\b(set|list|map)\\s*<', | |
| 69 keywords: { type: [ | |
| 70 ...TYPES, | |
| 71 "set", | |
| 72 "list", | |
| 73 "map" | |
| 74 ] }, | |
| 75 end: '>', | |
| 76 contains: [ 'self' ] | |
| 77 } | |
| 78 ] | |
| 79 }; | |
| 80 } | |
| 81 | |
| 82 return thrift; | |
| 83 | |
| 84 })(); | |
| 85 | |
| 86 hljs.registerLanguage('thrift', hljsGrammar); | |
| 87 })(); |