tty_markdown 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/tty_markdown.rb +7 -6
- metadata +1 -1
data/lib/tty_markdown.rb
CHANGED
@@ -52,8 +52,9 @@ module Redcarpet
|
|
52
52
|
#def link(link, title, content)
|
53
53
|
#content
|
54
54
|
#end
|
55
|
-
|
56
|
-
def block_code(text, lang)
|
55
|
+
|
56
|
+
def block_code(text, lang="")
|
57
|
+
lang ||= lang.to_s
|
57
58
|
result = "```#{lang}\n"
|
58
59
|
if lang.match RUBY_LANG
|
59
60
|
result << ColorCode::Ruby.new(text).colorize
|
@@ -69,14 +70,14 @@ module Redcarpet
|
|
69
70
|
end
|
70
71
|
|
71
72
|
def emphasis(text)
|
72
|
-
[ BOLD, '*', text,
|
73
|
+
[ BOLD, '*', text,
|
73
74
|
'*', COLOR_OFF ].inject("") { |memo, v| memo << v.to_s }
|
74
75
|
end
|
75
76
|
|
76
77
|
def header(text, header_level)
|
77
78
|
heads = "".tap {|h| header_level.times {h << "#"} }
|
78
79
|
heads << " "
|
79
|
-
op = [ BLUE_BG, "\n", heads, text,
|
80
|
+
op = [ BLUE_BG, "\n", heads, text,
|
80
81
|
COLOR_OFF, "\n" ].inject("") { |memo, v| memo << v.to_s }
|
81
82
|
end
|
82
83
|
|
@@ -85,7 +86,7 @@ module Redcarpet
|
|
85
86
|
memo << " " + line
|
86
87
|
end + "\n"
|
87
88
|
end
|
88
|
-
|
89
|
+
|
89
90
|
def list_item(text, type)
|
90
91
|
if type.match UNORDERED
|
91
92
|
"#{ORANGE}- #{COLOR_OFF}" + text
|
@@ -99,7 +100,7 @@ module Redcarpet
|
|
99
100
|
end
|
100
101
|
|
101
102
|
def block_quote(text)
|
102
|
-
[ ROSE, "> ", text.strip,
|
103
|
+
[ ROSE, "> ", text.strip,
|
103
104
|
COLOR_OFF, "\n" ].inject("") { |memo, v| memo << v.to_s }
|
104
105
|
end
|
105
106
|
|