RDoc::Markup::ToAnsi

Outputs RDoc markup with vibrant ANSI color!

Public Class Methods

new() click to toggle source
    # File lib/rdoc/markup/to_ansi.rb, line 8
 8:   def initialize
 9:     super
10: 
11:     @headings.clear
12:     @headings[1] = ["\e[1;32m", "\e[m"]
13:     @headings[2] = ["\e[4;32m", "\e[m"]
14:     @headings[3] = ["\e[32m",   "\e[m"]
15:   end

Public Instance Methods

accept_list_item_end(list_item) click to toggle source
    # File lib/rdoc/markup/to_ansi.rb, line 26
26:   def accept_list_item_end list_item
27:     width = case @list_type.last
28:             when :BULLET then
29:               2
30:             when :NOTE, :LABEL then
31:               @res << "\n"
32:               2
33:             else
34:               bullet = @list_index.last.to_s
35:               @list_index[1] = @list_index.last.succ
36:               bullet.length + 2
37:             end
38: 
39:     @indent -= width
40:   end
accept_list_item_start(list_item) click to toggle source
    # File lib/rdoc/markup/to_ansi.rb, line 42
42:   def accept_list_item_start list_item
43:     bullet = case @list_type.last
44:              when :BULLET then
45:                '*'
46:              when :NOTE, :LABEL then
47:                attributes(list_item.label) + ":\n"
48:              else
49:                @list_index.last.to_s + '.'
50:              end
51: 
52:     case @list_type.last
53:     when :NOTE, :LABEL then
54:       @indent += 2
55:       @prefix = bullet + (' ' * @indent)
56:     else
57:       @prefix = (' ' * @indent) + bullet.ljust(bullet.length + 1)
58: 
59:       width = bullet.gsub(/\e\[[\d;]*m/, '').length + 1
60: 
61:       @indent += width
62:     end
63:   end
init_tags() click to toggle source

Maps attributes to ANSI sequences

    # File lib/rdoc/markup/to_ansi.rb, line 20
20:   def init_tags
21:     add_tag :BOLD, "\e[1m", "\e[m"
22:     add_tag :TT,   "\e[7m", "\e[m"
23:     add_tag :EM,   "\e[4m", "\e[m"
24:   end
start_accepting() click to toggle source
    # File lib/rdoc/markup/to_ansi.rb, line 65
65:   def start_accepting
66:     super
67: 
68:     @res = ["\e[0m"]
69:   end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.