Class: Greenmat::Render::ManPage

Inherits:
Base
  • Object
show all
Defined in:
lib/greenmat/render_man.rb

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Greenmat::Render::Base

Instance Method Details

#block_code(code, language) ⇒ Object



9
10
11
# File 'lib/greenmat/render_man.rb', line 9

def block_code(code, language)
  "\n.nf\n#{normal_text(code)}\n.fi\n"
end

#codespan(code) ⇒ Object



13
14
15
# File 'lib/greenmat/render_man.rb', line 13

def codespan(code)
  block_code(code, nil)
end

#double_emphasis(text) ⇒ Object



30
31
32
# File 'lib/greenmat/render_man.rb', line 30

def double_emphasis(text)
  "\\fB#{text}\\fP"
end

#emphasis(text) ⇒ Object



34
35
36
# File 'lib/greenmat/render_man.rb', line 34

def emphasis(text)
  "\\fI#{text}\\fP"
end

#header(title, level) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/greenmat/render_man.rb', line 17

def header(title, level)
  case level
  when 1
    "\n.TH #{title}\n"

  when 2
    "\n.SH #{title}\n"

  when 3
    "\n.SS #{title}\n"
  end
end

#linebreakObject



38
39
40
# File 'lib/greenmat/render_man.rb', line 38

def linebreak
  "\n.LP\n"
end

#list(content, list_type) ⇒ Object



46
47
48
49
50
51
52
53
# File 'lib/greenmat/render_man.rb', line 46

def list(content, list_type)
  case list_type
  when :ordered
    "\n\n.nr step 0 1\n#{content}\n"
  when :unordered
    "\n.\n#{content}\n"
  end
end

#list_item(content, list_type) ⇒ Object



55
56
57
58
59
60
61
62
# File 'lib/greenmat/render_man.rb', line 55

def list_item(content, list_type)
  case list_type
  when :ordered
    ".IP \\n+[step]\n#{content.strip}\n"
  when :unordered
    ".IP \\[bu] 2 \n#{content.strip}\n"
  end
end

#normal_text(text) ⇒ Object



5
6
7
# File 'lib/greenmat/render_man.rb', line 5

def normal_text(text)
  text.gsub('-', '\\-').strip
end

#paragraph(text) ⇒ Object



42
43
44
# File 'lib/greenmat/render_man.rb', line 42

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