Class: Md2Ansi::Ansi

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

Instance Method Summary collapse

Instance Method Details



43
44
45
# File 'lib/md2ansi/render.rb', line 43

def autolink(link, link_type)
  link
end

#block_code(code, language) ⇒ Object



11
12
13
# File 'lib/md2ansi/render.rb', line 11

def block_code(code, language)
  Pygments.highlight(code, :lexer => language, :formatter => 'terminal') + "\n\n"
end

#codespan(code) ⇒ Object



15
16
17
# File 'lib/md2ansi/render.rb', line 15

def codespan(code)
  Pygments.highlight(code, :formatter => 'terminal')
end

#double_emphasis(text) ⇒ Object



31
32
33
# File 'lib/md2ansi/render.rb', line 31

def double_emphasis(text)
  " #{ansi(text, :yellow)} "
end

#emphasis(text) ⇒ Object



35
36
37
# File 'lib/md2ansi/render.rb', line 35

def emphasis(text)
  " #{ansi(text, :white, :on_black)} "
end

#header(title, level) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/md2ansi/render.rb', line 19

def header(title, level)

  case level
  when 1
    ansi(title, :red)
  when 2
    ansi(title, :black, :on_red)
  when 3
    ansi(title, :cyan)
  end + "\n\n"
end

#image(link, title, alt_text) ⇒ Object



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

def image(link, title, alt_text)
  " #{content}(#{ansi(link, :underline)}) "
end

#linebreakObject



39
40
41
# File 'lib/md2ansi/render.rb', line 39

def linebreak
  ""
end


47
48
49
# File 'lib/md2ansi/render.rb', line 47

def link(link, title, content)
  " #{content}(#{ansi(link, :underline)}) "
end

#list(content, list_type) ⇒ Object



59
60
61
62
63
64
65
66
67
# File 'lib/md2ansi/render.rb', line 59

def list(content, list_type)
  case list_type
  when :ordered
    @order = 0
    "#{content}\n"
  when :unordered
    "#{content}\n"
  end
end

#list_item(content, list_type) ⇒ Object



69
70
71
72
73
74
75
76
77
# File 'lib/md2ansi/render.rb', line 69

def list_item(content, list_type)
  case list_type
  when :ordered
    @order =(@order or 0) + 1
    "#{@order}. #{content.strip}\n"
  when :unordered
    "+ #{content.strip}\n"
  end
end

#normal_text(text) ⇒ Object



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

def normal_text(text)
  text.strip
end

#paragraph(text) ⇒ Object



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

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