diff --git a/queries/html/injections.scm b/queries/html/injections.scm index 682431195..7ddb5beae 100644 --- a/queries/html/injections.scm +++ b/queries/html/injections.scm @@ -1,12 +1 @@ -((style_element - (raw_text) @css)) - -((attribute - (attribute_name) @_attr - (quoted_attribute_value (attribute_value) @css)) - (#eq? @_attr "style")) - -((script_element - (raw_text) @javascript)) - -(comment) @comment +; inherits html_tags diff --git a/queries/html_tags/injections.scm b/queries/html_tags/injections.scm index 80c0d2a4a..63d00a753 100644 --- a/queries/html_tags/injections.scm +++ b/queries/html_tags/injections.scm @@ -1,7 +1,67 @@ -((style_element - (raw_text) @css)) +; +( + (style_element + (start_tag) @_no_attribute + (raw_text) @css) + (#match? @_no_attribute "^\\<\\s*style\\s*\\>$") + ; unsure why, but without escaping < and > the query breaks +) -((script_element - (raw_text) @javascript)) +; +; 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") +) + +( + (style_element + (start_tag + (attribute + (attribute_name) @_type + (quoted_attribute_value (attribute_value) @_css))) + (raw_text) @css) + (#eq? @_type "type") + (#eq? @_css "text/css") +) + +; +( + (script_element + (start_tag) @_no_attribute + (raw_text) @javascript) + (#match? @_no_attribute "^\\<\\s*script\\s*\\>$") +) + +; +( + (script_element + (start_tag + (attribute + (attribute_name) @_no_set_type)) + (raw_text) @javascript) + (#not-any-of? @_no_set_type "type" "lang") +) + +( + (script_element + (start_tag + (attribute + (attribute_name) @_type + (quoted_attribute_value (attribute_value) @_javascript))) + (raw_text) @javascript) + (#eq? @_type "type") + (#eq? @_javascript "text/javascript") +) + +((attribute + (attribute_name) @_attr + (quoted_attribute_value (attribute_value) @css)) + (#eq? @_attr "style")) (comment) @comment diff --git a/queries/vue/injections.scm b/queries/vue/injections.scm index 223791c09..84ac2160e 100644 --- a/queries/vue/injections.scm +++ b/queries/vue/injections.scm @@ -1,20 +1,6 @@ -( - (style_element - (start_tag) @_no_attribute - (raw_text) @css) - (#match? @_no_attribute "^\\<\\s*style\\s*\\>$") - ; unsure why, but without escaping < and > the query breaks -) - -( - (style_element - (start_tag - (attribute - (attribute_name) @_no_lang)) - (raw_text) @css) - (#not-eq? @_no_lang "lang") -) +; inherits html_tags +; + + +
+ + Test div to test css injections for style attributes +
+ +