Skip to content

Commit

Permalink
[PHP] Improve event/style attribute value contexts (#3630)
Browse files Browse the repository at this point in the history
* [PHP] Exclude prototype from event/style attribute values

This commit excludes `prototype` from event/style attribute values as
those contexts already include inherit syntax which highlights PHP tags
well. Injecting prototype just creates duplicate patterns.

* [PHP] Split strings into -body/-content

This commit makes it easier for inheriting syntax to replace embedded
JavaScript/CSS without duplicating all the basic string patterns.
  • Loading branch information
deathaxe authored Dec 20, 2022
1 parent 24efbbb commit ed3bf63
Showing 1 changed file with 26 additions and 8 deletions.
34 changes: 26 additions & 8 deletions PHP/PHP.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -125,53 +125,71 @@ contexts:
4: comment.block.html punctuation.definition.comment.end.html

tag-event-attribute-value:
- meta_include_prototype: false
- match: \"
scope: string.quoted.double.html punctuation.definition.string.begin.html
set: tag-event-attribute-value-double-quoted-content
set: tag-event-attribute-value-double-quoted-body
- match: \'
scope: string.quoted.single.html punctuation.definition.string.begin.html
set: tag-event-attribute-value-single-quoted-content
set: tag-event-attribute-value-single-quoted-body
- include: else-pop

tag-event-attribute-value-double-quoted-content:
tag-event-attribute-value-double-quoted-body:
- meta_include_prototype: false
- meta_scope: meta.string.html
- meta_content_scope: meta.interpolation.html source.js.embedded.html
- match: \"
scope: string.quoted.double.html punctuation.definition.string.end.html
pop: 1
- include: tag-event-attribute-value-double-quoted-content

tag-event-attribute-value-double-quoted-content:
- include: scope:source.js.embedded.string.quoted.double.php

tag-event-attribute-value-single-quoted-content:
tag-event-attribute-value-single-quoted-body:
- meta_include_prototype: false
- meta_scope: meta.string.html
- meta_content_scope: meta.interpolation.html source.js.embedded.html
- match: \'
scope: string.quoted.single.html punctuation.definition.string.end.html
pop: 1
- include: tag-event-attribute-value-single-quoted-content

tag-event-attribute-value-single-quoted-content:
- include: scope:source.js.embedded.string.quoted.single.php

tag-style-attribute-value:
- meta_include_prototype: false
- match: \"
scope: string.quoted.double.html punctuation.definition.string.begin.html
set: tag-style-attribute-value-double-quoted-content
set: tag-style-attribute-value-double-quoted-body
- match: \'
scope: string.quoted.single.html punctuation.definition.string.begin.html
set: tag-style-attribute-value-single-quoted-content
set: tag-style-attribute-value-single-quoted-body
- include: else-pop

tag-style-attribute-value-double-quoted-content:
tag-style-attribute-value-double-quoted-body:
- meta_include_prototype: false
- meta_scope: meta.string.html
- meta_content_scope: meta.interpolation.html source.css.embedded.html
- match: \"
scope: string.quoted.double.html punctuation.definition.string.end.html
pop: 1
- include: tag-style-attribute-value-double-quoted-content

tag-style-attribute-value-double-quoted-content:
- include: scope:source.css.embedded.string.quoted.double.php

tag-style-attribute-value-single-quoted-content:
tag-style-attribute-value-single-quoted-body:
- meta_include_prototype: false
- meta_scope: meta.string.html
- meta_content_scope: meta.interpolation.html source.css.embedded.html
- match: \'
scope: string.quoted.single.html punctuation.definition.string.end.html
pop: 1
- include: tag-style-attribute-value-single-quoted-content

tag-style-attribute-value-single-quoted-content:
- include: scope:source.css.embedded.string.quoted.single.php

tag-attribute-value-content:
Expand Down

0 comments on commit ed3bf63

Please sign in to comment.