-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquerys.lua
More file actions
61 lines (57 loc) · 1.51 KB
/
Copy pathquerys.lua
File metadata and controls
61 lines (57 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
local M = {}
-- <link href="" rel="stylesheet" />
-- query for extracting href values from the page
-- this is general query for extracting information from
-- vue, svelte, html files.
-- this query extract links that ends with .css,.scss,.less or .sass extension.
-- So it will ignore the links like google fonts or what what ever you have in the link href tag
M.general_link_href = [[
((tag_name) @tag (#eq? @tag "link")
(attribute
(attribute_name) @attr_name (#eq? @attr_name "href")
(quoted_attribute_value
((attribute_value) @href_value (#match? @href_value "\\.css$|\\.less$|\\.scss$|\\.sass$")))))
]]
M.selectors = [[
(
(rule_set
(selectors
(class_selector
(class_name) @class_name)
) @class_decl
(#lua-match? @class_decl "^[.][a-zA-Z0-9_-]+$")
(#not-has-ancestor? @class_decl "media_statement")
(block) @class_block
)
)
;; find nested class
;; (
;; (rule_set
;; (selectors
;; (class_selector
;; (class_name) @nested.class_name)
;; ) @nested.class_decl
;; (#lua-match? @nested.class_decl "^[.][a-zA-Z0-9_-]+$")
;; (#not-has-ancestor? @nested.class_decl "media_statement")
;; (block) @nested.class_block
;; ) @nested.rs (#has-ancestor? @nested.rs "rule_set")
;;)
(
(rule_set
(selectors
(id_selector
(id_name) @id_name)
) @id_decl
(#lua-match? @id_decl "^#[a-zA-Z0-9_-]+")
(#not-has-ancestor? @id_decl "media_statement")
(block) @id_block
)
)
]]
M.internal_selectors = [[
(id_selector
(id_name) @id_name)
(class_selector
(class_name) @class_name)
]]
return M