class 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(markup = nil)
click to toggle source
Returns a new ToBs
that is ready for hot backspace action!
Calls superclass method
RDoc::Markup::ToRdoc::new
# File rdoc/markup/to_bs.rb, line 13 def initialize markup = nil super @in_b = false @in_em = false end
Public Instance Methods
accept_heading(heading)
click to toggle source
Makes heading text bold.
# File rdoc/markup/to_bs.rb, line 33 def accept_heading heading use_prefix or @res << ' ' * @indent @res << @headings[heading.level][0] @in_b = true @res << attributes(heading.text) @in_b = false @res << @headings[heading.level][1] @res << "\n" end
accept_list_item_start(list_item)
click to toggle source
Prepares the visitor for consuming list_item
# File rdoc/markup/to_bs.rb, line 46 def accept_list_item_start list_item type = @list_type.last case type when :NOTE, :LABEL then bullets = Array(list_item.label).map do |label| attributes(label).strip end.join "\n" bullets << ":\n" unless bullets.empty? @prefix = ' ' * @indent @indent += 2 @prefix << bullets + (' ' * @indent) else bullet = type == :BULLET ? '*' : @list_index.last.to_s + '.' @prefix = (' ' * @indent) + bullet.ljust(bullet.length + 1) width = bullet.length + 1 @indent += width end end
annotate(tag)
click to toggle source
Turns on or off regexp handling for convert_string
# File rdoc/markup/to_bs.rb, line 71 def annotate tag case tag when '+b' then @in_b = true when '-b' then @in_b = false when '+_' then @in_em = true when '-_' then @in_em = false end '' end
convert_regexp_handling(target)
click to toggle source
Calls convert_string
on the result of convert_regexp_handling
Calls superclass method
RDoc::Markup::Formatter#convert_regexp_handling
# File rdoc/markup/to_bs.rb, line 84 def convert_regexp_handling target convert_string super end
convert_string(string)
click to toggle source
Adds bold or underline mixed with backspaces
# File rdoc/markup/to_bs.rb, line 91 def convert_string string return string unless @in_b or @in_em chars = if @in_b then string.chars.map do |char| "#{char}\b#{char}" end elsif @in_em then string.chars.map do |char| "_\b#{char}" end end chars.join end