deckar01-task_list 1.0.5 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/app/assets/javascripts/task_list.coffee +15 -14
- data/bower.json +1 -1
- data/lib/task_list/version.rb +1 -1
- data/test/unit/test_updates.coffee +67 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fdfcf76a91d8eaab8ec42ad11c61cadf5563cd6b
|
4
|
+
data.tar.gz: 71f6596cbe4bd8edfd4362c693ae8f54f257c647
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf328e7bc0d70b33a7124b15f4c0847b93a2eab368ff673872668b768276aa5b32cc65ff226d439fcbdbeeeb518f708a874447b740d88b709e1145262f458f40
|
7
|
+
data.tar.gz: 41fb013dcdfc812ef969a358ed9e6918595c68c99243f4eabc89d90dc5c0282b5d666c712f4121ed00fd57b03cfc9058758124fa5abe5a0de4b53f7cdfcf7a82
|
data/README.md
CHANGED
@@ -27,7 +27,7 @@ Rendering Task List item checkboxes from source Markdown depends on the `TaskLis
|
|
27
27
|
|
28
28
|
``` ruby
|
29
29
|
require 'html/pipeline'
|
30
|
-
require '
|
30
|
+
require 'task_list/filter'
|
31
31
|
|
32
32
|
pipeline = HTML::Pipeline.new [
|
33
33
|
HTML::Pipeline::MarkdownFilter,
|
@@ -97,7 +97,7 @@ This is the preferred method for including the frontend assets in your applicati
|
|
97
97
|
|
98
98
|
``` ruby
|
99
99
|
# config/application.rb
|
100
|
-
require '
|
100
|
+
require 'task_list/railtie'
|
101
101
|
```
|
102
102
|
|
103
103
|
### Frontend: Rails 2.3 Manual method
|
@@ -107,7 +107,7 @@ Wherever you have your Sprockets setup:
|
|
107
107
|
``` ruby
|
108
108
|
Sprockets::Environment.new(Rails.root) do |env|
|
109
109
|
# Load TaskList assets
|
110
|
-
require '
|
110
|
+
require 'task_list/railtie'
|
111
111
|
TaskList.asset_paths.each do |path|
|
112
112
|
env.append_path path
|
113
113
|
end
|
@@ -135,17 +135,10 @@ itemPattern = ///
|
|
135
135
|
)
|
136
136
|
///
|
137
137
|
|
138
|
-
# Used to
|
139
|
-
# http://rubular.com/r/
|
140
|
-
|
141
|
-
|
142
|
-
^`{3} # ```
|
143
|
-
(?:\s*\w+)? # followed by optional language
|
144
|
-
[\S\s] # whitespace
|
145
|
-
.* # code
|
146
|
-
[\S\s] # whitespace
|
147
|
-
^`{3}$ # ```
|
148
|
-
///mg
|
138
|
+
# Used to skip checkbox markup inside of code fences.
|
139
|
+
# http://rubular.com/r/TfCDNsy8x4
|
140
|
+
startFencesPattern = /^`{3}.*$/
|
141
|
+
endFencesPattern = /^`{3}$/
|
149
142
|
|
150
143
|
# Used to filter out potential mismatches (items not in lists).
|
151
144
|
# http://rubular.com/r/OInl6CiePy
|
@@ -164,11 +157,19 @@ itemsInParasPattern = ///
|
|
164
157
|
#
|
165
158
|
# Returns the updated String text.
|
166
159
|
updateTaskListItem = (source, itemIndex, checked) ->
|
167
|
-
clean = source.replace(/\r/g, '').replace(
|
168
|
-
replace(itemsInParasPattern, '').split("\n")
|
160
|
+
clean = source.replace(/\r/g, '').replace(itemsInParasPattern, '').split("\n")
|
169
161
|
index = 0
|
162
|
+
inCodeBlock = false
|
170
163
|
result = for line in source.split("\n")
|
171
|
-
if
|
164
|
+
if inCodeBlock
|
165
|
+
# Lines inside of a code block are ignored.
|
166
|
+
if line.match(endFencesPattern)
|
167
|
+
# Stop ignoring lines once the code block is closed.
|
168
|
+
inCodeBlock = false
|
169
|
+
else if line.match(startFencesPattern)
|
170
|
+
# Start ignoring lines inside a code block.
|
171
|
+
inCodeBlock = true
|
172
|
+
else if line in clean && line.match(itemPattern)
|
172
173
|
index += 1
|
173
174
|
if index == itemIndex
|
174
175
|
line =
|
data/bower.json
CHANGED
data/lib/task_list/version.rb
CHANGED
@@ -564,3 +564,70 @@ asyncTest "updates items followed by links", ->
|
|
564
564
|
, 20
|
565
565
|
|
566
566
|
item2Checkbox.click()
|
567
|
+
|
568
|
+
# See https://github.com/deckar01/task_list/issues/3
|
569
|
+
asyncTest "doesn't update items inside code blocks", ->
|
570
|
+
expect 3
|
571
|
+
|
572
|
+
container = $ '<div>', class: 'js-task-list-container'
|
573
|
+
|
574
|
+
list = $ '<ul>', class: 'task-list'
|
575
|
+
|
576
|
+
item1 = $ '<li>', class: 'task-list-item'
|
577
|
+
item1Checkbox = $ '<input>',
|
578
|
+
type: 'checkbox'
|
579
|
+
class: 'task-list-item-checkbox'
|
580
|
+
disabled: true
|
581
|
+
checked: false
|
582
|
+
|
583
|
+
item2 = $ '<li>', class: 'task-list-item'
|
584
|
+
item2Checkbox = $ '<input>',
|
585
|
+
type: 'checkbox'
|
586
|
+
class: 'task-list-item-checkbox'
|
587
|
+
disabled: true
|
588
|
+
checked: false
|
589
|
+
|
590
|
+
field = $ '<textarea>', class: 'js-task-list-field', text: """
|
591
|
+
```
|
592
|
+
- [ ] test1
|
593
|
+
- [ ] test2
|
594
|
+
```
|
595
|
+
|
596
|
+
- [ ] test1
|
597
|
+
- [ ] test2
|
598
|
+
"""
|
599
|
+
|
600
|
+
changes = """
|
601
|
+
```
|
602
|
+
- [ ] test1
|
603
|
+
- [ ] test2
|
604
|
+
```
|
605
|
+
|
606
|
+
- [ ] test1
|
607
|
+
- [x] test2
|
608
|
+
"""
|
609
|
+
|
610
|
+
item1.append item1Checkbox
|
611
|
+
list.append item1
|
612
|
+
item1.expectedIndex = 1
|
613
|
+
|
614
|
+
item2.append item2Checkbox
|
615
|
+
list.append item2
|
616
|
+
item2.expectedIndex = 2
|
617
|
+
|
618
|
+
container.append list
|
619
|
+
container.append field
|
620
|
+
|
621
|
+
$('#qunit-fixture').append(container)
|
622
|
+
container.taskList()
|
623
|
+
|
624
|
+
field.on 'tasklist:changed', (event, index, checked) =>
|
625
|
+
ok checked
|
626
|
+
equal index, item2.expectedIndex
|
627
|
+
equal field.val(), changes
|
628
|
+
|
629
|
+
setTimeout ->
|
630
|
+
start()
|
631
|
+
, 20
|
632
|
+
|
633
|
+
item2Checkbox.click()
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: deckar01-task_list
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jared Deckard
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-10-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|