class Redcarpet::Render::ColorDown
Constants
- BINK
- BLUE_BG
- BOLD
- COLOR_OFF
- CYAN
- DIM
- GRAY_BG
- GREEN
- L_GRAY
- ORANGE
- RED
- ROSE
- RUBY_LANG
- UNDERSCORE
- UNORDERED
- WHITE
- YELLOW
Public Instance Methods
block_code(text, lang="")
click to toggle source
Other methods where the text content is in another argument
def link(link, title, content) content end
# File lib/tty_markdown.rb, line 56 def block_code(text, lang="") lang ||= lang.to_s result = "```#{lang}\n" if lang.match RUBY_LANG result << ColorCode::Ruby.new(text).colorize else result << ColorCode::Unknown.new(text).colorize end result << "```\n" result end
block_quote(text)
click to toggle source
# File lib/tty_markdown.rb, line 102 def block_quote(text) [ ROSE, "> ", text.strip, COLOR_OFF, "\n" ].inject("") { |memo, v| memo << v.to_s } end
codespan(text)
click to toggle source
# File lib/tty_markdown.rb, line 68 def codespan(text) GRAY_BG + "`#{text}`" + COLOR_OFF end
emphasis(text)
click to toggle source
# File lib/tty_markdown.rb, line 72 def emphasis(text) [ BOLD, '*', text, '*', COLOR_OFF ].inject("") { |memo, v| memo << v.to_s } end
header(text, header_level)
click to toggle source
# File lib/tty_markdown.rb, line 77 def header(text, header_level) heads = "".tap {|h| header_level.times {h << "#"} } heads << " " op = [ BLUE_BG, "\n", heads, text, COLOR_OFF, "\n" ].inject("") { |memo, v| memo << v.to_s } end
hrule()
click to toggle source
# File lib/tty_markdown.rb, line 107 def hrule "\n----" end
list(text, type)
click to toggle source
# File lib/tty_markdown.rb, line 84 def list(text, type) text.lines.inject("") do |memo, line| memo << " " + line end + "\n" end
list_item(text, type)
click to toggle source
# File lib/tty_markdown.rb, line 90 def list_item(text, type) if type.match UNORDERED "#{ORANGE}- #{COLOR_OFF}" + text else text end end
paragraph(text)
click to toggle source
# File lib/tty_markdown.rb, line 98 def paragraph(text) "\n" + text + "\n" end