Skip to content

Commit

Permalink
Ensure tricky comments don't cause exceptions
Browse files Browse the repository at this point in the history
We had this comment in our codebase and it was causing the whole parse
to fail
  • Loading branch information
kneath committed Sep 20, 2013
1 parent b2ed27f commit 589a9cd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/kss/section.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def section
return @section unless @section.nil?

cleaned = section_comment.strip.sub(/\.$/, '') # Kill trailing period
@section = cleaned.match(/Styleguide (.+)/)[1]
@section = cleaned.match(/Styleguide (.+)/i)[1]

@section
end
Expand Down
9 changes: 9 additions & 0 deletions test/fixtures/css/buttons.css
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,12 @@ Styleguide Buttons - Truly Lime
a.button.lime {
color: lime;
}

/*
A button truly lime in color
Seen in styleguide 10.2
*/
a.button.tricksy {
background: sparkles;
}
2 changes: 1 addition & 1 deletion test/parser_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def setup
end

test "public sections returns hash of sections" do
assert_equal 4, @css_parsed.sections.count
assert_equal 5, @css_parsed.sections.count
end

test "parse multiple paths" do
Expand Down

0 comments on commit 589a9cd

Please sign in to comment.