martile 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/martile.rb +4 -5
- metadata +1 -1
data/lib/martile.rb
CHANGED
@@ -11,7 +11,7 @@ class Martile
|
|
11
11
|
|
12
12
|
def initialize(s)
|
13
13
|
s2 = code_block_to_html(s)
|
14
|
-
s3 =
|
14
|
+
s3 = ordered_list_to_html(s2)
|
15
15
|
s4 = table_to_html(s3)
|
16
16
|
@to_html = s4
|
17
17
|
end
|
@@ -21,11 +21,11 @@ class Martile
|
|
21
21
|
def code_block_to_html(s)
|
22
22
|
|
23
23
|
s.split(/(?=\n\n\s{4})/).map do |x|
|
24
|
-
raw_code_block = x[
|
24
|
+
raw_code_block = x[/.*\s{4}[^\n]+/m]
|
25
25
|
|
26
26
|
if raw_code_block then
|
27
27
|
code_block = "<pre><code>%s</code></pre>" % \
|
28
|
-
raw_code_block.lines.map
|
28
|
+
raw_code_block.lines.map{|x| x[4..-1]}[1..-1].join
|
29
29
|
code_block + ($').to_s
|
30
30
|
else
|
31
31
|
x
|
@@ -34,7 +34,7 @@ class Martile
|
|
34
34
|
|
35
35
|
end
|
36
36
|
|
37
|
-
def
|
37
|
+
def ordered_list_to_html(s)
|
38
38
|
|
39
39
|
s.split(/(?=\[#)/).map do |x|
|
40
40
|
s2, remainder = [x[/\[#.*#[^\]]+\]/m], ($').to_s] if x.strip.length > 0
|
@@ -42,7 +42,6 @@ class Martile
|
|
42
42
|
|
43
43
|
raw_list = s2[1..-2].split(/^#/).reject(&:empty?).map(&:strip)
|
44
44
|
list = "<ol>%s</ol>" % raw_list.map {|x| "<li>%s</li>" % x}.join
|
45
|
-
|
46
45
|
list + remainder.to_s
|
47
46
|
else
|
48
47
|
x
|