]> luflow.net public git repositories - flow-web.git/blob - static/highlight/languages/properties.js
Initial commit.
[flow-web.git] / static / highlight / languages / properties.js
1 /*! `properties` grammar compiled for Highlight.js 11.11.1 */
2 (function(){
3 var hljsGrammar = (function () {
4 'use strict';
5
6 /*
7 Language: .properties
8 Contributors: Valentin Aitken <valentin@nalisbg.com>, Egor Rogov <e.rogov@postgrespro.ru>
9 Website: https://en.wikipedia.org/wiki/.properties
10 Category: config
11 */
12
13 /** @type LanguageFn */
14 function properties(hljs) {
15 // whitespaces: space, tab, formfeed
16 const WS0 = '[ \\t\\f]*';
17 const WS1 = '[ \\t\\f]+';
18 // delimiter
19 const EQUAL_DELIM = WS0 + '[:=]' + WS0;
20 const WS_DELIM = WS1;
21 const DELIM = '(' + EQUAL_DELIM + '|' + WS_DELIM + ')';
22 const KEY = '([^\\\\:= \\t\\f\\n]|\\\\.)+';
23
24 const DELIM_AND_VALUE = {
25 // skip DELIM
26 end: DELIM,
27 relevance: 0,
28 starts: {
29 // value: everything until end of line (again, taking into account backslashes)
30 className: 'string',
31 end: /$/,
32 relevance: 0,
33 contains: [
34 { begin: '\\\\\\\\' },
35 { begin: '\\\\\\n' }
36 ]
37 }
38 };
39
40 return {
41 name: '.properties',
42 disableAutodetect: true,
43 case_insensitive: true,
44 illegal: /\S/,
45 contains: [
46 hljs.COMMENT('^\\s*[!#]', '$'),
47 // key: everything until whitespace or = or : (taking into account backslashes)
48 // case of a key-value pair
49 {
50 returnBegin: true,
51 variants: [
52 { begin: KEY + EQUAL_DELIM },
53 { begin: KEY + WS_DELIM }
54 ],
55 contains: [
56 {
57 className: 'attr',
58 begin: KEY,
59 endsParent: true
60 }
61 ],
62 starts: DELIM_AND_VALUE
63 },
64 // case of an empty key
65 {
66 className: 'attr',
67 begin: KEY + WS0 + '$'
68 }
69 ]
70 };
71 }
72
73 return properties;
74
75 })();
76
77 hljs.registerLanguage('properties', hljsGrammar);
78 })();