Skip to content

Commit

Permalink
Fix typescript mimetype
Browse files Browse the repository at this point in the history
This commit ...

1. adds support for explicit typescript mime type
2. uses typescript by default in script tags
  • Loading branch information
deathaxe committed Nov 2, 2024
1 parent 2d345ae commit b9e2e92
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 8 additions & 1 deletion 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 @@ -174,9 +176,14 @@ contexts:

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
- script-typescript
- tag-type-attribute-meta
- tag-generic-attribute-value

Expand Down
4 changes: 2 additions & 2 deletions tests/syntax_test_script.astro
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
// ^ punctuation.separator.key-value.html
// ^^^^^^^^^^^^^^^^^ string.quoted.double.html
// ^^^^ comment.block.html punctuation.definition.comment.begin.html
// ^ source.js.embedded.html
// ^ source.ts.embedded.html

var foo = 100;
// <- source.ts.embedded.html - source.ts source.ts
Expand All @@ -134,7 +134,7 @@
// ^^^ source.ts.embedded.html keyword.operator - comment

--> </script>
// ^ source.js.embedded.html - source.ts source.ts
// ^ source.ts.embedded.html - source.ts source.ts
// ^^^^^^^^^^^^^^ - source.ts
// ^ - meta.tag - comment
// ^^^^^^^^^ meta.tag
Expand Down

0 comments on commit b9e2e92

Please sign in to comment.