diff --git a/components/prism-editorconfig.js b/components/prism-editorconfig.js index 5cab128ca6..c7c68b0460 100644 --- a/components/prism-editorconfig.js +++ b/components/prism-editorconfig.js @@ -2,7 +2,8 @@ Prism.languages.editorconfig = { // https://editorconfig-specification.readthedocs.io/en/latest/ 'comment': /[;#].*/, 'section': { - pattern: /^[ \t]*\[.+]/m, + pattern: /(^[ \t]*)\[.+]/m, + lookbehind: true, alias: 'keyword', inside: { 'regex': /\\\\[\[\]{},!?.*]/, // Escape special characters with '\\' @@ -10,7 +11,10 @@ Prism.languages.editorconfig = { 'punctuation': /[\[\]{},]/ } }, - 'property': /^[ \t]*[^\s=]+(?=[ \t]*=)/m, + 'property': { + pattern: /(^[ \t]*)[^\s=]+(?=[ \t]*=)/m, + lookbehind: true + }, 'value': { pattern: /=.*/, alias: 'string', diff --git a/components/prism-editorconfig.min.js b/components/prism-editorconfig.min.js index 58fdfdf71e..fd7ddd72c4 100644 --- a/components/prism-editorconfig.min.js +++ b/components/prism-editorconfig.min.js @@ -1 +1 @@ -Prism.languages.editorconfig={comment:/[;#].*/,section:{pattern:/^[ \t]*\[.+]/m,alias:"keyword",inside:{regex:/\\\\[\[\]{},!?.*]/,operator:/[!?]|\.\.|\*{1,2}/,punctuation:/[\[\]{},]/}},property:/^[ \t]*[^\s=]+(?=[ \t]*=)/m,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:/[\[\]{},]/}},property:{pattern:/(^[ \t]*)[^\s=]+(?=[ \t]*=)/m,lookbehind:!0},value:{pattern:/=.*/,alias:"string",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 881f6a1035..dfcbd6a335 100644 --- a/tests/languages/editorconfig/key_value_feature.test +++ b/tests/languages/editorconfig/key_value_feature.test @@ -1,5 +1,6 @@ foo = Bar Baz foobar = 42 + another_value = with_indent ---------------------------------------------------- @@ -13,6 +14,11 @@ foobar = 42 ["value", [ ["punctuation", "="], " 42" + ]], + ["property", "another_value"], + ["value", [ + ["punctuation", "="], + " with_indent" ]] ] diff --git a/tests/languages/editorconfig/section_feature.test b/tests/languages/editorconfig/section_feature.test index 9ba7b59980..ae24c74045 100644 --- a/tests/languages/editorconfig/section_feature.test +++ b/tests/languages/editorconfig/section_feature.test @@ -3,6 +3,7 @@ [{**.kt, **.kts}] [?[!seq].log.{0..9}] [\\**.log] + [Section with indent] ---------------------------------------------------- @@ -26,6 +27,9 @@ ]], ["section", [ ["punctuation", "["], ["regex", "\\\\*"], ["operator", "*"], ".log", ["punctuation", "]"] + ]], + ["section", [ + ["punctuation", "["], "Section with indent", ["punctuation", "]"] ]] ]