deckar01-task_list 2.3.3 → 3.0.alpha2

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
  SHA256:
3
- metadata.gz: 25b1e9330f205a0fdcd27bffcd57709c3b13d45d6554075dc66472d71230421a
4
- data.tar.gz: 575a135f17373ec21748d76cd96cd7143a2846aae8667b8fba7a0d2c10a4312f
3
+ metadata.gz: ad259725c7de35c5b6bb6c88a6f175c3c53becfebebc2681d7fc3f816cd0b498
4
+ data.tar.gz: 59bbc4372a0a24e95123585ad2df1b1b9551f89be82486a72bcac36321522121
5
5
  SHA512:
6
- metadata.gz: 6bef865f56600783b7c5da763891fec1fdd2de59152af2f698c481ff936859f60d7a5b5ce3756a90021d82dea1e50894f362701384606c8e4a9ef8ebbd62e739
7
- data.tar.gz: 72cc545b970a28c4fe2b03b2fe271c9ad7304b5a3880305a8aed1f458e7cd67141c73e7f7d3829044bfd6d128cb61c9350b451ccc9af817dec7284e657bb98b1
6
+ metadata.gz: 2773a96edaf7569423101c52f7b310265e206b1c2ad71aff139cfa810d1bda9313ed4434b0fdd6b7963e555b7321c0fd8dd06f78af551f297a71404657abd28c
7
+ data.tar.gz: 66ed087ad4add8a9bdc24951ce8c55bbbe4562b936f409c7499133276a7df474a6af100d58865ee2f9f4b16292f6f7ddd15b2048f18666b99202908eaadcab08
@@ -50,22 +50,6 @@ class TaskList
50
50
  (?=\s) # followed by whitespace
51
51
  /x
52
52
 
53
- ListItemSelector = ".//li[task_list_item(.)]".freeze
54
-
55
- class XPathSelectorFunction
56
- def self.task_list_item(nodes)
57
- nodes.select { |li| Filter::item_container(li).inner_html =~ ItemPattern }
58
- end
59
- end
60
-
61
- # Selects first P tag of an LI, if present
62
- ItemParaSelector = "./p[1]".freeze
63
-
64
- # The the node directly containing the checkbox text
65
- def self.item_container(li)
66
- li.xpath(ItemParaSelector)[0] || li
67
- end
68
-
69
53
  # List of `TaskList::Item` objects that were recognized in the document.
70
54
  # This is available in the result hash as `:task_list_items`.
71
55
  #
@@ -85,7 +69,6 @@ class TaskList
85
69
  />)
86
70
  end
87
71
 
88
- # Deprecated: Removed in v3
89
72
  # Public: Marks up the task list item checkbox with metadata and behavior.
90
73
  #
91
74
  # NOTE: produces a string that, when assigned to a Node's `inner_html`,
@@ -101,16 +84,6 @@ class TaskList
101
84
  item.source.sub(ItemPattern, render_item_checkbox(item)), 'utf-8'
102
85
  end
103
86
 
104
- # Deprecated: Removed in v3
105
- # Public: Select all task list items within `container`.
106
- #
107
- # Returns an Array of Nokogiri::XML::Element objects for ordered and
108
- # unordered lists. The container can either be the entire document (as
109
- # returned by `#doc`) or an Element object.
110
- def list_items(container)
111
- container.xpath(ListItemSelector, XPathSelectorFunction)
112
- end
113
-
114
87
  # Filters the source for task list items.
115
88
  #
116
89
  # Each item is wrapped in HTML to identify, style, and layer
@@ -120,16 +93,15 @@ class TaskList
120
93
  #
121
94
  # Returns nothing.
122
95
  def filter!
123
- list_items(doc).reverse.each do |li|
124
- outer = self.class.item_container(li)
125
- inner = outer.inner_html
126
- checkbox = inner.match(ItemPattern).captures[0]
127
- item = TaskList::Item.new(checkbox, inner)
128
- # prepend because we're iterating in reverse
96
+ doc.xpath(".//li").reverse.each do |li|
97
+ container = li.xpath("./p[1]")[0] || li
98
+ next if not container.inner_html =~ ItemPattern
99
+
100
+ item = TaskList::Item.new($1, container.inner_html)
129
101
  task_list_items.unshift item
102
+ container.inner_html = render_task_list_item(item)
130
103
  li.parent.add_class('task-list')
131
104
  li.add_class('task-list-item')
132
- outer.inner_html = render_task_list_item(item)
133
105
  end
134
106
  end
135
107
 
@@ -137,15 +109,5 @@ class TaskList
137
109
  filter!
138
110
  doc
139
111
  end
140
-
141
- # Deprecated: Removed in v3
142
- # Private: adds a CSS class name to a node, respecting existing class
143
- # names.
144
- def add_css_class(node, *new_class_names)
145
- class_names = (node['class'] || '').split(' ')
146
- return if new_class_names.all? { |klass| class_names.include?(klass) }
147
- class_names.concat(new_class_names)
148
- node['class'] = class_names.uniq.join(' ')
149
- end
150
112
  end
151
113
  end
@@ -1,3 +1,3 @@
1
1
  class TaskList
2
- VERSION = [2, 3, 3].join('.')
2
+ VERSION = [3, 0, 'alpha2'].join('.')
3
3
  end
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: 2.3.3
4
+ version: 3.0.alpha2
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: 2023-09-08 00:00:00.000000000 Z
12
+ date: 2023-09-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: html-pipeline
@@ -180,9 +180,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
180
180
  version: 2.0.0
181
181
  required_rubygems_version: !ruby/object:Gem::Requirement
182
182
  requirements:
183
- - - ">="
183
+ - - ">"
184
184
  - !ruby/object:Gem::Version
185
- version: '0'
185
+ version: 1.3.1
186
186
  requirements: []
187
187
  rubygems_version: 3.4.18
188
188
  signing_key: