deckar01-task_list 1.0.5 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fa88b4fa286bd28b155409f3fec9e902eb979f3b
4
- data.tar.gz: 752b3e624982c591d2acbb476eb131ac914363dd
3
+ metadata.gz: fdfcf76a91d8eaab8ec42ad11c61cadf5563cd6b
4
+ data.tar.gz: 71f6596cbe4bd8edfd4362c693ae8f54f257c647
5
5
  SHA512:
6
- metadata.gz: f464c95ab4f96fefd9001631ac7a49b79f554242875fb7642f9bf5692826e8504043ef32267c9e96dde3bb6f1e86c3e6324f887fb3992f8b75b476c186dc71e8
7
- data.tar.gz: 3699906243780c404a938b1d0672d938d52b7db44027b32ca9625a224b794d512c32de9829060819c32897ade56cb73a404693958fca1f02934a33fa52685832
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 'deckar01-task_list/filter'
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 'deckar01-task_list/railtie'
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 'deckar01-task_list/railtie'
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 filter out code fences from the source for comparison only.
139
- # http://rubular.com/r/x5EwZVrloI
140
- # Modified slightly due to issues with JS
141
- codeFencesPattern = ///
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(codeFencesPattern, '').
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 line in clean && line.match(itemPattern)
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deckar01-task_list",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "Markdown TaskList components",
5
5
  "homepage": "https://github.com/deckar01/task_list",
6
6
  "dependencies": {
@@ -1,3 +1,3 @@
1
1
  class TaskList
2
- VERSION = [1, 0, 5].join('.')
2
+ VERSION = [1, 0, 6].join('.')
3
3
  end
@@ -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.5
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-09-30 00:00:00.000000000 Z
12
+ date: 2016-10-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack