Skip to content

Commit

Permalink
Add support for slashes and colons in class names
Browse files Browse the repository at this point in the history
This is to add support for [Tailwind CSS](https://tailwindcss.com/)
  • Loading branch information
thewatts committed Mar 21, 2020
1 parent d7fbf99 commit b5e2cda
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/slim/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def initialize(opts = {})
end
end
keys = Regexp.union @attr_shortcut.keys.sort_by {|k| -k.size }
@attr_shortcut_re = /\A(#{keys}+)((?:\p{Word}|-)*)/
@attr_shortcut_re = /\A(#{keys}+)((?:\p{Word}|-|\/\d+|:(\w|-)+)*)/
keys = Regexp.union @tag_shortcut.keys.sort_by {|k| -k.size }
@tag_re = /\A(?:#{keys}|\*(?=[^\s]+)|(\p{Word}(?:\p{Word}|:|-)*\p{Word}|\p{Word}+))/
keys = Regexp.escape @code_attr_delims.keys.join
Expand Down
10 changes: 9 additions & 1 deletion test/literate/TESTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -1186,13 +1186,15 @@ renders to

#### ID shortcut and class shortcut `.`

ID and class shortcuts can contain dashes.
ID and class shortcuts can contain dashes, slashes with digits, and colons.

~~~ slim
.-test text
#test- text
.--a#b- text
.a--test-123#--b text
.a-1/2#b-1/2 text
.ab:c-test#d:e text
~~~

renders as
Expand All @@ -1210,6 +1212,12 @@ renders as
<div class="a--test-123" id="--b">
text
</div>
<div class="a-1/2" id="b-1/2">
text
</div>
<div class="ab:c-test" id="d:e">
text
</div>
~~~

## Text interpolation
Expand Down

0 comments on commit b5e2cda

Please sign in to comment.