Skip to content

Commit

Permalink
[HTML] Restrict main HTML snippet (#4084)
Browse files Browse the repository at this point in the history
This commit disables `html` snippet in ...

- comments
- literal or interpolated strings
- embedded or interpolated code blocks (from template languages)
- HTML tags
- Markdown files (but not in fenced code blocks)

Using `- text.html <scope>` in order to only exclude scopes belonging to
possibly embedded HTML code block in question.

This is required to enable snippets if HTML is embedded in `source` code,

   source.astro text.html

but disable it in embedded CSS/JS or any other source code.

   text.html source.css
  • Loading branch information
deathaxe authored Nov 24, 2024
1 parent 0bd3246 commit c320a8b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
5 changes: 4 additions & 1 deletion HTML/Snippets/html (begin tag).sublime-snippet
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ $0
</body>
</html>]]></content>
<tabTrigger>html</tabTrigger>
<scope>text.html entity.name.tag, text.html meta.character.less-than</scope>
<scope>
(text.html entity.name.tag, text.html meta.character.less-than)
- (text.html.markdown - markup.raw.code-fence text.html)
</scope>
<description>html</description>
</snippet>
13 changes: 12 additions & 1 deletion HTML/Snippets/html.sublime-snippet
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@ $0
</body>
</html>]]></content>
<tabTrigger>html</tabTrigger>
<scope>text.html - (meta.tag | meta.character.less-than) - source.php</scope>
<scope>
text.html
- text.html meta.tag
- text.html meta.character.less-than
- text.html meta.embedded
- text.html meta.interpolation
- text.html meta.string
- text.html source
- text.html comment
- text.html string
- (text.html.markdown - markup.raw.code-fence text.html)
</scope>
<description>html</description>
</snippet>

0 comments on commit c320a8b

Please sign in to comment.