]> luflow.net public git repositories - flow-web.git/blob - static/highlight/es/languages/ini.js
Initial commit.
[flow-web.git] / static / highlight / es / languages / ini.js
1 /*! `ini` grammar compiled for Highlight.js 11.11.1 */
2 var hljsGrammar = (function () {
3 'use strict';
4
5 /*
6 Language: TOML, also INI
7 Description: TOML aims to be a minimal configuration file format that's easy to read due to obvious semantics.
8 Contributors: Guillaume Gomez <guillaume1.gomez@gmail.com>
9 Category: common, config
10 Website: https://github.com/toml-lang/toml
11 */
12
13 function ini(hljs) {
14 const regex = hljs.regex;
15 const NUMBERS = {
16 className: 'number',
17 relevance: 0,
18 variants: [
19 { begin: /([+-]+)?[\d]+_[\d_]+/ },
20 { begin: hljs.NUMBER_RE }
21 ]
22 };
23 const COMMENTS = hljs.COMMENT();
24 COMMENTS.variants = [
25 {
26 begin: /;/,
27 end: /$/
28 },
29 {
30 begin: /#/,
31 end: /$/
32 }
33 ];
34 const VARIABLES = {
35 className: 'variable',
36 variants: [
37 { begin: /\$[\w\d"][\w\d_]*/ },
38 { begin: /\$\{(.*?)\}/ }
39 ]
40 };
41 const LITERALS = {
42 className: 'literal',
43 begin: /\bon|off|true|false|yes|no\b/
44 };
45 const STRINGS = {
46 className: "string",
47 contains: [ hljs.BACKSLASH_ESCAPE ],
48 variants: [
49 {
50 begin: "'''",
51 end: "'''",
52 relevance: 10
53 },
54 {
55 begin: '"""',
56 end: '"""',
57 relevance: 10
58 },
59 {
60 begin: '"',
61 end: '"'
62 },
63 {
64 begin: "'",
65 end: "'"
66 }
67 ]
68 };
69 const ARRAY = {
70 begin: /\[/,
71 end: /\]/,
72 contains: [
73 COMMENTS,
74 LITERALS,
75 VARIABLES,
76 STRINGS,
77 NUMBERS,
78 'self'
79 ],
80 relevance: 0
81 };
82
83 const BARE_KEY = /[A-Za-z0-9_-]+/;
84 const QUOTED_KEY_DOUBLE_QUOTE = /"(\\"|[^"])*"/;
85 const QUOTED_KEY_SINGLE_QUOTE = /'[^']*'/;
86 const ANY_KEY = regex.either(
87 BARE_KEY, QUOTED_KEY_DOUBLE_QUOTE, QUOTED_KEY_SINGLE_QUOTE
88 );
89 const DOTTED_KEY = regex.concat(
90 ANY_KEY, '(\\s*\\.\\s*', ANY_KEY, ')*',
91 regex.lookahead(/\s*=\s*[^#\s]/)
92 );
93
94 return {
95 name: 'TOML, also INI',
96 aliases: [ 'toml' ],
97 case_insensitive: true,
98 illegal: /\S/,
99 contains: [
100 COMMENTS,
101 {
102 className: 'section',
103 begin: /\[+/,
104 end: /\]+/
105 },
106 {
107 begin: DOTTED_KEY,
108 className: 'attr',
109 starts: {
110 end: /$/,
111 contains: [
112 COMMENTS,
113 ARRAY,
114 LITERALS,
115 VARIABLES,
116 STRINGS,
117 NUMBERS
118 ]
119 }
120 }
121 ]
122 };
123 }
124
125 return ini;
126
127 })();
128 ;
129 export default hljsGrammar;