In Files

  • rdoc/markup/to_bs.rb

Class/Module Index [+]



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!

               # File rdoc/markup/to_bs.rb, line 12
def initialize markup = nil

  @in_b  = false
  @in_em = false

Public Instance Methods

accept_heading(heading) click to toggle source

Makes heading text bold.

               # File rdoc/markup/to_bs.rb, line 32
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"
annotate(tag) click to toggle source

Turns on or off special handling for convert_string

               # File rdoc/markup/to_bs.rb, line 45
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
convert_special(special) click to toggle source

Calls #convert_string on the result of #convert_special

               # File rdoc/markup/to_bs.rb, line 58
def convert_special special
  convert_string super
convert_string(string) click to toggle source

Adds bold or underline mixed with backspaces

               # File rdoc/markup/to_bs.rb, line 65
def convert_string string
  return string unless string.respond_to? :chars # your ruby is lame
  return string unless @in_b or @in_em
  chars = if @in_b then
   do |char| "#{char}\b#{char}" end
          elsif @in_em then
   do |char| "_\b#{char}" 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 rdoc/markup/to_bs.rb, line 23
def init_tags
  add_tag :BOLD, '+b', '-b'
  add_tag :EM,   '+_', '-_'
  add_tag :TT,   ''  , ''   # we need in_tt information maintained

Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.

If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.

If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.

If you want to help improve the Ruby documentation, please visit