Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EditorConfig support #2471

Merged
merged 4 commits into from Jul 10, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion components.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions components.json
Expand Up @@ -295,6 +295,10 @@
"title": "EBNF",
"owner": "RunDevelopment"
},
"editorconfig": {
"title": "EditorConfig",
"owner": "osipxd"
},
"eiffel": {
"title": "Eiffel",
"owner": "Conaclos"
Expand Down
20 changes: 20 additions & 0 deletions components/prism-editorconfig.js
@@ -0,0 +1,20 @@
Prism.languages.editorconfig = {
// https://editorconfig-specification.readthedocs.io/en/latest/
'comment': /[;#].*$/m,
RunDevelopment marked this conversation as resolved.
Show resolved Hide resolved
'section': {
pattern: /^[ \t]*\[.+]/m,
RunDevelopment marked this conversation as resolved.
Show resolved Hide resolved
alias: 'keyword',
inside: {
'regex': /\\\\[\[\]{},!?.*]/, // Escape special characters with '\\'
'punctuation': /[\[\]{},!?]|\.\.|\*{1,2}/
RunDevelopment marked this conversation as resolved.
Show resolved Hide resolved
}
},
'property': /^[ \t]*[^\s=]+?(?=[ \t]*=)/m,
RunDevelopment marked this conversation as resolved.
Show resolved Hide resolved
'value': {
pattern: /=.*/,
alias: 'string',
inside: {
'punctuation': /^[=]/
RunDevelopment marked this conversation as resolved.
Show resolved Hide resolved
}
}
};
1 change: 1 addition & 0 deletions components/prism-editorconfig.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions plugins/show-language/prism-show-language.js
Expand Up @@ -57,6 +57,7 @@
"dns-zone": "DNS zone file",
"dockerfile": "Docker",
"ebnf": "EBNF",
"editorconfig": "EditorConfig",
"ejs": "EJS",
"etlua": "Embedded Lua templating",
"erb": "ERB",
Expand Down
2 changes: 1 addition & 1 deletion plugins/show-language/prism-show-language.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions tests/languages/editorconfig/comment_feature.test
@@ -0,0 +1,15 @@
;
; comment
# comment can also contain ; and #

----------------------------------------------------

[
["comment", ";"],
["comment", "; comment"],
["comment", "# comment can also contain ; and #"]
]

----------------------------------------------------

Checks for comments.
21 changes: 21 additions & 0 deletions tests/languages/editorconfig/key_value_feature.test
@@ -0,0 +1,21 @@
foo = Bar Baz
foobar = 42

----------------------------------------------------

[
["property", "foo"],
["value", [
["punctuation", "="],
" Bar Baz"
]],
["property", "foobar"],
["value", [
["punctuation", "="],
" 42"
]]
]

----------------------------------------------------

Checks for key/value pairs.
34 changes: 34 additions & 0 deletions tests/languages/editorconfig/section_feature.test
@@ -0,0 +1,34 @@
[*]
[**.kt]
[{**.kt, **.kts}]
[?[!seq].log.{0..9}]
[\\**.log]

----------------------------------------------------

[
["section", [
["punctuation", "["], ["punctuation", "*"], ["punctuation", "]"]
]],
["section", [
["punctuation", "["], ["punctuation", "**"], ".kt", ["punctuation", "]"]
]],
["section", [
["punctuation", "["], ["punctuation", "{"],
["punctuation", "**"], ".kt", ["punctuation", ","], ["punctuation", "**"], ".kts",
["punctuation", "}"], ["punctuation", "]"]
]],
["section", [
["punctuation", "["], ["punctuation", "?"],
["punctuation", "["], ["punctuation", "!"], "seq", ["punctuation", "]"],
".log.", ["punctuation", "{"], "0", ["punctuation", ".."], "9", ["punctuation", "}"],
["punctuation", "]"]
]],
["section", [
["punctuation", "["], ["regex", "\\\\*"], ["punctuation", "*"], ".log", ["punctuation", "]"]
]]
]

----------------------------------------------------

Checks for section titles.