Skip to content

Commit e93595e

Browse files
committed
current highlighter gets too many colors
1 parent 86cf234 commit e93595e

File tree

1 file changed

+23
-47
lines changed

1 file changed

+23
-47
lines changed

src/languages/systemd.js

Lines changed: 23 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ Category: common, config
66
Website: https://www.freedesktop.org/
77
*/
88
export default function(hljs) {
9-
const regex = hljs.regex;
10-
119
const FIELD_CODES = {
1210
className: 'variable',
1311
match: /%[fFuUcCiIkKvV]/,
@@ -16,10 +14,9 @@ export default function(hljs) {
1614

1715
const STRINGS = {
1816
className: 'string',
17+
begin: /"/,
18+
end: /"/,
1919
contains: [ hljs.BACKSLASH_ESCAPE ],
20-
variants: [
21-
{ begin: '"', end: '"' }
22-
],
2320
relevance: 0
2421
};
2522

@@ -30,47 +27,20 @@ export default function(hljs) {
3027
relevance: 0
3128
};
3229

33-
const BOOL_LITERAL = {
34-
className: 'literal',
35-
begin: /\b(true|false|True|False)\b/,
36-
relevance: 10
37-
};
38-
39-
const TYPE_LITERAL = {
40-
className: 'literal',
41-
begin: /\b(Application|Link|Directory|forking|oneshot|OneShot)\b/,
42-
relevance: 10
43-
};
44-
45-
const NUMBER = {
46-
className: 'number',
47-
relevance: 0,
48-
variants: [
49-
{ begin: /([+-])?[\d]+(_[\d]+)*/ },
50-
{ begin: hljs.NUMBER_RE }
51-
]
52-
};
53-
5430
const SECTION = {
5531
className: 'section',
5632
begin: /^\[(Desktop Entry|Unit|Service|Install|Socket|Mount|Automount|Swap|Path|Timer|Slice|Scope|Manager|connection|ipv4|ipv6|802-3-ethernet|802-11-wireless|802-11-wireless-security|vpn|Journal|Bridge|Desktop Action\s+[A-Za-z0-9_-]+)\]/,
5733
end: /\]/,
5834
relevance: 10
5935
};
6036

61-
const BARE_KEY = /[A-Za-z0-9_-]+/;
62-
const KEY_WITH_INDEX = regex.concat(
63-
BARE_KEY,
64-
'(\\[[A-Za-z0-9_@.]+\\])?'
65-
);
66-
6737
const KEY_VALUE = {
68-
begin: regex.concat('^', KEY_WITH_INDEX, '\\s*='),
38+
begin: /^([A-Za-z0-9_-]+(\[[A-Za-z0-9_@.]+\])?)\s*=/,
6939
returnBegin: true,
7040
contains: [
7141
{
7242
className: 'attr',
73-
begin: KEY_WITH_INDEX,
43+
begin: /^[A-Za-z0-9_-]+(\[[A-Za-z0-9_@.]+\])?/,
7444
end: /\s*=/,
7545
excludeEnd: true,
7646
relevance: 10
@@ -81,25 +51,31 @@ export default function(hljs) {
8151
relevance: 0
8252
},
8353
{
84-
className: 'literal',
85-
begin: /\b(Application|Link|Directory|forking|oneshot|OneShot)\b/,
86-
relevance: 10
87-
},
88-
{
89-
className: 'literal',
90-
begin: /\b(true|false|True|False)\b/,
91-
relevance: 10
92-
},
93-
STRINGS,
94-
FIELD_CODES,
95-
COMMENT
54+
begin: /\S.*/,
55+
end: /$/,
56+
excludeBegin: false,
57+
contains: [
58+
{
59+
className: 'literal',
60+
match: /\b(Application|Link|Directory|forking|oneshot|OneShot|true|false|True|False)\b/,
61+
relevance: 10
62+
},
63+
STRINGS,
64+
FIELD_CODES
65+
// 일반 값은 하이라이팅 없음
66+
],
67+
relevance: 0
68+
}
9669
]
9770
};
9871

9972
return {
100-
name: 'Systemd/XDG',
73+
name: 'Systemd (INI-like)',
10174
aliases: [ 'desktop', 'service', 'mount', 'socket', 'timer', 'nmconnection', 'systemd' ],
10275
case_insensitive: false,
76+
keywords: {
77+
literal: 'Application Link Directory forking oneshot OneShot true false True False'
78+
},
10379
contains: [
10480
COMMENT,
10581
SECTION,

0 commit comments

Comments
 (0)