Skip to content

Commit

Permalink
Merge branch 'st4126'
Browse files Browse the repository at this point in the history
  • Loading branch information
deathaxe committed Nov 2, 2024
2 parents 7a8b808 + b9e2e92 commit 0fa888f
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 32 deletions.
74 changes: 52 additions & 22 deletions Syntaxes/HTML (Astro).sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ variables:
astro_component_char: '[^/?!\s<>=]'

typescript_mime_type: (?:(?:text|application)/(?:ts|typescript))

contexts:

prototype:
Expand Down Expand Up @@ -107,12 +109,12 @@ contexts:
- include: script-lang-attribute

script-lang-attribute:
- match: (?i:lang){{attribute_name_break}}
scope: meta.attribute-with-value.html entity.other.attribute-name.html
- match: (?i:lang(?:uage)?){{attribute_name_break}}
scope: meta.attribute-with-value.lang.html entity.other.attribute-name.html
set: script-lang-attribute-assignment

script-lang-attribute-assignment:
- meta_content_scope: meta.tag.script.begin.html meta.attribute-with-value.html
- meta_content_scope: meta.tag.script.begin.html meta.attribute-with-value.lang.html
- match: =
scope: punctuation.separator.key-value.html
set: script-lang-attribute-value
Expand All @@ -121,48 +123,76 @@ contexts:

script-lang-attribute-value:
- meta_include_prototype: false
- meta_scope: meta.tag.script.begin.html meta.attribute-with-value.html
- meta_scope: meta.tag.script.begin.html meta.attribute-with-value.lang.html
- include: script-lang-decider

script-lang-decider:
- match: (?i)(?=js{{unquoted_attribute_break}}|\'js\'|"js")
set:
- script-javascript
- tag-generic-attribute-meta
- tag-lang-attribute-meta
- tag-generic-attribute-value
- match: (?i)(?=ts{{unquoted_attribute_break}}|\'ts\'|"ts")
set:
- script-typescript
- tag-generic-attribute-meta
- tag-lang-attribute-meta
- tag-generic-attribute-value
- match: (?=>|''|"")
set:
- script-typescript
- tag-generic-attribute-meta
- tag-lang-attribute-meta
- tag-generic-attribute-value
- match: (?=\S)
set:
- script-other
- tag-generic-attribute-meta
- tag-lang-attribute-meta
- tag-generic-attribute-value

tag-lang-attribute-meta:
- meta_include_prototype: false
- meta_scope: meta.attribute-with-value.lang.html
- include: immediately-pop

script-type-attribute:
# required until https://github.com/sublimehq/Packages/pull/4061
- match: (?i:type){{attribute_name_break}}
scope: meta.attribute-with-value.type.html entity.other.attribute-name.html
set: script-type-attribute-assignment

script-type-attribute-assignment:
- meta_include_prototype: false
- meta_content_scope: meta.tag.script.begin.html meta.attribute-with-value.html
- meta_content_scope: meta.tag.script.begin.html meta.attribute-with-value.type.html
- match: =
scope: punctuation.separator.key-value.html
set: script-type-attribute-value
- match: (?=\S)
set: script-typescript

script-type-attribute-value:
# required until https://github.com/sublimehq/Packages/pull/4061
- meta_include_prototype: false
- meta_scope: meta.tag.script.begin.html meta.attribute-with-value.type.html
- include: script-type-decider

script-type-decider:
- meta_prepend: true
- match: (?i)(?={{typescript_mime_type}}{{unquoted_attribute_break}}|'{{typescript_mime_type}}'|"{{typescript_mime_type}}")
set:
- script-typescript
- tag-type-attribute-meta
- tag-generic-attribute-value
- match: (?=>|''|"")
set:
- script-javascript
- tag-generic-attribute-meta
- script-typescript
- tag-type-attribute-meta
- tag-generic-attribute-value

tag-type-attribute-meta:
# required until https://github.com/sublimehq/Packages/pull/4061
- meta_include_prototype: false
- meta_scope: meta.attribute-with-value.type.html
- include: immediately-pop

script-typescript:
- meta_scope: meta.tag.script.begin.html
- match: '>'
Expand Down Expand Up @@ -204,12 +234,12 @@ contexts:
- include: style-lang-attribute

style-lang-attribute:
- match: (?i:lang){{attribute_name_break}}
scope: meta.attribute-with-value.html entity.other.attribute-name.html
- match: (?i:lang(?:uage)?){{attribute_name_break}}
scope: meta.attribute-with-value.lang.html entity.other.attribute-name.html
set: style-lang-attribute-assignment

style-lang-attribute-assignment:
- meta_content_scope: meta.tag.style.begin.html meta.attribute-with-value.html
- meta_content_scope: meta.tag.style.begin.html meta.attribute-with-value.lang.html
- match: =
scope: punctuation.separator.key-value.html
set: style-lang-attribute-value
Expand All @@ -218,44 +248,44 @@ contexts:

style-lang-attribute-value:
- meta_include_prototype: false
- meta_scope: meta.tag.style.begin.html meta.attribute-with-value.html
- meta_scope: meta.tag.style.begin.html meta.attribute-with-value.lang.html
- include: style-lang-decider

style-lang-decider:
- match: (?i)(?=postcss{{unquoted_attribute_break}}|'postcss'|"postcss")
set:
- style-postcss
- tag-generic-attribute-meta
- tag-lang-attribute-meta
- tag-generic-attribute-value
- match: (?i)(?=css{{unquoted_attribute_break}}|\'css\'|"css")
set:
- style-css
- tag-generic-attribute-meta
- tag-lang-attribute-meta
- tag-generic-attribute-value
- match: (?i)(?=less{{unquoted_attribute_break}}|\'less\'|"less")
set:
- style-less
- tag-generic-attribute-meta
- tag-lang-attribute-meta
- tag-generic-attribute-value
- match: (?i)(?=sass{{unquoted_attribute_break}}|\'sass\'|"sass")
set:
- style-sass
- tag-generic-attribute-meta
- tag-lang-attribute-meta
- tag-generic-attribute-value
- match: (?i)(?=scss{{unquoted_attribute_break}}|\'scss\'|"scss")
set:
- style-scss
- tag-generic-attribute-meta
- tag-lang-attribute-meta
- tag-generic-attribute-value
- match: (?i)(?=stylus{{unquoted_attribute_break}}|\'stylus\'|"stylus")
set:
- style-stylus
- tag-generic-attribute-meta
- tag-lang-attribute-meta
- tag-generic-attribute-value
- match: (?=\S)
set:
- style-css
- tag-generic-attribute-meta
- tag-lang-attribute-meta
- tag-generic-attribute-value

style-less:
Expand Down
37 changes: 32 additions & 5 deletions tests/syntax_test_script.astro
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,33 @@


<script type="text/javascript"> <!--
// ^^^^^^^^ meta.tag - meta.attribute-with-value - source.js
// ^^^^^^^^^^^^^^^^^^^^^^ meta.tag meta.attribute-with-value - meta.attribute-with-value meta.attribute-with-value - source.js
// ^ meta.tag - meta.attribute-with-value - source.js
// ^^^^^ - meta.tag - source.js
// ^^^^^^ entity.name.tag
// ^^^^ entity.other.attribute-name.html
// ^ punctuation.separator.key-value.html
// ^^^^^^^^^^^^^^^^^ string.quoted.double.html
// ^^^^ comment.block.html punctuation.definition.comment.begin.html

var foo = 100;
// <- source.js.embedded.html - source.js source.js

(a --> b);
// ^^^ source.js.embedded.html keyword.operator - comment

--> </script>
// ^^^^^^^^^^^^^^ - source.js
// ^ - meta.tag - comment
// ^^^^^^^^^ meta.tag
// ^ - meta.tag
// ^^^ comment.block.html punctuation.definition.comment.end.html
// ^^ punctuation.definition.tag.begin.html
// ^^^^^^ entity.name.tag.script.html
// ^ punctuation.definition.tag.end.html

<script type="text/typescript"> <!--
// ^^^^^^^^ meta.tag - meta.attribute-with-value - source.ts
// ^^^^^^^^^^^^^^^^^^^^^^ meta.tag meta.attribute-with-value.html - meta.attribute-with-value meta.attribute-with-value - source.ts, meta.tag meta.attribute-with-value.type.html - meta.attribute-with-value meta.attribute-with-value - source.ts
// ^ meta.tag - meta.attribute-with-value - source.ts
Expand All @@ -93,10 +120,10 @@
// ^^^^ comment.block.html punctuation.definition.comment.begin.html

var foo = 100;
// <- source.js.embedded.html - source.ts source.ts
// <- source.ts.embedded.html - source.ts source.ts

(a --> b);
// ^^^ source.js.embedded.html keyword.operator - comment
// ^^^ source.ts.embedded.html keyword.operator - comment

--> </script>
// ^^^^^^^^^^^^^^ - source.ts
Expand All @@ -114,7 +141,7 @@
// ^^^^ meta.tag meta.attribute-with-value.html - meta.attribute-with-value meta.attribute-with-value, meta.tag meta.attribute-with-value.type.html - meta.attribute-with-value meta.attribute-with-value
=
application/jAvAsCrIpT>
// ^^^^^^^^^^^^^^^^^^^^^^ meta.tag meta.attribute-with-value.html - meta.attribute-with-value meta.attribute-with-value
// ^^^^^^^^^^^^^^^^^^^^^^ meta.tag meta.attribute-with-value - meta.attribute-with-value meta.attribute-with-value
var foo = 100;
// <- source.ts.embedded.html - source.ts source.ts
// ^^^^^^^^^^^^^^^^ source.ts.embedded.html - source.ts source.ts
Expand All @@ -129,7 +156,7 @@
// ^^^^^^^^^^^^^^^^^^ meta.tag.script.begin.html
// ^ punctuation.definition.tag.begin.html
// ^^^^^^ entity.name.tag.script.html
// ^^^^^^^^^ meta.attribute-with-value.html
// ^^^^^^^^^ meta.attribute-with-value.lang.html
// ^^^^ entity.other.attribute-name.html
// ^ punctuation.separator.key-value.html
// ^^^^ meta.string.html string.quoted.double.html
Expand Down Expand Up @@ -163,7 +190,7 @@

<script lang="other"> </script>
// ^^^^^^^^^^^^^^^^^^^^^ meta.tag - meta.tag meta.tag - source.ts
// ^^^^^^^^^^^^ meta.attribute-with-value.html - meta.attribute-with-value meta.attribute-with-value
// ^^^^^^^^^^^^ meta.attribute-with-value.lang.html - meta.attribute-with-value meta.attribute-with-value
// ^^ - meta.tag - source.ts
// ^^^^^^^^^ meta.tag - source.ts

Expand Down
10 changes: 5 additions & 5 deletions tests/syntax_test_style.astro
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@

<style lang="less"> </style>
// ^^^^^^^^^^^^^^^^^^^ meta.tag - source.css
// ^^^^^^^^^^^ meta.attribute-with-value.html - meta.attribute-with-value meta.attribute-with-value
// ^^^^^^^^^^^ meta.attribute-with-value.lang.html - meta.attribute-with-value meta.attribute-with-value
// ^^ source.less.embedded.html - meta.tag
// ^^^^^^^^ meta.tag - source.css
// ^^ punctuation.definition.tag.begin.html
Expand All @@ -140,7 +140,7 @@
// ^^^^^^^^^^^^^^^^^^^ meta.tag.style.begin.html
// ^ punctuation.definition.tag.begin.html
// ^^^^^ entity.name.tag.style.html
// ^^^^^^^^^^^ meta.attribute-with-value.html
// ^^^^^^^^^^^ meta.attribute-with-value.lang.html
// ^^^^ entity.other.attribute-name.html
// ^ punctuation.separator.key-value.html
// ^^^^^^ meta.string.html string.quoted.double.html
Expand Down Expand Up @@ -191,7 +191,7 @@
// ^^^^^^^^^^^^^^^^^^^ meta.tag.style.begin.html
// ^ punctuation.definition.tag.begin.html
// ^^^^^ entity.name.tag.style.html
// ^^^^^^^^^^^ meta.attribute-with-value.html
// ^^^^^^^^^^^ meta.attribute-with-value.lang.html
// ^^^^ entity.other.attribute-name.html
// ^ punctuation.separator.key-value.html
// ^^^^^^ meta.string.html string.quoted.double.html
Expand Down Expand Up @@ -225,7 +225,7 @@
// ^^^^^^^^^^^^^^^^^^^ meta.tag.style.begin.html
// ^ punctuation.definition.tag.begin.html
// ^^^^^ entity.name.tag.style.html
// ^^^^^^^^^^^ meta.attribute-with-value.html
// ^^^^^^^^^^^ meta.attribute-with-value.lang.html
// ^^^^ entity.other.attribute-name.html
// ^ punctuation.separator.key-value.html
// ^^^^^^ meta.string.html string.quoted.double.html
Expand Down Expand Up @@ -259,7 +259,7 @@
//^^^^^^^^^^^^^^^^^^^^^^ meta.tag.style.begin.html
//^ punctuation.definition.tag.begin.html
// ^^^^^ entity.name.tag.style.html
// ^^^^^^^^^^^^^ meta.attribute-with-value.html
// ^^^^^^^^^^^^^ meta.attribute-with-value.lang.html
// ^^^^ entity.other.attribute-name.html
// ^ punctuation.separator.key-value.html
// ^^^^^^^^ meta.string.html string.quoted.double.html
Expand Down

0 comments on commit 0fa888f

Please sign in to comment.