aboutsummaryrefslogtreecommitdiffstats
path: root/queries
diff options
context:
space:
mode:
authorPham Huy Hoang <hoangtun0810@gmail.com>2023-03-03 09:09:52 +0700
committerObserverOfTime <chronobserver@disroot.org>2023-03-05 22:34:41 +0200
commitd11dd552dbde181cd49652188521f4b5f6cad2f8 (patch)
treee523d048cbf9bfa2a614e318ac0183f4830f04b4 /queries
parentUpdate parsers: zig (diff)
downloadnvim-treesitter-d11dd552dbde181cd49652188521f4b5f6cad2f8.tar
nvim-treesitter-d11dd552dbde181cd49652188521f4b5f6cad2f8.tar.gz
nvim-treesitter-d11dd552dbde181cd49652188521f4b5f6cad2f8.tar.bz2
nvim-treesitter-d11dd552dbde181cd49652188521f4b5f6cad2f8.tar.lz
nvim-treesitter-d11dd552dbde181cd49652188521f4b5f6cad2f8.tar.xz
nvim-treesitter-d11dd552dbde181cd49652188521f4b5f6cad2f8.tar.zst
nvim-treesitter-d11dd552dbde181cd49652188521f4b5f6cad2f8.zip
injections(html): fix faulty css/js injections
Group queries to reduce duplicate injection tree use only regex
Diffstat (limited to 'queries')
-rw-r--r--queries/html_tags/injections.scm34
1 files changed, 7 insertions, 27 deletions
diff --git a/queries/html_tags/injections.scm b/queries/html_tags/injections.scm
index c29619281..5f0719c64 100644
--- a/queries/html_tags/injections.scm
+++ b/queries/html_tags/injections.scm
@@ -1,22 +1,12 @@
; <style>...</style>
-(
- (style_element
- (start_tag
- (tag_name) .)
- (raw_text) @css)
-)
-
; <style blocking> ...</style>
; Add "lang" to predicate check so that vue/svelte can inherit this
; without having this element being captured twice
(
(style_element
- (start_tag
- (attribute
- (attribute_name) @_no_set_type))
- (raw_text) @css)
- (#not-any-of? @_no_set_type "type" "lang")
-)
+ (start_tag) @_no_type_lang
+ (#not-match? @_no_type_lang "\\s(lang|type)\\s*\\=")
+ (raw_text) @css))
(
(style_element
@@ -30,22 +20,12 @@
)
; <script>...</script>
-(
- (script_element
- (start_tag
- (tag_name) .)
- (raw_text) @javascript)
-)
-
; <script defer>...</script>
(
(script_element
- (start_tag
- (attribute
- (attribute_name) @_no_set_type))
- (raw_text) @javascript)
- (#not-any-of? @_no_set_type "type" "lang")
-)
+ (start_tag) @_no_type_lang
+ (#not-match? @_no_type_lang "\\s(lang|type)\\s*\\=")
+ (raw_text) @javascript))
(
(script_element
@@ -55,7 +35,7 @@
(quoted_attribute_value (attribute_value) @_javascript)))
(raw_text) @javascript)
(#eq? @_type "type")
- (#eq? @_javascript "text/javascript")
+ (#any-of? @_javascript "text/javascript" "module")
)
((attribute