Skip to content
This repository was archived by the owner on Nov 1, 2017. It is now read-only.

Commit e46e645

Browse files
committed
Match lower or upper case X for completion, test
1 parent 480efc2 commit e46e645

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

lib/task_list.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ def summary
2424
end
2525

2626
class Item < Struct.new(:checkbox_text, :source)
27-
Complete = "[x]".freeze # see TaskListFilter
27+
Complete = /\[[xX]\]/.freeze # see TaskList::Filter
2828
def complete?
29-
checkbox_text == Complete
29+
checkbox_text =~ Complete
3030
end
3131
end
3232
end

lib/task_list/filter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class Filter < HTML::Pipeline::Filter
3535
Complete = "[x]".freeze
3636

3737
IncompletePattern = /\[[[:space:]]\]/.freeze # matches all whitespace
38-
CompletePattern = Regexp.escape(Complete).freeze
38+
CompletePattern = /\[[xX]\]/.freeze # matches any capitalization
3939

4040
# Pattern used to identify all task list items.
4141
# Useful when you need iterate over all items.

test/task_list/filter_test.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,14 @@ def test_non_breaking_space_between_brackets_in_paras
125125
assert_equal 3, filter(text)[:output].css(@item_selector).size
126126
end
127127

128+
def test_capital_X
129+
text = <<-md
130+
- [x] lower case
131+
- [X] capital
132+
md
133+
assert_equal 2, filter(text)[:output].css("[checked]").size
134+
end
135+
128136
protected
129137

130138
def filter(input, context = @context, result = nil)

0 commit comments

Comments
 (0)