Class: Downterm::Render::Terminal

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

Instance Method Summary collapse

Instance Method Details



49
50
51
# File 'lib/downterm/render.rb', line 49

def autolink(link, link_type)
  Rainbow(link).underline.to_s
end

#block_code(code, language) ⇒ Object



61
62
63
# File 'lib/downterm/render.rb', line 61

def block_code(code, language)
  code.split("\n").map { |line| "    #{line}"}.join("\n")
end

#block_html(raw_html) ⇒ Object



69
70
71
# File 'lib/downterm/render.rb', line 69

def block_html(raw_html)
  raw_html
end

#block_quote(quote) ⇒ Object



65
66
67
# File 'lib/downterm/render.rb', line 65

def block_quote(quote)
  quote.split("\n").map { |line| "> #{line}" }.join("\n")
end

#codespan(code) ⇒ Object



57
58
59
# File 'lib/downterm/render.rb', line 57

def codespan(code)
  "`#{code}`"
end

#double_emphasis(text) ⇒ Object



37
38
39
# File 'lib/downterm/render.rb', line 37

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

#emphasis(text) ⇒ Object



33
34
35
# File 'lib/downterm/render.rb', line 33

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

#entity(text) ⇒ Object



24
25
26
27
28
29
30
31
# File 'lib/downterm/render.rb', line 24

def entity(text)
  case text
  when ">"  then return ">"
  when "&lt;"  then return "<"
  when "&amp;" then return "&"
  else              return text
  end
end

#header(text, header_level) ⇒ Object



20
21
22
# File 'lib/downterm/render.rb', line 20

def header(text, header_level)
  "#{'#' * header_level} #{text}\n\n"
end

#hruleObject



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

def hrule
  '-' * HighLine::SystemExtensions.terminal_size[0] + "\n\n"
end

#image(link, title, content) ⇒ Object



53
54
55
# File 'lib/downterm/render.rb', line 53

def image(link, title, content)
  Rainbow(link).underline.to_s
end

#linebreakObject



16
17
18
# File 'lib/downterm/render.rb', line 16

def linebreak
  "\n"
end


45
46
47
# File 'lib/downterm/render.rb', line 45

def link(link, link_title, content)
  "#{Rainbow(content).underline} <#{link}>"
end

#list(contents, list_type) ⇒ Object



89
90
91
92
93
94
# File 'lib/downterm/render.rb', line 89

def list(contents, list_type)
  case list_type
  when :unordered then return contents
  when :ordered   then return number_list(contents.split("\n")).join("\n")
  end
end

#list_item(text, list_type) ⇒ Object



96
97
98
99
100
101
# File 'lib/downterm/render.rb', line 96

def list_item(text, list_type)
  case list_type
  when :unordered then return "* #{text}"
  when :ordered   then return "#{text}"
  end
end

#normal_text(text) ⇒ Object



12
13
14
# File 'lib/downterm/render.rb', line 12

def normal_text(text)
  text
end

#paragraph(text) ⇒ Object



8
9
10
# File 'lib/downterm/render.rb', line 8

def paragraph(text)
  "#{text}\n\n"
end

#postprocess(full_document) ⇒ Object



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

def postprocess(full_document)
  full_document.rstrip
end

#raw_html(raw_html) ⇒ Object



73
74
75
# File 'lib/downterm/render.rb', line 73

def raw_html(raw_html)
  raw_html
end

#strikethrough(text) ⇒ Object



77
78
79
# File 'lib/downterm/render.rb', line 77

def strikethrough(text)
  text
end

#superscript(text) ⇒ Object



81
82
83
84
85
86
87
# File 'lib/downterm/render.rb', line 81

def superscript(text)
  if text.length > 1
    "^(#{text})"
  else
    "^#{text}"
  end
end

#triple_emphasis(text) ⇒ Object



41
42
43
# File 'lib/downterm/render.rb', line 41

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