md_edit 0.2.2 → 0.2.3

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: 4c9699e0321fd92c07f4720867075d0ac6585503
4
- data.tar.gz: 7cc2d79abe6b63a7282698b08d7b35c30a9d4016
3
+ metadata.gz: b16174851175e57f2cad74f86b616f1d9e24b9fd
4
+ data.tar.gz: 72a5ede7446a92694b3dce34f451c49e0a22a5c1
5
5
  SHA512:
6
- metadata.gz: 85037ea96652ceccbe258c5cd796608dc3a0b1d324dd7f5a0b1f61e019dec4939a06b0097c1b43f72e3103be698b3257f88b4bb0beb8507fd6ca2e1ffb7505cd
7
- data.tar.gz: e36b02b4ec92e71792018aa5701bb4bd6c8571ec8ecae674a832efd4d7da996b6bae0e07760688cde90e94cf484f4a38f67c343fb6a9d960a47c31d83794cf5f
6
+ metadata.gz: dda881164fa4a421bb7dce5c545d1d8e6b4e7de60f14461dcf21c3612946d82c0f2ca96e0f4b8fadee35bbc122802a821e630ce21a8ca8259e337b1dfe4a43ce
7
+ data.tar.gz: 273f5d1d93cf1fad2d1ad4bc663691f4dcb1d335f087d767a1fd804075ae66ed884aa668c88cc87f11202b66c7eab3ab47fbf690d7f8e65ccebbb00172ca67f3
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/md_edit.rb CHANGED
@@ -160,20 +160,38 @@ class MdEdit
160
160
  end
161
161
 
162
162
  if a2 then
163
+
164
+ h = a2.values.flatten(1).group_by {|x| x[/\[[^\]]+\]/]}
165
+
163
166
 
164
- phrases_found = a2.values.flatten(1).map do |x|
165
-
166
- raw_heading, phrase = x.split(/\]\s+/,2)
167
+ phrases_found = h.to_a.flat_map do |raw_heading,v|
168
+
169
+
170
+ # get rid of results which are almost duplicate (contain a
171
+ # subset of text from the 1st result)
172
+
173
+ phrases = v.map {|x| x[/\] +(.*)/,1]}
174
+ filtered_phrases = phrases[1..-1].reject {|x| phrases[0].include? x }
175
+
176
+ filtered_phrases.unshift(phrases[0])
177
+
178
+ # get rid of the top level heading from the heading trailing
167
179
 
168
- if raw_heading =~ / > / then
169
- heading = raw_heading[/(?<=\[)[^\]]+/].split(' > ')[1..-1].join(' > ')
170
- "[%s] %s" % [heading, phrase]
180
+ heading = if raw_heading =~ / > / then
181
+
182
+ raw_heading[1..-2].split(' > ')[1..-1]\
183
+ .join(' > ')
171
184
  else
172
- x
173
- end
185
+ raw_heading[1..-2]
186
+ end
174
187
 
188
+ filtered_phrases.map {|phrase| "[%s] %s" % [heading, phrase] }
189
+
175
190
  end
191
+
192
+
176
193
  results.concat phrases_found if phrases_found
194
+
177
195
  end
178
196
 
179
197
  results.take limit
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: md_edit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
metadata.gz.sig CHANGED
Binary file