diff --git a/Syntaxes/HTML (Blade).sublime-syntax b/Syntaxes/HTML (Blade).sublime-syntax index c752319..963bd8d 100644 --- a/Syntaxes/HTML (Blade).sublime-syntax +++ b/Syntaxes/HTML (Blade).sublime-syntax @@ -83,6 +83,51 @@ contexts: 3: source.css.embedded.html 4: comment.block.html punctuation.definition.comment.end.html + tag-attributes: + - meta_prepend: true + - include: tag-blade-attributes + + tag-blade-attributes: + - match: :\w+\b + scope: entity.other.attribute-name.blade + push: + - tag-blade-attribute-meta + - tag-blade-attribute-assignment + + tag-blade-attribute-meta: + - meta_include_prototype: false + - meta_scope: meta.attribute-with-value.blade + - include: immediately-pop + + tag-blade-attribute-assignment: + - meta_include_prototype: false + - match: = + scope: punctuation.separator.key-value.html + set: tag-blade-attribute-value + - include: else-pop + + tag-blade-attribute-value: + - meta_include_prototype: false + # add extra meta.attribute-with-value.blade in escape_capture to work around + # https://github.com/sublimehq/sublime_text/issues/3784 + - match: \" + scope: meta.string.html string.quoted.double.html punctuation.definition.string.begin.html + embed: scope:source.php#expressions + embed_scope: meta.string.html meta.embedded.html source.php.embedded.html + escape: \" + escape_captures: + 0: meta.attribute-with-value.blade meta.string.html string.quoted.double.html punctuation.definition.string.end.html + pop: 1 + - match: \' + scope: meta.string.html string.single.double.html punctuation.definition.string.begin.html + embed: scope:source.php#expressions + embed_scope: meta.string.html meta.embedded.html source.php.embedded.html + escape: \' + escape_captures: + 0: meta.attribute-with-value.blade meta.string.html string.single.single.html punctuation.definition.string.end.html + pop: 1 + - include: else-pop + tag-generic-attribute: # fixes: https://github.com/Medalink/laravel-blade/issues/196 - meta_prepend: true diff --git a/tests/syntax_test_blade.blade.php b/tests/syntax_test_blade.blade.php index 7ff3905..96d019d 100644 --- a/tests/syntax_test_blade.blade.php +++ b/tests/syntax_test_blade.blade.php @@ -194,7 +194,7 @@ {{-- ^ keyword.operator.assignment.php --}} {{-- ^^^^ variable.other.php --}} {{-- ^^ keyword.operator.null-coalescing.php --}} -{{-- ^^^^^ constant.language.boolean.php --}} +{{-- ^^^^^ constant.language.boolean --}} {{-- ^ punctuation.section.arguments.end.blade - source.php --}} @php($bool = $bool ?: true) @@ -208,7 +208,7 @@ {{-- ^ keyword.operator.assignment.php --}} {{-- ^^^^^ variable.other.php --}} {{-- ^^ keyword.operator.ternary.php --}} -{{-- ^^^^ constant.language.boolean.php --}} +{{-- ^^^^ constant.language.boolean --}} {{-- ^ punctuation.section.arguments.end.blade - source.php --}} @@ -1200,3 +1200,51 @@ {{-- ^ punctuation.separator.key-value.html --}} {{-- ^^^^^^^^^^^^^^^^^^^^^^^ meta.string.html string.quoted.double.html --}} {{-- ^ punctuation.definition.tag.end.html --}} + + +{{--^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.tag.other.html --}} +{{--^^^^^^^ entity.name.tag.other.html --}} +{{-- ^^^^^^^^^^^^ meta.attribute-with-value.html --}} +{{-- ^^^^ entity.other.attribute-name.html --}} +{{-- ^ punctuation.separator.key-value.html --}} +{{-- ^^^^^^^ meta.string.html string.quoted.double.html --}} +{{-- ^ punctuation.definition.string.begin.html --}} +{{-- ^ punctuation.definition.string.end.html --}} +{{-- ^^^^^^^^^^^^^^^^^^^ meta.attribute-with-value.blade --}} +{{-- ^^^^^^^^ entity.other.attribute-name.blade --}} +{{-- ^ punctuation.separator.key-value.html --}} +{{-- ^^^^^^^^^^ meta.string.html --}} +{{-- ^ string.quoted.double.html punctuation.definition.string.begin.html --}} +{{-- ^^^^^^^^ meta.embedded.html source.php.embedded.html variable.other.php --}} +{{-- ^ punctuation.definition.variable.php --}} +{{-- ^ string.quoted.double.html punctuation.definition.string.end.html --}} +{{-- ^^^^^^^^^^^^ meta.attribute-with-value.class.html --}} +{{-- ^^^^^ entity.other.attribute-name.class.html --}} +{{-- ^ punctuation.separator.key-value.html --}} +{{-- ^ meta.string.html string.quoted.double.html punctuation.definition.string.begin.html --}} +{{-- ^^^^ meta.class-name.html meta.string.html string.quoted.double.html --}} +{{-- ^ meta.string.html string.quoted.double.html punctuation.definition.string.end.html --}} +{{-- ^^ punctuation.definition.tag.end.html --}} + + Product +{{--^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.tag.other.html --}} +{{-- ^^^^^^^^^^^^^ meta.tag.other.html --}} +{{--^^^^^^^^^^ entity.name.tag.other.html --}} +{{-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute-with-value.blade --}} +{{-- ^^^^^^^ entity.other.attribute-name.blade --}} +{{-- ^ punctuation.separator.key-value.html --}} +{{-- ^ meta.string.html string.quoted.double.html punctuation.definition.string.begin.html --}} +{{-- ^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.html meta.embedded.html source.php.embedded.html --}} +{{-- ^ meta.string.html string.quoted.double.html punctuation.definition.string.end.html --}} +{{-- ^ - meta.attribute-with-value --}} +{{-- ^^^^^^^^^^^^^^^ meta.attribute-with-value.href.html --}} +{{-- ^^^^ entity.other.attribute-name.href.html --}} +{{-- ^ punctuation.separator.key-value.html --}} +{{-- ^ meta.string.html string.quoted.double.html punctuation.definition.string.begin.html --}} +{{-- ^^^^^^^^ meta.path.url.html meta.string.html string.quoted.double.html --}} +{{-- ^ punctuation.separator.path.html --}} +{{-- ^ meta.string.html string.quoted.double.html punctuation.definition.string.end.html --}} +{{-- ^ punctuation.definition.tag.end.html --}} +{{-- ^^ punctuation.definition.tag.begin.html --}} +{{-- ^^^^^^^^^^ entity.name.tag.other.html --}} +{{-- ^ punctuation.definition.tag.end.html --}}