martile 0.6.5 → 0.6.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/martile.rb +25 -10
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c63c50dfb33d820a5e691a8c4c891a0b08f2d9e2
|
4
|
+
data.tar.gz: e6e6fc61f78cc63352ecbb34c017694323c6b8c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 93d2b0e234640fc100eaff52bc194ba6f0129a314d90e1744fc1bbbe46db792a91afd57c86430592a670dd1948a7af007d3515daabbd7dcc4df519c7cd0f8dd7
|
7
|
+
data.tar.gz: de26b7b0f4b764be08bab71fdbb7410e43cd00ec9d1ec6e34eb6f016e8c803a1e8d179535fac24abc1ce16ad678852961c2f42151001df8361d20402856a91c5
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/martile.rb
CHANGED
@@ -8,8 +8,9 @@ require 'dynarex'
|
|
8
8
|
require 'rdiscount'
|
9
9
|
|
10
10
|
|
11
|
-
# feature: 06-Jul-2015 dynarex_to_table():
|
12
|
-
# col is now hyperlinked
|
11
|
+
# feature: 06-Jul-2015 dynarex_to_table():
|
12
|
+
# 1. A URL within a col is now hyperlinked
|
13
|
+
# 2. Select fields can now be displayd
|
13
14
|
# feature: 02-Jul-2015 Apply_filter() now filters out pre and code tags
|
14
15
|
# The shorthand !i[]() can now render an iframe tag
|
15
16
|
# e.g. !i[](http://somefile.url/sometext.txt)
|
@@ -198,24 +199,36 @@ class Martile
|
|
198
199
|
|
199
200
|
def dynarex_to_table(s)
|
200
201
|
|
201
|
-
s.gsub(/-\[((https?:\/\/)?[\w\/\.\-]+)\]
|
202
|
-
|
202
|
+
s.gsub(/-\[((https?:\/\/)?[\w\/\.\-]+)\](\{[^\}]+\})?/) do |match|
|
203
|
+
|
204
|
+
source = ($1)
|
205
|
+
raw_select = ($3)
|
206
|
+
|
207
|
+
if raw_select then
|
208
|
+
raw_fields = raw_select[/select:\s*["']([^"']+)/,1]
|
209
|
+
fields = raw_fields.split(/\s*,\s*/)
|
210
|
+
end
|
211
|
+
|
203
212
|
print_row = -> (row, widths) do
|
204
|
-
'| ' + row.map
|
213
|
+
'| ' + row.map\
|
214
|
+
.with_index {|y,i| y.to_s.ljust(widths[i])}.join(' | ') + " |\n"
|
205
215
|
end
|
206
216
|
|
207
217
|
print_thline = -> (row, widths) do
|
208
|
-
'|:' + row.map
|
218
|
+
'|:' + row.map\
|
219
|
+
.with_index {|y,i| y.to_s.ljust(widths[i])}.join('|:') + "|\n"
|
209
220
|
end
|
210
221
|
|
211
222
|
print_rows = -> (rows, widths) do
|
212
223
|
rows.map {|x| print_row.call(x,widths)}.join
|
213
224
|
end
|
214
225
|
|
215
|
-
dx = Dynarex.new(
|
216
|
-
keys = dx.to_h.map(&:keys).first
|
226
|
+
dx = Dynarex.new(source)
|
217
227
|
|
218
|
-
|
228
|
+
flat_records = raw_select ? dx.to_a(select: fields) : dx.to_a
|
229
|
+
|
230
|
+
keys = flat_records.map(&:keys).first
|
231
|
+
raw_vals = flat_records.map(&:values)
|
219
232
|
|
220
233
|
# create Markdown hyperlinks for any URLs
|
221
234
|
|
@@ -276,7 +289,9 @@ class Martile
|
|
276
289
|
|
277
290
|
s.split(/(?=\[#{symbol}|^#{symbol*2})/).map do |x|
|
278
291
|
|
279
|
-
|
292
|
+
if x.strip.length > 0 then
|
293
|
+
s2, remainder = [x[/\[#{symbol}.*#{symbol}[^\]]+\]/m], ($').to_s]
|
294
|
+
end
|
280
295
|
|
281
296
|
if s2 then
|
282
297
|
|
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|