Class: RDoc::Markup::ToBs
| Relationships & Source Files | |
| Super Chains via Extension / Inclusion / Inheritance | |
|
Class Chain:
|
|
|
Instance Chain:
|
|
| Inherits: |
RDoc::Markup::ToRdoc
|
| Defined in: | lib/rdoc/markup/to_bs.rb |
Overview
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.
Class Method Summary
-
.new(markup = nil) ⇒ ToBs
constructor
Returns a new
ToBsthat is ready for hot backspace action!
ToRdoc - Inherited
| .new | Creates a new formatter that will output (mostly) RDoc markup. |
Formatter - Inherited
| .gen_relative_url | Converts a target url to one that is relative to a given path. |
| .new | Creates a new Formatter. |
Instance Attribute Summary
ToRdoc - Inherited
| #indent | Current indent amount for output in characters. |
| #width | Output width in characters. |
| #list_index | Stack of current list indexes for alphabetic and numeric lists. |
| #list_type | Stack of list types. |
| #list_width | Stack of list widths for indentation. |
| #prefix | Prefix for the next list item. |
| #res | Output accumulator. |
Formatter - Inherited
| #in_tt? | Are we currently inside tt tags? |
Instance Method Summary
-
#accept_heading(heading)
Makes heading text bold.
-
#annotate(tag)
Turns on or off special handling for #convert_string
-
#convert_special(special)
Calls convert_string on the result of convert_special.
-
#convert_string(string)
Adds bold or underline mixed with backspaces.
-
#init_tags
Sets a flag that is picked up by #annotate to do the right thing in #convert_string
ToRdoc - Inherited
| #accept_blank_line | Adds |
| #accept_block_quote | Adds |
| #accept_heading | Adds |
| #accept_indented_paragraph | Adds |
| #accept_list_end | Finishes consumption of |
| #accept_list_item_end | Finishes consumption of |
| #accept_list_item_start | Prepares the visitor for consuming |
| #accept_list_start | Prepares the visitor for consuming |
| #accept_paragraph | Adds |
| #accept_raw | Adds |
| #accept_rule | Adds |
| #accept_verbatim | Outputs |
| #attributes | Applies attribute-specific markup to |
| #end_accepting | Returns the generated output. |
| #handle_special_HARD_BREAK | Adds a newline to the output. |
| #handle_special_SUPPRESSED_CROSSREF | Removes preceding \ from the suppressed crossref |
| #init_tags | Maps attributes to HTML sequences. |
| #start_accepting | Prepares the visitor for text generation. |
| #use_prefix | Adds the stored |
| #wrap | Wraps |
Formatter - Inherited
| #accept_document | Adds |
|
| #add_special_RDOCLINK | Adds a special for links of the form rdoc-…: |
|
| #add_special_TIDYLINK | Adds a special for links of the form |
Add a new set of tags for an attribute. |
| #annotate | Allows |
|
| #convert | Marks up |
|
| #convert_flow | Converts flow items |
|
| #convert_special | Converts added specials. |
|
| #convert_string | Converts a string to be fancier if desired. |
|
| #ignore | Use ignore in your subclass to ignore the content of a node. |
|
| #off_tags | Turns off tags for |
|
| #on_tags | Turns on tags for |
|
| #parse_url | Extracts and a scheme, url and an anchor id from |
|
| #tt? | Is |
Constructor Details
.new(markup = nil) ⇒ ToBs
Returns a new ToBs that is ready for hot backspace action!
# File 'lib/rdoc/markup/to_bs.rb', line 13
def initialize markup = nil super @in_b = false @in_em = false end
Instance Method Details
#accept_heading(heading)
Makes heading text bold.
# File 'lib/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
#annotate(tag)
Turns on or off special handling for #convert_string
# File 'lib/rdoc/markup/to_bs.rb', line 46
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_special(special)
Calls convert_string on the result of convert_special
# File 'lib/rdoc/markup/to_bs.rb', line 59
def convert_special special convert_string super end
#convert_string(string)
Adds bold or underline mixed with backspaces
# File 'lib/rdoc/markup/to_bs.rb', line 66
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
#init_tags
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 24
def add_tag :BOLD, '+b', '-b' add_tag :EM, '+_', '-_' add_tag :TT, '' , '' # we need in_tt information maintained end