1 |
|
2 |
|
3 | (function (Prism) {
|
4 |
|
5 | var comment = {
|
6 | pattern: /^[;#].*/m,
|
7 | greedy: true
|
8 | };
|
9 |
|
10 | var quotesSource = /"(?:[^\r\n"\\]|\\(?:[^\r]|\r\n?))*"(?!\S)/.source;
|
11 |
|
12 | Prism.languages.systemd = {
|
13 | 'comment': comment,
|
14 |
|
15 | 'section': {
|
16 | pattern: /^\[[^\n\r\[\]]*\](?=[ \t]*$)/m,
|
17 | greedy: true,
|
18 | inside: {
|
19 | 'punctuation': /^\[|\]$/,
|
20 | 'section-name': {
|
21 | pattern: /[\s\S]+/,
|
22 | alias: 'selector'
|
23 | },
|
24 | }
|
25 | },
|
26 |
|
27 | 'key': {
|
28 | pattern: /^[^\s=]+(?=[ \t]*=)/m,
|
29 | greedy: true,
|
30 | alias: 'attr-name'
|
31 | },
|
32 | 'value': {
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 | pattern: RegExp(
|
39 | /(=[ \t]*(?!\s))/.source +
|
40 |
|
41 | '(?:' + quotesSource + '|(?=[^"\r\n]))' +
|
42 |
|
43 | '(?:' + (
|
44 | /[^\s\\]/.source +
|
45 |
|
46 | '|' + '[ \t]+(?:(?![ \t"])|' + quotesSource + ')' +
|
47 |
|
48 | '|' + /\\[\r\n]+(?:[#;].*[\r\n]+)*(?![#;])/.source
|
49 | ) +
|
50 | ')*'
|
51 | ),
|
52 | lookbehind: true,
|
53 | greedy: true,
|
54 | alias: 'attr-value',
|
55 | inside: {
|
56 | 'comment': comment,
|
57 | 'quoted': {
|
58 | pattern: RegExp(/(^|\s)/.source + quotesSource),
|
59 | lookbehind: true,
|
60 | greedy: true,
|
61 | },
|
62 | 'punctuation': /\\$/m,
|
63 |
|
64 | 'boolean': {
|
65 | pattern: /^(?:false|no|off|on|true|yes)$/,
|
66 | greedy: true
|
67 | }
|
68 | }
|
69 | },
|
70 |
|
71 | 'punctuation': /=/
|
72 | };
|
73 |
|
74 | }(Prism));
|