martile 0.6.2 → 0.6.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cae919ad3738c5633faebe00988f330261e6aa76
4
- data.tar.gz: e92aebae9a0c888783ba9b4c26579eb982c8bc45
3
+ metadata.gz: e1180f8084a2a565f0413e5559ba1b49edac1616
4
+ data.tar.gz: 832e0107f0e7964b8d6f1b49724ef37499d513be
5
5
  SHA512:
6
- metadata.gz: bd0f4fe7c0f0294104416f1324d36717601e755d240979053521eeefa4ec692726ddf6412491e0b6f5fbf422972097acfbe0879b4207521650c096da72b06899
7
- data.tar.gz: 4ee690646238b127e46ad72d91222d14c93c17be7ac295643eefa70b0ea8bec3f5aba8a58b792f3e877b95212311fb9a70c0b473bcbd816b5cc7cae0c8aeba04
6
+ metadata.gz: 5f1f55791cec859496fdda8c4c1e203a16fd20cdcdbf9b94b7ab559ffb9aea7d376c2ad1c757d33ec17896ef90915eedad6b906fd1b93196788b049a9ff4dee6
7
+ data.tar.gz: be29e0b4d49468f782eea9ce318bb5ccc2552d208d7391d8765ac23fa33cc220b9a09ab11001b87cc464c9b499d53f8f71d7912806f645b4737c9529c55b4121
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/lib/martile.rb CHANGED
@@ -8,6 +8,8 @@ require 'dynarex'
8
8
  require 'rdiscount'
9
9
 
10
10
 
11
+ # feature: 06-Jul-2015 dynarex_to_table(): A URL within a
12
+ # col is now hyperlinked
11
13
  # feature: 02-Jul-2015 Apply_filter() now filters out pre and code tags
12
14
  # The shorthand !i[]() can now render an iframe tag
13
15
  # e.g. !i[](http://somefile.url/sometext.txt)
@@ -213,7 +215,32 @@ class Martile
213
215
  dx = Dynarex.new($1)
214
216
  keys = dx.to_h.map(&:keys).first
215
217
 
216
- vals = dx.to_h.map(&:values)
218
+ raw_vals = dx.to_h.map(&:values)
219
+
220
+ # create Markdown hyperlinks for any URLs
221
+
222
+ vals = raw_vals.map do |row|
223
+
224
+ row.map do |col|
225
+
226
+ found_match = col.match(/https?:\/\/([^\/]+)(.*)/)
227
+
228
+ r = if found_match then
229
+
230
+ domain, path = found_match.captures
231
+
232
+ a = domain.split('.')
233
+ a.shift if a.length > 2
234
+ url_title = (a.join + path)[0..39] + '...'
235
+
236
+ "[%s](%s)" % [url_title, col]
237
+ else
238
+ col
239
+ end
240
+
241
+ r
242
+ end
243
+ end
217
244
 
218
245
  widths = ([keys] + vals).transpose.map{|x| x.max_by(&:length).length}
219
246
  th = '|' + keys.join('|') + "|\n"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: martile
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -31,7 +31,7 @@ cert_chain:
31
31
  fnr5l+RI/6f8lfxBNgDrktGB/RwPkOyWtyKk1tu9CWgHmptxL0JglikCXg5MzuZI
32
32
  tZzXOvXUoUf1VQ==
33
33
  -----END CERTIFICATE-----
34
- date: 2015-07-02 00:00:00.000000000 Z
34
+ date: 2015-07-06 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rdiscount
metadata.gz.sig CHANGED
Binary file