Skip to content

Commit c45a710

Browse files
authored
feat(queries): Extract html_tags rules (#501)
* feat(queries): Extract html_tags rules * ignore queries test for html_tags
1 parent 1863cb2 commit c45a710

File tree

6 files changed

+116
-11
lines changed

6 files changed

+116
-11
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Changelog
22

33
## Unreleased
4+
- feat(queries): Extract `html_tags` rules
45
- feat(queries): Extract `ecma` rules
56

67
## 0.12.165 - 2024-03-31

queries/html/highlights.scm

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
(tag_name) @tag
2-
(erroneous_end_tag_name) @tag.error
1+
;; inherits: html_tags
2+
33
(doctype) @constant
4-
(attribute_name) @attribute
5-
(attribute_value) @string
6-
(comment) @comment
74

8-
"<" @punctuation.bracket
9-
">" @punctuation.bracket
10-
"</" @punctuation.bracket
5+
"<!" @tag.delimiter
6+
7+
(entity) @character.special

queries/html_tags/highlights.scm

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
(tag_name) @tag
2+
3+
; (erroneous_end_tag_name) @error ; we do not lint syntax errors
4+
(comment) @comment @spell
5+
6+
(attribute_name) @tag.attribute
7+
8+
((attribute
9+
(quoted_attribute_value) @string)
10+
(#set! "priority" 99))
11+
12+
(text) @none @spell
13+
14+
((element
15+
(start_tag
16+
(tag_name) @_tag)
17+
(text) @markup.heading)
18+
(#eq? @_tag "title"))
19+
20+
((element
21+
(start_tag
22+
(tag_name) @_tag)
23+
(text) @markup.heading.1)
24+
(#eq? @_tag "h1"))
25+
26+
((element
27+
(start_tag
28+
(tag_name) @_tag)
29+
(text) @markup.heading.2)
30+
(#eq? @_tag "h2"))
31+
32+
((element
33+
(start_tag
34+
(tag_name) @_tag)
35+
(text) @markup.heading.3)
36+
(#eq? @_tag "h3"))
37+
38+
((element
39+
(start_tag
40+
(tag_name) @_tag)
41+
(text) @markup.heading.4)
42+
(#eq? @_tag "h4"))
43+
44+
((element
45+
(start_tag
46+
(tag_name) @_tag)
47+
(text) @markup.heading.5)
48+
(#eq? @_tag "h5"))
49+
50+
((element
51+
(start_tag
52+
(tag_name) @_tag)
53+
(text) @markup.heading.6)
54+
(#eq? @_tag "h6"))
55+
56+
((element
57+
(start_tag
58+
(tag_name) @_tag)
59+
(text) @markup.strong)
60+
(#any-of? @_tag "strong" "b"))
61+
62+
((element
63+
(start_tag
64+
(tag_name) @_tag)
65+
(text) @markup.italic)
66+
(#any-of? @_tag "em" "i"))
67+
68+
((element
69+
(start_tag
70+
(tag_name) @_tag)
71+
(text) @markup.strikethrough)
72+
(#any-of? @_tag "s" "del"))
73+
74+
((element
75+
(start_tag
76+
(tag_name) @_tag)
77+
(text) @markup.underline)
78+
(#eq? @_tag "u"))
79+
80+
((element
81+
(start_tag
82+
(tag_name) @_tag)
83+
(text) @markup.raw)
84+
(#any-of? @_tag "code" "kbd"))
85+
86+
((element
87+
(start_tag
88+
(tag_name) @_tag)
89+
(text) @string.special.url)
90+
(#eq? @_tag "a"))
91+
92+
((attribute
93+
(attribute_name) @_attr
94+
(quoted_attribute_value
95+
(attribute_value) @string.special.url))
96+
(#any-of? @_attr "href" "src"))
97+
98+
[
99+
"<"
100+
">"
101+
"</"
102+
"/>"
103+
] @tag.delimiter
104+
105+
"=" @operator

queries/svelte/highlights.scm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; inherits: html_tags
1+
;; inherits: html_tags
22
(raw_text_expr) @none
33

44
[

tree-sitter-langs-tests.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
(require 'subr-x))
2121

2222
(defvar tree-sitter-langs-tests-ignore-queries
23-
'( psv tsv ecma)
23+
'( psv tsv ecma html_tags)
2424
"List of queries to ignore the test.")
2525

2626
(defun tree-sitter-langs-tests-check-queries (lang-symbol)

tree-sitter-langs.el

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,10 +248,12 @@ Return nil if there are no bundled patterns."
248248
(dolist (sym (cons lang-symbol
249249
(pcase lang-symbol
250250
('arduino '(cpp c))
251-
('astro '(html))
251+
('astro '(html_tags html))
252252
('cpp '(c))
253253
('csv '(tsv))
254254
('hlsl '(cpp c))
255+
('html '(html_tags))
256+
('svelte '(html_tags))
255257
('javascript '(ecma))
256258
('typescript '(ecma))
257259
('tsx '(ecma typescript))

0 commit comments

Comments
 (0)