Skip to content

Commit

Permalink
Merge pull request #867 from redoPop/atful-css
Browse files Browse the repository at this point in the history
Add support for CSS class names containing the `@` sign ("commercial at", U+0040)
  • Loading branch information
k0kubun committed Apr 18, 2017
2 parents e7ccb95 + 13eff01 commit ed7f24f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/haml/parser.rb
Expand Up @@ -554,7 +554,7 @@ def self.parse_class_and_id(list)
attributes = {}
return attributes if list.empty?

list.scan(/([#.])([-:_a-zA-Z0-9]+)/) do |type, property|
list.scan(/([#.])([-:_a-zA-Z0-9@]+)/) do |type, property|
case type
when '.'
if attributes[CLASS_KEY]
Expand Down Expand Up @@ -593,7 +593,7 @@ def parse_static_hash(text)

# Parses a line into tag_name, attributes, attributes_hash, object_ref, action, value
def parse_tag(text)
match = text.scan(/%([-:\w]+)([-:\w.#]*)(.+)?/)[0]
match = text.scan(/%([-:\w]+)([-:\w.#@]*)(.+)?/)[0]
raise SyntaxError.new(Error.message(:invalid_tag, text)) unless match

tag_name, attributes, rest = match
Expand Down
4 changes: 4 additions & 0 deletions test/results/bemit.xhtml
@@ -0,0 +1,4 @@
<div class='o-media@md c-user c-user--premium'>
<img alt='' class='o-media__img@md c-user__photo c-avatar' src='' />
<p class='o-media__body@md c-user__bio'>...</p>
</div>
2 changes: 1 addition & 1 deletion test/template_test.rb
Expand Up @@ -8,7 +8,7 @@ class TemplateTest < Haml::TestCase
TEMPLATES = %w{ very_basic standard helpers
whitespace_handling original_engine list helpful
silent_script tag_parsing just_stuff partials
nuke_outer_whitespace nuke_inner_whitespace
nuke_outer_whitespace nuke_inner_whitespace bemit
render_layout partial_layout partial_layout_erb}

def setup
Expand Down
3 changes: 3 additions & 0 deletions test/templates/bemit.haml
@@ -0,0 +1,3 @@
.o-media@md.c-user.c-user--premium
%img.o-media__img@md.c-user__photo.c-avatar{src: '', alt: ''}
%p.o-media__body@md.c-user__bio ...

0 comments on commit ed7f24f

Please sign in to comment.