main
Last change
on this file since e48199a was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
1.7 KB
|
Rev | Line | |
---|
[d24f17c] | 1 | // https://www.freedesktop.org/software/systemd/man/systemd.syntax.html
|
---|
| 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 | // This pattern is quite complex because of two properties:
|
---|
| 34 | // 1) Quotes (strings) must be preceded by a space. Since we can't use lookbehinds, we have to "resolve"
|
---|
| 35 | // the lookbehind. You will see this in the main loop where spaces are handled separately.
|
---|
| 36 | // 2) Line continuations.
|
---|
| 37 | // After line continuations, empty lines and comments are ignored so we have to consume them.
|
---|
| 38 | pattern: RegExp(
|
---|
| 39 | /(=[ \t]*(?!\s))/.source +
|
---|
| 40 | // the value either starts with quotes or not
|
---|
| 41 | '(?:' + quotesSource + '|(?=[^"\r\n]))' +
|
---|
| 42 | // main loop
|
---|
| 43 | '(?:' + (
|
---|
| 44 | /[^\s\\]/.source +
|
---|
| 45 | // handle spaces separately because of quotes
|
---|
| 46 | '|' + '[ \t]+(?:(?![ \t"])|' + quotesSource + ')' +
|
---|
| 47 | // line continuation
|
---|
| 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));
|
---|
Note:
See
TracBrowser
for help on using the repository browser.