mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-10 07:20:06 -04:00
injections(html): fix faulty css/js injections
Group queries to reduce duplicate injection tree use only regex
This commit is contained in:
parent
3731cf1c0c
commit
d11dd552db
3 changed files with 17 additions and 27 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue