This repository was archived by the owner on Nov 1, 2017. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +30
-5
lines changed
Expand file tree Collapse file tree 5 files changed +30
-5
lines changed Original file line number Diff line number Diff line change @@ -105,7 +105,8 @@ complete = "[x]"
105105escapePattern = (str ) ->
106106 str.
107107 replace (/ ([\[\] ] )/ g , " \\ $1" ). # escape square brackets
108- replace (/ \s / , " \\ s" ) # match all white space
108+ replace (/ \s / , " \\ s" ). # match all white space
109+ replace (" x" , " [xX]" ) # match all cases
109110
110111incompletePattern = ///
111112 #{ escapePattern (incomplete)}
Original file line number Diff line number Diff 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
3232end
Original file line number Diff line number Diff 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.
Original file line number Diff line number Diff line change 7474 < input type ="checkbox " class ="task-list-item-checkbox " disabled />
7575 I'm a task list item
7676 </ li >
77+ < li class ="task-list-item ">
78+ < input type ="checkbox " class ="task-list-item-checkbox " disabled />
79+ with non-breaking space
80+ </ li >
81+ < li class ="task-list-item ">
82+ < input type ="checkbox " class ="task-list-item-checkbox " disabled checked />
83+ completed, lower
84+ </ li >
85+ < li class ="task-list-item ">
86+ < input type ="checkbox " class ="task-list-item-checkbox " disabled checked />
87+ completed capitalized
88+ </ li >
7789 </ ul >
7890 </ div >
7991 < form action ="/update " method ="POST " data-remote data-type ="json ">
80- < textarea name ="comment[body] " class ="js-task-list-field "> - [ ] I'm a task list item</ textarea >
92+ < textarea name ="comment[body] " class ="js-task-list-field " cols ="40 " rows ="10 ">
93+ - [ ] I'm a task list item
94+ - [ ] with non-breaking space
95+ - [x] completed, lower
96+ - [X] completed capitalized</ textarea >
8197 </ form >
8298 </ div >
8399
Original file line number Diff line number Diff 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 )
You can’t perform that action at this time.
0 commit comments