From bee6ad56d77417650e62597b001894139541f749 Mon Sep 17 00:00:00 2001 From: Wei Ting <59229084+hoonweiting@users.noreply.github.com> Date: Mon, 6 Dec 2021 01:44:55 +0800 Subject: [PATCH] EditorConfig: Swap out `property` for `key`; alias with `attr-name` (#3272) --- components/prism-editorconfig.js | 9 +++++---- components/prism-editorconfig.min.js | 2 +- tests/languages/editorconfig/key_value_feature.test | 8 ++++---- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/components/prism-editorconfig.js b/components/prism-editorconfig.js index 5a5eeaf2a7..e4775e7a65 100644 --- a/components/prism-editorconfig.js +++ b/components/prism-editorconfig.js @@ -1,5 +1,5 @@ Prism.languages.editorconfig = { - // https://editorconfig-specification.readthedocs.io/en/latest/ + // https://editorconfig-specification.readthedocs.io 'comment': /[;#].*/, 'section': { pattern: /(^[ \t]*)\[.+\]/m, @@ -11,13 +11,14 @@ Prism.languages.editorconfig = { 'punctuation': /[\[\]{},]/ } }, - 'property': { + 'key': { pattern: /(^[ \t]*)[^\s=]+(?=[ \t]*=)/m, - lookbehind: true + lookbehind: true, + alias: 'attr-name' }, 'value': { pattern: /=.*/, - alias: 'string', + alias: 'attr-value', inside: { 'punctuation': /^=/ } diff --git a/components/prism-editorconfig.min.js b/components/prism-editorconfig.min.js index e360ed8540..435b900070 100644 --- a/components/prism-editorconfig.min.js +++ b/components/prism-editorconfig.min.js @@ -1 +1 @@ -Prism.languages.editorconfig={comment:/[;#].*/,section:{pattern:/(^[ \t]*)\[.+\]/m,lookbehind:!0,alias:"keyword",inside:{regex:/\\\\[\[\]{},!?.*]/,operator:/[!?]|\.\.|\*{1,2}/,punctuation:/[\[\]{},]/}},property:{pattern:/(^[ \t]*)[^\s=]+(?=[ \t]*=)/m,lookbehind:!0},value:{pattern:/=.*/,alias:"string",inside:{punctuation:/^=/}}}; \ No newline at end of file +Prism.languages.editorconfig={comment:/[;#].*/,section:{pattern:/(^[ \t]*)\[.+\]/m,lookbehind:!0,alias:"keyword",inside:{regex:/\\\\[\[\]{},!?.*]/,operator:/[!?]|\.\.|\*{1,2}/,punctuation:/[\[\]{},]/}},key:{pattern:/(^[ \t]*)[^\s=]+(?=[ \t]*=)/m,lookbehind:!0,alias:"attr-name"},value:{pattern:/=.*/,alias:"attr-value",inside:{punctuation:/^=/}}}; \ No newline at end of file diff --git a/tests/languages/editorconfig/key_value_feature.test b/tests/languages/editorconfig/key_value_feature.test index dfcbd6a335..545e34d6f6 100644 --- a/tests/languages/editorconfig/key_value_feature.test +++ b/tests/languages/editorconfig/key_value_feature.test @@ -5,17 +5,17 @@ foobar = 42 ---------------------------------------------------- [ - ["property", "foo"], + ["key", "foo"], ["value", [ ["punctuation", "="], " Bar Baz" ]], - ["property", "foobar"], + ["key", "foobar"], ["value", [ ["punctuation", "="], " 42" ]], - ["property", "another_value"], + ["key", "another_value"], ["value", [ ["punctuation", "="], " with_indent" @@ -24,4 +24,4 @@ foobar = 42 ---------------------------------------------------- -Checks for key/value pairs. \ No newline at end of file +Checks for key/value pairs.