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