martile 0.1.14 → 0.1.15
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 +3 -3
- data/lib/martile.rb +29 -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: c385709f2357966e81fa9abbb82e21fc94b259d3
|
4
|
+
data.tar.gz: 5717ab324dc3a1897b23eb156f3f61bdd220cf65
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f89e37f145e4507d3c448726dee2435dabc8041ceb2bc9fcfa239562eb0ee83e5e25b4e3c6f6b9c8177098a9c326d1d4c7ddf1a6f860f072cd507a9beb1c0016
|
7
|
+
data.tar.gz: 7ab89467da5e94e8283bb9031237927104e019359de913abe8546c6cbd991ff35376ec9d2612b45f967a12c4790d2c3e0770a92b6c121daaeaca0dbd14694547
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
�
|
1
|
+
a�[��o��e
|
2
|
+
�D�r
|
3
|
+
m��)5Ij @�CC�
|
data/lib/martile.rb
CHANGED
@@ -7,6 +7,8 @@ require 'rexle'
|
|
7
7
|
require 'dynarex'
|
8
8
|
require 'rdiscount'
|
9
9
|
|
10
|
+
|
11
|
+
# feature: 12-Aug-2013: unordered_list supported
|
10
12
|
# feature: 31-Mar-2013: markdown inside a martile ordered list
|
11
13
|
# is now converted to HTML
|
12
14
|
# bug fix: 02-Nov-2012: within dynarex_to_table URLs containing a
|
@@ -23,10 +25,16 @@ class Martile
|
|
23
25
|
|
24
26
|
def initialize(s)
|
25
27
|
s2 = code_block_to_html(s)
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
28
|
+
|
29
|
+
s3 = ordered_list_to_html(s2)
|
30
|
+
|
31
|
+
s4 = unordered_list_to_html(s3)
|
32
|
+
|
33
|
+
s5 = dynarex_to_table(s4)
|
34
|
+
|
35
|
+
s6 = table_to_html(s5)
|
36
|
+
|
37
|
+
@to_html = s6
|
30
38
|
end
|
31
39
|
|
32
40
|
private
|
@@ -70,17 +78,20 @@ class Martile
|
|
70
78
|
end
|
71
79
|
end
|
72
80
|
|
73
|
-
def
|
81
|
+
def list_to_html(s,symbol='#')
|
82
|
+
|
83
|
+
return s unless s[/\[#{symbol}[^\]]+\]/]
|
84
|
+
tag = {'#' => 'ol', '\*' => 'ul'}[symbol]
|
74
85
|
|
75
|
-
s.split(/(?=\[
|
86
|
+
s.split(/(?=\[#{symbol}|^#{symbol*2})/).map do |x|
|
76
87
|
|
77
|
-
s2, remainder = [x[/\[
|
88
|
+
s2, remainder = [x[/\[#{symbol}.*#{symbol}[^\]]+\]/m], ($').to_s] if x.strip.length > 0
|
78
89
|
|
79
90
|
if s2 then
|
80
91
|
|
81
|
-
raw_list = s2[1..-2].split(
|
82
|
-
list = "
|
83
|
-
|
92
|
+
raw_list = s2[1..-2].split(/^#{symbol}/).reject(&:empty?).map(&:strip)
|
93
|
+
list = "<#{tag}>%s</#{tag}>" % raw_list.map {|x| \
|
94
|
+
"<li>%s</li>" % RDiscount.new(x).to_html[/<p>(.*)<\/p>/,1]}.join
|
84
95
|
list + remainder.to_s
|
85
96
|
|
86
97
|
else
|
@@ -91,7 +102,15 @@ class Martile
|
|
91
102
|
|
92
103
|
end.join
|
93
104
|
|
105
|
+
end
|
106
|
+
|
107
|
+
def ordered_list_to_html(s)
|
108
|
+
list_to_html s, '#'
|
94
109
|
end
|
110
|
+
|
111
|
+
def unordered_list_to_html(s)
|
112
|
+
list_to_html s, '\*'
|
113
|
+
end
|
95
114
|
|
96
115
|
def table_to_html(s)
|
97
116
|
# create any tables
|
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|