From 73be69a17a9ba3c9e98ff8e1a5a7c85a4d06bb77 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Fri, 4 Oct 2024 18:29:10 +0200 Subject: [PATCH 1/2] Add support for PostCSS --- Syntaxes/HTML (Astro).sublime-syntax | 26 ++++++++++++++++++++++++++ tests/syntax_test_style.astro | 16 ++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/Syntaxes/HTML (Astro).sublime-syntax b/Syntaxes/HTML (Astro).sublime-syntax index 20ddd9f..adf7376 100644 --- a/Syntaxes/HTML (Astro).sublime-syntax +++ b/Syntaxes/HTML (Astro).sublime-syntax @@ -221,6 +221,11 @@ contexts: - include: style-lang-decider style-lang-decider: + - match: (?i)(?=postcss{{unquoted_attribute_break}}|'postcss'|"postcss") + set: + - style-postcss + - tag-generic-attribute-meta + - tag-generic-attribute-value - match: (?i)(?=css{{unquoted_attribute_break}}|\'css\'|"css") set: - style-css @@ -273,6 +278,27 @@ contexts: 3: source.less.embedded.html 4: comment.block.html punctuation.definition.comment.end.html + style-postcss: + - meta_scope: meta.tag.style.begin.html + - match: '>' + scope: punctuation.definition.tag.end.html + set: style-postcss-content + - include: style-common + + style-postcss-content: + - match: '{{style_content_begin}}' + captures: + 1: comment.block.html punctuation.definition.comment.begin.html + pop: 1 + embed: scope:source.postcss + embed_scope: source.postcss.embedded.html + escape: '{{style_content_end}}' + escape_captures: + 1: source.postcss.embedded.html + 2: comment.block.html punctuation.definition.comment.end.html + 3: source.postcss.embedded.html + 4: comment.block.html punctuation.definition.comment.end.html + style-sass: - meta_scope: meta.tag.style.begin.html - match: '>' diff --git a/tests/syntax_test_style.astro b/tests/syntax_test_style.astro index 92cb9d0..9adc025 100644 --- a/tests/syntax_test_style.astro +++ b/tests/syntax_test_style.astro @@ -182,6 +182,22 @@ // ^^^^^ entity.name.tag.style.html // ^ punctuation.definition.tag.end.html + +// <- - source.postcss - comment - meta.tag +//^^ - source.postcss - comment - meta.tag +// ^^^^^^^^ meta.tag - source.postcss +// ^^ punctuation.definition.tag.begin.html +// ^^^^^ entity.name.tag.style.html +// ^ punctuation.definition.tag.end.html