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