RDoc::Markup::ToBs

Outputs RDoc markup with hot backspace action! You will probably need a pager to use this output format.

This formatter won’t work on 1.8.6 because it lacks String#chars.

Public Class Methods

new() click to toggle source
    # File lib/rdoc/markup/to_bs.rb, line 11
11:   def initialize
12:     super
13: 
14:     @in_b  = false
15:     @in_em = false
16:   end

Public Instance Methods

accept_heading(heading) click to toggle source
    # File lib/rdoc/markup/to_bs.rb, line 27
27:   def accept_heading heading
28:     use_prefix or @res << ' ' * @indent
29:     @res << @headings[heading.level][0]
30:     @in_b = true
31:     @res << attributes(heading.text)
32:     @in_b = false
33:     @res << @headings[heading.level][1]
34:     @res << "\n"
35:   end
annotate(tag) click to toggle source

Turns on or off special handling for convert_string

    # File lib/rdoc/markup/to_bs.rb, line 40
40:   def annotate tag
41:     case tag
42:     when '+b' then @in_b = true
43:     when '-b' then @in_b = false
44:     when '+_' then @in_em = true
45:     when '-_' then @in_em = false
46:     end
47: 
48:     ''
49:   end
convert_special(special) click to toggle source

Calls convert_string on the result of convert_special

    # File lib/rdoc/markup/to_bs.rb, line 54
54:   def convert_special special
55:     convert_string super
56:   end
convert_string(string) click to toggle source

Adds bold or underline mixed with backspaces

    # File lib/rdoc/markup/to_bs.rb, line 61
61:   def convert_string string
62:     return string unless string.respond_to? :chars # your ruby is lame
63:     return string unless @in_b or @in_em
64:     chars = if @in_b then
65:               string.chars.map do |char| "#{char}\b#{char}" end
66:             elsif @in_em then
67:               string.chars.map do |char| "_\b#{char}" end
68:             end
69: 
70:     chars.join
71:   end
init_tags() click to toggle source

Sets a flag that is picked up by annotate to do the right thing in convert_string

    # File lib/rdoc/markup/to_bs.rb, line 22
22:   def init_tags
23:     add_tag :BOLD, '+b', '-b'
24:     add_tag :EM,   '+_', '-_'
25:   end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.