Skip to content

Commit 8527121

Browse files
authored
Merge pull request #4 from calmyournerves/support-css-class-characters
Add support for `:` and `/` in css class names
2 parents e2468e2 + c097bec commit 8527121

File tree

4 files changed

+27
-6
lines changed

4 files changed

+27
-6
lines changed

grammar.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,9 @@ module.exports = grammar({
193193
_element_rest_text: $ => token(prec(-3, /[^ \t][^\n]*/)),
194194

195195
// From css grammar https://github.com/tree-sitter/tree-sitter-css/blob/master/grammar.js
196-
// Originally: /\A(#{keys}+)((?:\p{Word}|-|\/\d+|:(\w|-)+)*)/
197-
css_identifier: $ => /(--|-?[a-zA-Z_])[a-zA-Z0-9-_]*/,
196+
// Originally from Slim: /\A(#{keys}+)((?:\p{Word}|-|\/\d+|:(\w|-)+)*)/
197+
// With added support for `:` and `/`
198+
css_identifier: $ => /(--|-?[a-zA-Z_])[a-zA-Z0-9-_:\/]*/,
198199

199200
// From doc, mostly unclear, which means which
200201
doctype: $ => seq(

src/grammar.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/parser.c

+4-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/corpus/tags.txt

+19
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,25 @@ span.menu.active
2828
(attr_shortcut_class
2929
(css_identifier)))))
3030

31+
================================
32+
Tag and css classes with : and /
33+
================================
34+
35+
span.hidden.lg:block.w-1/2
36+
37+
---
38+
39+
(source_file
40+
(element
41+
(tag_name)
42+
(attr_shortcuts
43+
(attr_shortcut_class
44+
(css_identifier))
45+
(attr_shortcut_class
46+
(css_identifier))
47+
(attr_shortcut_class
48+
(css_identifier)))))
49+
3150
===============================
3251
Tag with traling space modifier
3352
===============================

0 commit comments

Comments
 (0)