Skip to content

Commit 0c30c58

Browse files
authoredJul 22, 2020
EditorConfig: Trim spaces before key and section title (#2482)
The `key` and `section` tokens sometimes included leading spaces.
1 parent 2ff40fe commit 0c30c58

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed
 

‎components/prism-editorconfig.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,19 @@ Prism.languages.editorconfig = {
22
// https://editorconfig-specification.readthedocs.io/en/latest/
33
'comment': /[;#].*/,
44
'section': {
5-
pattern: /^[ \t]*\[.+]/m,
5+
pattern: /(^[ \t]*)\[.+]/m,
6+
lookbehind: true,
67
alias: 'keyword',
78
inside: {
89
'regex': /\\\\[\[\]{},!?.*]/, // Escape special characters with '\\'
910
'operator': /[!?]|\.\.|\*{1,2}/,
1011
'punctuation': /[\[\]{},]/
1112
}
1213
},
13-
'property': /^[ \t]*[^\s=]+(?=[ \t]*=)/m,
14+
'property': {
15+
pattern: /(^[ \t]*)[^\s=]+(?=[ \t]*=)/m,
16+
lookbehind: true
17+
},
1418
'value': {
1519
pattern: /=.*/,
1620
alias: 'string',

‎components/prism-editorconfig.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎tests/languages/editorconfig/key_value_feature.test

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
foo = Bar Baz
22
foobar = 42
3+
another_value = with_indent
34

45
----------------------------------------------------
56

@@ -13,6 +14,11 @@ foobar = 42
1314
["value", [
1415
["punctuation", "="],
1516
" 42"
17+
]],
18+
["property", "another_value"],
19+
["value", [
20+
["punctuation", "="],
21+
" with_indent"
1622
]]
1723
]
1824

‎tests/languages/editorconfig/section_feature.test

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
[{**.kt, **.kts}]
44
[?[!seq].log.{0..9}]
55
[\\**.log]
6+
[Section with indent]
67

78
----------------------------------------------------
89

@@ -26,6 +27,9 @@
2627
]],
2728
["section", [
2829
["punctuation", "["], ["regex", "\\\\*"], ["operator", "*"], ".log", ["punctuation", "]"]
30+
]],
31+
["section", [
32+
["punctuation", "["], "Section with indent", ["punctuation", "]"]
2933
]]
3034
]
3135

0 commit comments

Comments
 (0)
Please sign in to comment.