Class: ConsoleRenderer

Inherits:
Redcarpet::Render::Base
  • Object
show all
Defined in:
lib/console_renderer.rb

Constant Summary collapse

@@listitemid =
0

Instance Method Summary collapse

Instance Method Details


67
68
69
# File 'lib/console_renderer.rb', line 67

def autolink(link, link_type)
  Rainbow(link).color(:cyan)
end

#block_code(code, language) ⇒ Object


7
8
9
# File 'lib/console_renderer.rb', line 7

def block_code(code, language)
  "\n" + code + "\n"
end

#block_html(raw_html) ⇒ Object


19
20
21
# File 'lib/console_renderer.rb', line 19

def block_html(raw_html)
  raw_html
end

#block_quote(quote) ⇒ Object


11
12
13
14
15
16
17
# File 'lib/console_renderer.rb', line 11

def block_quote(quote)
  ret = "\n"
  quote.split("\n").each do |line|
    ret += Rainbow("|").color(:cyan) + line + "\n"
  end
  ret + "\n"
end

#codespan(code) ⇒ Object


71
72
73
# File 'lib/console_renderer.rb', line 71

def codespan(code)
  code
end

#double_emphasis(text) ⇒ Object


75
76
77
# File 'lib/console_renderer.rb', line 75

def double_emphasis(text)
  Rainbow(text).bright
end

#emphasis(text) ⇒ Object


79
80
81
# File 'lib/console_renderer.rb', line 79

def emphasis(text)
  Rainbow(text).underline
end

#header(text, header_level) ⇒ Object


23
24
25
26
27
28
29
30
# File 'lib/console_renderer.rb', line 23

def header(text, header_level)
  text = "\n" + text + "\n"
  if header_level == 1
    Rainbow(text).bright.underline
  else
    Rainbow(text).underline
  end
end

#hruleObject


32
33
34
# File 'lib/console_renderer.rb', line 32

def hrule()
  Rainbow("___________________________\n").color(:yellow)
end

#image(link, title, alt_text) ⇒ Object


83
84
85
# File 'lib/console_renderer.rb', line 83

def image(link, title, alt_text)
  Rainbow("<" + (alt_text || "") + ">").color(:green) + Rainbow("(image at: " + (link || "") + ")").color(:cyan)
end

#linebreakObject


87
88
89
# File 'lib/console_renderer.rb', line 87

def linebreak()
  "\n\n"
end

91
92
93
# File 'lib/console_renderer.rb', line 91

def link(link, title, content)
  (content || "") + " " + Rainbow("<#{link}#{title ? " :" + title : ''}>").color(:cyan)
end

#list(contents, list_type) ⇒ Object


36
37
38
39
# File 'lib/console_renderer.rb', line 36

def list(contents, list_type)
  @@listitemid = 0
  contents
end

#list_item(text, list_type) ⇒ Object


41
42
43
44
45
46
47
48
49
# File 'lib/console_renderer.rb', line 41

def list_item(text, list_type)
  case list_type
  when :unordered
    "    " + Rainbow("-").color(:cyan) + " " + text
  when :ordered
    @@listitemid += 1
    "    " + Rainbow(@@listitemid.to_s + ".").color(:cyan) + " " + text
  end
end

#paragraph(text) ⇒ Object


51
52
53
# File 'lib/console_renderer.rb', line 51

def paragraph(text)
  text + "\n"
end

#raw_html(raw_html) ⇒ Object


95
96
97
# File 'lib/console_renderer.rb', line 95

def raw_html(raw_html)
  raw_html
end

#strikethrough(text) ⇒ Object


103
104
105
# File 'lib/console_renderer.rb', line 103

def strikethrough(text)
  text
end

#superscript(text) ⇒ Object


107
108
109
# File 'lib/console_renderer.rb', line 107

def superscript(text)
  Rainbow("^" + text).color(:red)
end

#table(header, body) ⇒ Object


55
56
57
# File 'lib/console_renderer.rb', line 55

def table(header, body)
  body
end

#table_cell(content, alignment) ⇒ Object


63
64
65
# File 'lib/console_renderer.rb', line 63

def table_cell(content, alignment)
  content
end

#table_row(content) ⇒ Object


59
60
61
# File 'lib/console_renderer.rb', line 59

def table_row(content)
  content
end

#triple_emphasis(text) ⇒ Object


99
100
101
# File 'lib/console_renderer.rb', line 99

def triple_emphasis(text)
  Rainbow(text).bright.underline
end