diff --git a/Syntaxes/Embeddings/TSX (for Astro).sublime-syntax b/Syntaxes/Embeddings/TSX (for Astro).sublime-syntax new file mode 100644 index 0000000..8cef180 --- /dev/null +++ b/Syntaxes/Embeddings/TSX (for Astro).sublime-syntax @@ -0,0 +1,24 @@ +%YAML 1.2 +--- +# http://www.sublimetext.com/docs/syntax.html +scope: source.tsx.embedded.astro +version: 2 +hidden: true + +extends: Packages/JavaScript/TSX.sublime-syntax + +contexts: + + jsx-meta: + # add support for multiple elements + # https://docs.astro.build/en/basics/astro-syntax/#multiple-elements + - meta_include_prototype: false + - meta_scope: meta.jsx.js + - match: '<(?=\s*[/>{{identifier_start}}])' + scope: punctuation.definition.tag.begin.js + push: jsx-tag-attributes-top + - include: else-pop + + jsx-tag-attributes: + - meta_prepend: true + - include: HTML (Astro).sublime-syntax#astro-directives diff --git a/Syntaxes/HTML (Astro).sublime-syntax b/Syntaxes/HTML (Astro).sublime-syntax index e30e13b..900aed5 100644 --- a/Syntaxes/HTML (Astro).sublime-syntax +++ b/Syntaxes/HTML (Astro).sublime-syntax @@ -553,5 +553,5 @@ contexts: - match: \} scope: punctuation.section.interpolation.end.astro pop: 1 - - include: scope:source.tsx#script + - include: scope:source.tsx.embedded.astro#script apply_prototype: true diff --git a/tests/syntax_test_astro.astro b/tests/syntax_test_astro.astro index 0de18f2..abbec2c 100644 --- a/tests/syntax_test_astro.astro +++ b/tests/syntax_test_astro.astro @@ -222,3 +222,90 @@ // ^ punctuation.section.interpolation.end.astro // ^^ punctuation.definition.tag.end.astro + +// Dynamic HTML + + +//^^ meta.tag +//^ entity.name.tag.block.any.html +// ^ punctuation.definition.tag.end.html +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.interpolation.astro +// ^ punctuation.section.interpolation.begin.astro +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.tsx.embedded.astro +// ^^^^^ variable.other +// ^ punctuation.accessor +// ^^^ meta.function-call variable.function +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call meta.group +// ^^^^^^^^^^^^^^^^^ meta.block meta.group +// ^^^^^^^^^^^^^^^ meta.jsx +// ^^^^ meta.tag +// ^^^^^^ meta.interpolation +// ^^^^^ meta.tag +// ^^^^^ meta.tag + + {visible &&

Show me!

} +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.interpolation.astro +//^ punctuation.section.interpolation.begin.astro +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ source.tsx.embedded.astro +// ^^^^^^^ variable.other +// ^^ keyword.operator.logical.js +// ^^^^^^^^^^^^^^^ meta.jsx.js +// ^^^ meta.tag +// ^^^^ meta.tag +// ^ punctuation.section.interpolation.end.astro + + {visible ?

Show me!

:

Else show me!

} +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.interpolation.astro +//^ punctuation.section.interpolation.begin.astro +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.tsx.embedded.astro +// ^^^^^^^ variable.other +// ^ keyword.operator.ternary.js +// ^^^^^^^^^^^^^^^^ meta.jsx.js +// ^^^ meta.tag +// ^^^^ meta.tag +// ^ keyword.operator.ternary.js +// ^^^^^^^^^^^^^^^^^^^^ meta.jsx.js +// ^^^ meta.tag +// ^^^^ meta.tag +// ^ punctuation.section.interpolation.end.astro + +// Multiple Elements + + {(

Show

me

)} +//^^^^^^^^^^^^^^^^^^^^^^^^ meta.interpolation.astro +//^ punctuation.section.interpolation.begin.astro +// ^^^^^^^^^^^^^^^^^^^^^^ source.tsx.embedded.astro meta.group.js +// ^ punctuation.section.group.begin.js +// ^^^^^^^^^^^^^^^^^^^^ meta.jsx.js +// ^^^ meta.tag +// ^^^^^^^ meta.tag +// ^^^^ meta.tag +// ^ punctuation.section.interpolation.end.astro + +// https://github.com/SublimeText/Astro/issues/11 + + {VITE_USE_VITE_WEB_COMPONENTS && ( + + +// ^ meta.tag punctuation.definition.tag.begin.js +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.tag +// ^^^^^^ entity.name.tag.native.js +// ^^^^ entity.other.attribute-name.js +// ^ punctuation.separator.key-value.js +// ^^^^^^^^ string.quoted.double.js +// ^ punctuation.definition.string.begin.js +// ^ punctuation.definition.string.end.js +// ^^^ entity.other.attribute-name.js +// ^ punctuation.separator.key-value.js +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ string.quoted.double.js +// ^ punctuation.definition.string.begin.js +// ^ punctuation.definition.string.end.js +// ^^^^^^^^^ meta.attribute-with-value.astro +// ^^ keyword.control.directive.astro +// ^ punctuation.separator.key-value.astro +// ^^^^^^ variable.parameter.astro +// ^ punctuation.definition.tag.end.js +// ^^ punctuation.definition.tag.begin.js +// ^^^^^^ entity.name.tag.native.js +// ^ punctuation.definition.tag.end.js + )} \ No newline at end of file